-
Notifications
You must be signed in to change notification settings - Fork 4
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
[DT-1087] Date Picker initial implementation with tests. #2749
Conversation
…est more reliable in CI/CD.
…yping a bad date.
There's an observed issue with Github Actions and the MUI date picker (generic) component rendering in "mobile" mode when being exercised in cypress under a github action. To account for this, I opted to guarantee the Desktop date component since a Data Submitter working on a mobile device is not fully supported at this point. |
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.
Thank you for the linting and test cleanup, looks reasonable to me 👍🏽
src/components/DuosDatePicker.tsx
Outdated
color: '#000', | ||
fontSize: '13px', | ||
fontWeight: '400', | ||
padding: '7px 20px 7px 20px', |
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.
Nit: I think this could be 7px 20px
src/components/DuosDatePicker.tsx
Outdated
fontWeight: '400', | ||
padding: '7px 20px 7px 20px', | ||
'&.Mui-selected': { | ||
backgroundColor: '#216FB4', |
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.
Could we make an intermediate variable for this?
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.
@s-rubenstein - Do you mean a CSS variable that calculates the value or a variable that assigns the backgroundColor to the theme?
src/components/DuosDatePicker.tsx
Outdated
styleOverrides:{ | ||
weekDayLabel:{ | ||
fontFamily: 'Montserrat', | ||
color: '#000', |
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.
How would you feel about standardizing this on black
/using the color names where we have them?
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.
I don't have strong feelings about this and would be happy to make that change, however we should be on the same page about colors in the context of MUI. Do you expect to see MUI color palettes or CSS ? For this PR, do you expect that standardization across all of DUOS-UI or just in the context of the DuosDatePicker?
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.
One minor thing I've observed in just using the CSS color 'black' instead of '#000' is that the IDE removes the option for the color picker in the gutter. Does that matter to you?
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.
For black I don't strongly care - if we need to change it we can always move it to get the color picker back.
I would personally say let's steer towards unity across the codebase, so if the rest of the codebase uses #000
then lets do that. However, I think right now there's existing inconsistency?
src/components/DuosDatePicker.tsx
Outdated
label={'Select a date'} | ||
format={inputFormat} | ||
value={value} | ||
onAccept={(value)=>{onChange(value);}} |
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.
Nit: I think you can just provide the method reference here?
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.
I'll tweak the types on both onChange and onError from Function
to any
and update these.
Sorry for the back and forth edits on this. I've got the types tweaked for this now to be just a method reference. In making and testing, I found a bug with date validation in a test that I needed to fix. I was passing in the wrong validator in the test.
src/components/DuosDatePicker.tsx
Outdated
format={inputFormat} | ||
value={value} | ||
onAccept={(value)=>{onChange(value);}} | ||
onError={(error, value)=> onError(error, value)} |
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.
Same comment about the method reference
export const dayJSValidator = { | ||
id: 'dayjs', | ||
isValid: (val) => isValidDayjsDate(val), | ||
msg: 'Please select a valid date.', |
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.
Wondering about if there is a way to make this error message more helpful, if it is a pop up calendar, what is the case where a user selects an invalid date?
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.
Great question! The control includes a text field that users can type into. The control does a good job at guarding against invalid dates, but they are still theoretically possible. For example, you can type in 2/31/2025.
|
||
const CancelSelectActionBar = (props:PickersActionBarProps) => { | ||
// Quirk of this control's usage pattern is the need to destructure the unused onSetToday and onClear from 'other' | ||
// props. This is in part because per mockup, this control does not support 'clear' or 'go to today' style buttons. |
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.
can you link the mocks? we don't need a clear button because there is cancel? and we don't need go to today because today is the default value? is that right?
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.
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.
the changes look good, but I'm lacking context from the ticket or the PR description. I know you said it's only visible in tests rn, but I'd love to see what it looks like and where it is used.
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.
the date picker looks good and love the linting thank you!
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.
tests and component look good 👍
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.
LGTM
Addresses
DT-1087
Summary
Adds a form field type of a date picker to Duos UI components per mockups from UX. Visible in tests only.
Have you read Terra's Contributing Guide lately? If not, do that first.