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

fix: DatePicker styles with updated spec #1697

Merged
merged 12 commits into from
Mar 8, 2023
Merged

Conversation

KevinGhadyani-Okta
Copy link
Contributor

Description

Updated DatePicker styles with updated spec.

transform: "translateY(-50%)",
width: `${(2 / 16) * (16 / 14)}rem`,
Copy link
Contributor

Choose a reason for hiding this comment

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

These won't hold if someone overrides typography.fontSize. What's the goal here? Maybe I can point you toward something safer.

Copy link
Contributor

Choose a reason for hiding this comment

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

For ex, we use em for our Status dots, so that they're always related to the size of the Status type:

"&::before": {
  content: "''",
  width: ".57em",
  height: ".57em",
  marginInlineEnd: theme.spacing(2),
  borderRadius: "100%",
  backgroundColor: theme.palette.text.secondary,
}

(We should probably have variables for these dot sizes, but you get the idea.)

Copy link
Contributor Author

@KevinGhadyani-Okta KevinGhadyani-Okta Feb 28, 2023

Choose a reason for hiding this comment

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

If someone overrides typography.fontSize, you're saying it won't scale up the width? Yeah, I'm assuming fonts sale with the HTML which is why I'm using rem.

But if someone modifies the MUI font size which doesn't modify the html element, then this 2px won't be consistent with the MUI font size right?

But I agree, they should be set as token variables, not 2px as rem.

Copy link
Contributor Author

@KevinGhadyani-Okta KevinGhadyani-Okta Mar 1, 2023

Choose a reason for hiding this comment

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

Updated to this:

Suggested change
width: `${(2 / 16) * (16 / 14)}rem`,
width: '0.14285714285714285em', // 2px

Actually, changed it to this instead so someone else (or me) doesn't have to do the math by hand:

Suggested change
width: `${(2 / 16) * (16 / 14)}rem`,
width: `${(2 / 16) * (16 / 14)}em`,

This only works because the fontSize is FontScale1. I think I need to change 16 to use FontScale1, and we should be good, but then I'd be using calc() instead which causes other issues. If I had access to the pixel values of our fonts, it'd be a lot more reliable, but this does scale properly if the font-size changes.

default: ({ theme }) => ({
backgroundColor: theme.palette.primary.main,
content: '""',
height: `${(16 / 16) * (16 / 14)}rem`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar comment as above here. Could this be 1em or theme.typography.body.fontSize?

Copy link
Contributor Author

@KevinGhadyani-Okta KevinGhadyani-Okta Feb 28, 2023

Choose a reason for hiding this comment

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

I made it relative to the fontSize. That makes sense here.

Suggested change
height: `${(16 / 16) * (16 / 14)}rem`,
height: theme.typography.body1.fontSize,

Copy link
Contributor Author

@KevinGhadyani-Okta KevinGhadyani-Okta Mar 1, 2023

Choose a reason for hiding this comment

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

Actually, I changed this to h6 because 1rem is actually 14px rather than 16px to match the text. FontScale2. The icon needs to be sized 1 font size above the text to match the design.

Copy link
Contributor

Choose a reason for hiding this comment

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

Totally cool to use fontSize variables here. Another option I use sometimes is theme.typography.ui.lineHeight, which is unitless. You can tag an em on there to make it scale with the local font-size (which gives you 16px with 14px type).

@edburyenegren-okta
Copy link
Contributor

I missed this during the initial PR. At 141 you have width: ${(296 / 16) * (16 / 14)}rem, width: auto solves the same problem and should be safer.

@KevinGhadyani-Okta
Copy link
Contributor Author

KevinGhadyani-Okta commented Feb 28, 2023

I missed this during the initial PR. At 141 you have width: ${(296 / 16) * (16 / 14)}rem, width: auto solves the same problem and should be safer.

I agree completely, but MUI requires a fixed height here because it's using position: absolute on the dates. I'd have to reconfigure the way dates render to remove this fixed height, and I'm not sure that's gonna be risky or not considering how much MUI's changing in the next version.

@edburyenegren-okta
Copy link
Contributor

edburyenegren-okta commented Feb 28, 2023

I'd have to reconfigure the way dates render to remove this fixed height[...]

This is for the width, not the height. Changing to width: auto gives the expected result:

Screenshot 2023-02-28 at 2 34 52 PM

@KevinGhadyani-Okta
Copy link
Contributor Author

KevinGhadyani-Okta commented Mar 1, 2023

There's a few px difference in width from a fixed-width to 'auto'. I'll keep it at 'auto', but it might be wider than we expect. Probably, it's the correct size.

Look at how much farther out the navigation arrows appear:
image
image

'auto' also shrinks the Year view. Do we want it fixed-width or 'auto'?
image

@edburyenegren-okta
Copy link
Contributor

Good question re: the shifting sizes between displays. I prefer my containers sized to content, but @josesolano-okta and @taylorridgway-okta may want a uniform experience when clicking through the picker.

@taylorridgway-okta
Copy link

Good question re: the shifting sizes between displays. I prefer my containers sized to content, but @josesolano-okta and @taylorridgway-okta may want a uniform experience when clicking through the picker.

As predicted, I'd prefer uniform width for both views if possible

@KevinGhadyani-Okta KevinGhadyani-Okta force-pushed the kg/OKTA-577942 branch 2 times, most recently from b9be9df to 3e004da Compare March 3, 2023 20:50
content: '" "',
height: `${(2 / 16) * (16 / 14)}rem`,
height: `${(2 / 16) * (16 / 14)}em`,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this 2px in Figma? If so, can prolly leave it as such here. The (16 / 14) modifier won't make sense if someone rethemes the base fontSize, since the proportional adjustment will be different.

If we do want it to scale with the font-size, the calculated value might be better since it won't need to reference the global values at all. It's something Design should probably create a token for anyway.

Copy link
Contributor

@edburyenegren-okta edburyenegren-okta Mar 3, 2023

Choose a reason for hiding this comment

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

width: `${(2 / {theme.typography.fontSize})}em`

@KevinGhadyani-Okta KevinGhadyani-Okta merged commit cba0894 into develop Mar 8, 2023
@KevinGhadyani-Okta KevinGhadyani-Okta deleted the kg/OKTA-577942 branch March 8, 2023 16:59
KevinGhadyani-Okta added a commit that referenced this pull request Mar 9, 2023
* fix(odyssey-react-mui): don't require children prop for Icon buttons

* fix: DatePicker styles with updated spec (#1697)

* fix: added missing MuiThemeDecorator to DatePicker story

* fix: adjusted spacing on DatePicker to match design

* chore: updated yarn

* fix: potential fix for local MUI and Labs development

* fix: styled DatePicker to match new design spec

* fix: add build before yarn start and fix order of yarn dev

* fix: added missing DatePicker border

* fix(odyssey-react-labs): improved selected vs "this year" styling

* fix(odyssey-storybook): hover styles outside of month

* fix(odyssey-storybook): removed MUI Month Picker styles

* fix(odyssey-react-labs): added theme variables where they were hardcoded

* fix(odyssey-react-labs): improved DatePicker styles to be more dynamic

---------

Co-authored-by: Kamron Batmanghelich <kamron.batmanghelich@okta.com>

* build: bump versions for v0.21.0

* docs: update CHANGELOG for v0.21.0

---------

Co-authored-by: Kevin Ghadyani <97464104+KevinGhadyani-Okta@users.noreply.github.com>
Co-authored-by: Kamron Batmanghelich <kamron.batmanghelich@okta.com>
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.

4 participants