Skip to content
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

Merged
merged 10 commits into from
Dec 16, 2024

Conversation

otchet-broad
Copy link
Contributor

@otchet-broad otchet-broad commented Dec 9, 2024

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.

  • Label PR with a Jira ticket number and include a link to the ticket
  • Label PR with a security risk modifier [no, low, medium, high]
  • PR describes scope of changes
  • Get a minimum of one thumbs worth of review, preferably two if enough team members are available
  • Get PO sign-off for all non-trivial UI or workflow changes
  • Verify all tests go green
  • Test this change deployed correctly and works on dev environment after deployment

@otchet-broad otchet-broad marked this pull request as ready for review December 10, 2024 19:10
@otchet-broad otchet-broad requested a review from a team as a code owner December 10, 2024 19:10
@otchet-broad otchet-broad requested review from pshapiro4broad and rjohanek and removed request for a team December 10, 2024 19:10
@otchet-broad
Copy link
Contributor Author

otchet-broad commented Dec 10, 2024

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.
See https://stackoverflow.com/questions/69799310/cypress-testing-a-material-ui-datepicker-is-not-working-on-github-actions.

Copy link
Contributor

@rushtong rushtong left a 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 👍🏽

color: '#000',
fontSize: '13px',
fontWeight: '400',
padding: '7px 20px 7px 20px',
Copy link
Contributor

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

fontWeight: '400',
padding: '7px 20px 7px 20px',
'&.Mui-selected': {
backgroundColor: '#216FB4',
Copy link
Contributor

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?

Copy link
Contributor Author

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?

styleOverrides:{
weekDayLabel:{
fontFamily: 'Montserrat',
color: '#000',
Copy link
Contributor

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?

Copy link
Contributor Author

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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?

label={'Select a date'}
format={inputFormat}
value={value}
onAccept={(value)=>{onChange(value);}}
Copy link
Contributor

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?

Copy link
Contributor Author

@otchet-broad otchet-broad Dec 11, 2024

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.

format={inputFormat}
value={value}
onAccept={(value)=>{onChange(value);}}
onError={(error, value)=> onError(error, value)}
Copy link
Contributor

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.',
Copy link
Contributor

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?

Copy link
Contributor Author

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.
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!
Mocks:
image

Rendered component:
image

Copy link
Contributor

@rjohanek rjohanek left a 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.

Copy link
Contributor

@rjohanek rjohanek left a 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!

Copy link
Contributor

@fboulnois fboulnois left a 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 👍

Copy link
Contributor

@s-rubenstein s-rubenstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@otchet-broad otchet-broad merged commit 8c494e2 into develop Dec 16, 2024
10 checks passed
@otchet-broad otchet-broad deleted the otchet/DT-1087-date-picker-component branch December 16, 2024 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants