Skip to content

Breakpoint values refactor #50

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Jpoliachik
Copy link
Contributor

@Jpoliachik Jpoliachik commented Jun 21, 2022

Description

This PR introduces a different enum to use for Breakpoints - ScreenSize.

Why?

  • Our components use a mixture of CSS media query breakpoints and React render calculations. We need to convert our breakpoint values to numbers to be used within React view calculation hooks - string value 800px doesn't work here. And we need these values to be consistent within .css.ts styles and render functions.

  • There are tons of magic numbers everywhere, and each component seems to have its own custom value for what "isMobile" means. We need a totally agnostic set of values that will work across the app. Terms like isMobile isTablet isDesktop can have intrinsic meaning outside of the screen width itself (eg, is the user actually on a mobile device? regardless of screen size?) - so those terms can be confusing. (Also - no clue if Mobile is bigger or smaller than Small and if Large is bigger than Desktop?)

ScreenSize names and values were copied from TailwindCSS's standard breakpoints (https://tailwindcss.com/docs/screens#max-width-breakpoints) - which I trust to be a pretty good industry standard here.

Changes Made

  • ScreenSize enum
  • useBreakpoint hooks (we previously had no way to get DS breakpoint values inside render())
  • Breakpoint.mdx doc file

image


Checklist

I confirm that I have added relevant:

  • stories
  • tests
  • comments

Figma (optional)

Other (optional)

@Jpoliachik Jpoliachik requested a review from a team as a code owner June 21, 2022 18:13
@netlify
Copy link

netlify bot commented Jun 21, 2022

Deploy Preview for studio-design-system ready!

Name Link
🔨 Latest commit 1f45332
🔍 Latest deploy log https://app.netlify.com/sites/studio-design-system/deploys/62b31c693891f50009b2d28e
😎 Deploy Preview https://deploy-preview-50--studio-design-system.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

xxl = 1536,
}

// deprecated, use ScreenSize instead.
export enum Breakpoint {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's definitely confusing for both of these enums to coexist. But I decided to keep the old one here for now to prevent breaking changes and let us convert in our own time.

@@ -11,7 +11,6 @@ export enum ThemeType {
// default theme (light colors)
export const lightThemeRawValues = {
spacing,
screenSizes,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

screenSizes isn't used anywhere in DS, or frontend repos, as far as I can tell. should be safe to remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In addition - it's better to keep ScreenSize values out of the theme IMO, since the theme is meant to contain values that may change between light/dark/other themes - but in our case, we want ScreenSize to be accessible from both VanillaExtract styling, and React hooks. Inserting themeing into the hooks would introduce unneeded complexity.

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.

1 participant