-
Notifications
You must be signed in to change notification settings - Fork 336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gcal): gcal date UI/UX #8696
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
455dd3c
get selectedTeamHasGcalAuth
nickoferrall 769becc
open gcal modal after auth
nickoferrall 54322b1
only open modal for the team that has authed
nickoferrall 0999305
and gcal error snackbar and hasGcalError to start retro payload
nickoferrall 2770dbc
add gcal err handler to sprint poker
nickoferrall 6401793
add hasGcalError to startTeamPrompt
nickoferrall 478da3f
clean up
nickoferrall 3521aee
get gcal date time picker menu working
nickoferrall 349097a
fix date pickers 24 hr clock
nickoferrall 4723853
fix close modal
nickoferrall 6ae34e2
override mui border styles
nickoferrall a5138c7
update border width when leaving input
nickoferrall 4c2b65e
always update end date after updating start date
nickoferrall a0aeaa7
override border styles when hovering into the calendar menu
nickoferrall c53f392
separate the date and time pickers
nickoferrall 2943044
fix merge conflicts
nickoferrall be2faf0
fix merge conflicts
nickoferrall 173edb6
update start if end date is before start
nickoferrall 8b542bc
add handleMouseDown comment
nickoferrall File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 0 additions & 86 deletions
86
packages/client/modules/userDashboard/components/GcalModal/DateTimePicker.tsx
This file was deleted.
Oops, something went wrong.
121 changes: 121 additions & 0 deletions
121
packages/client/modules/userDashboard/components/GcalModal/DateTimePickers.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import React from 'react' | ||
import {Dayjs} from 'dayjs' | ||
import {LocalizationProvider} from '@mui/x-date-pickers/LocalizationProvider' | ||
import {AdapterDayjs} from '@mui/x-date-pickers/AdapterDayjs' | ||
import {DatePicker, TimePicker} from '@mui/x-date-pickers' | ||
import {PALETTE} from '../../../../styles/paletteV3' | ||
|
||
const customStyles = { | ||
width: '100%', | ||
'& .MuiOutlinedInput-root': { | ||
'&:hover .MuiOutlinedInput-notchedOutline, &.Mui-focused .MuiOutlinedInput-notchedOutline, &.focus-within .MuiOutlinedInput-notchedOutline': | ||
{ | ||
borderColor: PALETTE.SLATE_400, | ||
borderWidth: '1px' | ||
}, | ||
'&.Mui-focused': { | ||
outline: 'none' | ||
} | ||
}, | ||
'& label': { | ||
color: PALETTE.SLATE_600, | ||
'&.Mui-focused': { | ||
color: PALETTE.SLATE_600 | ||
} | ||
}, | ||
'& .MuiPickersDay-dayWithMargin': { | ||
'&:hover, &:focus': { | ||
borderColor: PALETTE.SLATE_400, | ||
outline: 'none' | ||
} | ||
}, | ||
'& .MuiPickersCalendarHeader-switchHeader button:focus': { | ||
outline: 'none', | ||
color: PALETTE.SLATE_600 | ||
} | ||
} | ||
|
||
const timePickerStyles = { | ||
...customStyles, | ||
width: '50%' | ||
} | ||
|
||
type Props = { | ||
startValue: Dayjs | ||
setStart: (newValue: Dayjs) => void | ||
endValue: Dayjs | ||
setEnd: (newValue: Dayjs) => void | ||
} | ||
|
||
const DateTimePickers = (props: Props) => { | ||
const {startValue, setStart, endValue, setEnd} = props | ||
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone | ||
const date = new Date() | ||
const dateTimeString = date.toLocaleString('en-US', {timeZone: timeZone, timeZoneName: 'short'}) | ||
const timeZoneShort = dateTimeString.split(' ').pop() | ||
|
||
const handleChangeStart = (date: Dayjs | null, time: Dayjs | null) => { | ||
if (date && time) { | ||
const newValue = date.hour(time.hour()).minute(time.minute()) | ||
setStart(newValue) | ||
setEnd(newValue.add(1, 'hour')) | ||
} | ||
} | ||
|
||
const handleChangeEnd = (date: Dayjs | null, time: Dayjs | null) => { | ||
if (date && time) { | ||
const newValue = date.hour(time.hour()).minute(time.minute()) | ||
if (newValue.isAfter(startValue)) { | ||
setEnd(newValue) | ||
} else { | ||
const newStartValue = newValue.subtract(1, 'hour') | ||
setStart(newStartValue) | ||
setEnd(newValue) | ||
} | ||
} | ||
} | ||
|
||
const handleMouseDown = (e: React.MouseEvent<HTMLDivElement, MouseEvent>) => { | ||
// prevent gcal modal from closing when clicking datetime pickers | ||
e.stopPropagation() | ||
} | ||
|
||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<div className='w flex flex-col justify-between space-y-4 pt-3'> | ||
<div className='flex space-x-2' onMouseDown={handleMouseDown}> | ||
<DatePicker | ||
label={`Meeting Start Date`} | ||
value={startValue} | ||
onChange={(date) => handleChangeStart(date, startValue)} | ||
format='MMMM D, YYYY' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +2 I like we've used an unambiguous format |
||
sx={customStyles} | ||
/> | ||
<TimePicker | ||
label={`Start Time (${timeZoneShort})`} | ||
value={startValue} | ||
onChange={(time) => handleChangeStart(startValue, time)} | ||
sx={timePickerStyles} | ||
/> | ||
</div> | ||
<div className='flex space-x-2' onMouseDown={handleMouseDown}> | ||
<DatePicker | ||
label={`Meeting End Date`} | ||
value={endValue} | ||
onChange={(date) => handleChangeEnd(date, endValue)} | ||
format='MMMM D, YYYY' | ||
sx={customStyles} | ||
/> | ||
<TimePicker | ||
label={`End Time (${timeZoneShort})`} | ||
value={endValue} | ||
onChange={(time) => handleChangeEnd(endValue, time)} | ||
sx={timePickerStyles} | ||
/> | ||
</div> | ||
</div> | ||
</LocalizationProvider> | ||
) | ||
} | ||
|
||
export default DateTimePickers |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-1 Why is this needed, please add a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated! 👍