[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
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

WB-1655: Add mediaQuery breakpoints to wonder-blocks-tokens #2349

Merged
merged 15 commits into from
Nov 4, 2024

Conversation

marcysutton
Copy link
Member

Adds initial media query tokens for breakpoint sizes in wonder-blocks-tokens. Breakpoint values are derived from internal docs:

  Wonder Blocks (Web) Design at (Figma)
small < 682px 320px width (iPhone SE, 1st-gen)
medium 682 – 1023px 768px width (iPad portrait, many generations)
large 1024px – infinity 1366px width (Chromebook)

The structure of this new mediaQueries object mimics the version in webapp (internal) pretty closely, but with values documented internally in Confluence: (see "Future Breakpoints"): https://khanacademy.atlassian.net/wiki/spaces/WB/pages/2099970518/Layout+Breakpoints

Screenshot of the new docs, note there aren't examples of each one like the other tokens:
Screenshot 2024-10-18 at 3 47 51 PM

I did some initial testing in Wonder Blocks to ensure the type definition works and paired with @kevinbarabash to see if we could make it any more dynamic. But I think simple is fine for now as it's a bit of dark magic how these media query fragments turn into CSS Properties in Aphrodite.

My next step will be to update all @media viewport sizing in WB to use these new breakpoints!

Jira issue: https://khanacademy.atlassian.net/browse/WB-1655

Copy link
changeset-bot bot commented Oct 18, 2024

🦋 Changeset detected

Latest commit: 9733fc0

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 23 packages
Name Type
@khanacademy/wonder-blocks-tokens Minor
@khanacademy/wonder-blocks-accordion Patch
@khanacademy/wonder-blocks-banner Patch
@khanacademy/wonder-blocks-birthday-picker Patch
@khanacademy/wonder-blocks-breadcrumbs Patch
@khanacademy/wonder-blocks-button Patch
@khanacademy/wonder-blocks-cell Patch
@khanacademy/wonder-blocks-clickable Patch
@khanacademy/wonder-blocks-dropdown Patch
@khanacademy/wonder-blocks-form Patch
@khanacademy/wonder-blocks-grid Patch
@khanacademy/wonder-blocks-icon-button Patch
@khanacademy/wonder-blocks-labeled-field Patch
@khanacademy/wonder-blocks-layout Patch
@khanacademy/wonder-blocks-link Patch
@khanacademy/wonder-blocks-modal Patch
@khanacademy/wonder-blocks-pill Patch
@khanacademy/wonder-blocks-popover Patch
@khanacademy/wonder-blocks-progress-spinner Patch
@khanacademy/wonder-blocks-search-field Patch
@khanacademy/wonder-blocks-switch Patch
@khanacademy/wonder-blocks-toolbar Patch
@khanacademy/wonder-blocks-tooltip Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@khan-actions-bot khan-actions-bot requested a review from a team October 18, 2024 23:23
@khan-actions-bot
Copy link
Contributor
khan-actions-bot commented Oct 18, 2024

Gerald

Required Reviewers
  • @Khan/wonder-blocks for changes to .changeset/few-paws-speak.md, types/aphrodite.d.ts, __docs__/wonder-blocks-tokens/__overview__.mdx, __docs__/wonder-blocks-tokens/tokens-media-queries.mdx, packages/wonder-blocks-tokens/src/index.ts, packages/wonder-blocks-tokens/src/tokens/media-queries.ts

Don't want to be involved in this pull request? Comment #removeme and we won't notify you of further changes.

Copy link
Contributor
github-actions bot commented Oct 18, 2024

Size Change: +259 B (+0.26%)

Total Size: 101 kB

Filename Size Change
packages/wonder-blocks-tokens/dist/es/index.js 2.36 kB +259 B (+12.35%) ⚠️
ℹ️ View Unchanged
Filename Size
packages/wonder-blocks-accordion/dist/es/index.js 3.78 kB
packages/wonder-blocks-banner/dist/es/index.js 1.53 kB
packages/wonder-blocks-birthday-picker/dist/es/index.js 1.77 kB
packages/wonder-blocks-breadcrumbs/dist/es/index.js 887 B
packages/wonder-blocks-button/dist/es/index.js 4.04 kB
packages/wonder-blocks-cell/dist/es/index.js 2.01 kB
packages/wonder-blocks-clickable/dist/es/index.js 3.06 kB
packages/wonder-blocks-core/dist/es/index.js 3.44 kB
packages/wonder-blocks-data/dist/es/index.js 6.24 kB
packages/wonder-blocks-dropdown/dist/es/index.js 18.2 kB
packages/wonder-blocks-form/dist/es/index.js 6.21 kB
packages/wonder-blocks-grid/dist/es/index.js 1.36 kB
packages/wonder-blocks-i18n/dist/es/index.js 4.76 kB
packages/wonder-blocks-icon-button/dist/es/index.js 3 kB
packages/wonder-blocks-icon/dist/es/index.js 828 B
packages/wonder-blocks-labeled-field/dist/es/index.js 72 B
packages/wonder-blocks-layout/dist/es/index.js 1.82 kB
packages/wonder-blocks-link/dist/es/index.js 2.28 kB
packages/wonder-blocks-modal/dist/es/index.js 5.36 kB
packages/wonder-blocks-pill/dist/es/index.js 1.65 kB
packages/wonder-blocks-popover/dist/es/index.js 4.87 kB
packages/wonder-blocks-progress-spinner/dist/es/index.js 1.52 kB
packages/wonder-blocks-search-field/dist/es/index.js 1.3 kB
packages/wonder-blocks-switch/dist/es/index.js 1.94 kB
packages/wonder-blocks-testing-core/dist/es/index.js 3.74 kB
packages/wonder-blocks-testing/dist/es/index.js 1.07 kB
packages/wonder-blocks-theming/dist/es/index.js 693 B
packages/wonder-blocks-timing/dist/es/index.js 1.8 kB
packages/wonder-blocks-toolbar/dist/es/index.js 827 B
packages/wonder-blocks-tooltip/dist/es/index.js 7.08 kB
packages/wonder-blocks-typography/dist/es/index.js 1.23 kB

compressed-size-action

Copy link
Contributor
github-actions bot commented Oct 18, 2024

A new build was pushed to Chromatic! 🚀

https://5e1bf4b385e3fb0020b7073c-hmpwdvfyty.chromatic.com/

Chromatic results:

Metric Total
Captured snapshots 0
Tests with visual changes 0
Total stories 497
Inherited (not captured) snapshots [TurboSnap] 372
Tests on the build 372

Copy link
codecov bot commented Oct 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (0ac8cbd) to head (d39c334).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@     Coverage Diff      @@
##   main   #2349   +/-   ##
============================
============================

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0ac8cbd...d39c334. Read the comment docs.

Copy link
Contributor
github-actions bot commented Oct 21, 2024

npm Snapshot: Published

🎉 Good news!! We've packaged up the latest commit from this PR (2f1741e) and published all packages with changesets to npm.

You can install the packages in webapp by running:

./services/static/dev/tools/deploy_wonder_blocks.js --tag="PR2349"

Packages can also be installed manually by running:

yarn add @khanacademy/wonder-blocks-<package-name>@PR2349

Copy link
Member
@beaesguerra beaesguerra left a comment

Choose a reason for hiding this comment

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

Excited to have tokens for breakpoints 😄 Left a few questions I had!

__docs__/wonder-blocks-tokens/tokens-media-queries.mdx Outdated Show resolved Hide resolved
packages/wonder-blocks-tokens/src/tokens/media-queries.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-tokens/src/tokens/media-queries.ts Outdated Show resolved Hide resolved
@khan-actions-bot khan-actions-bot requested a review from a team October 29, 2024 21:51
types/aphrodite.d.ts Outdated Show resolved Hide resolved
Copy link
Member
@jandrade jandrade left a comment

Choose a reason for hiding this comment

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

Thanks for working through this. I'd like to get your thoughts on some suggestions to get this breakpoint tokens more in line with the other WB tokens.

packages/wonder-blocks-tokens/src/tokens/media-queries.ts Outdated Show resolved Hide resolved
packages/wonder-blocks-tokens/src/tokens/media-queries.ts Outdated Show resolved Hide resolved
types/aphrodite.d.ts Outdated Show resolved Hide resolved
@khan-actions-bot khan-actions-bot requested a review from a team November 1, 2024 21:57
Copy link
@kevinb-khan kevinb-khan left a comment

Choose a reason for hiding this comment

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

One thing you may want to consider for a potential future PR is using code generation to keep tokens/media-queries.ts and types/aphrodite.d.ts.

Comment on lines 17 to 18
const mediaQuery = {
// Named

Choose a reason for hiding this comment

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

There should probably be a comment here telling people if they make changes here they need to also update aphrodite.d.ts.

Comment on lines +4 to +7
const xs =
"@media screen and (max-width: 567px) /* breakpoint.mediaQuery.xs */";
const sm =
"@media screen and (min-width: 568px) and (max-width: 681px) /* breakpoint.mediaQuery.sm */";

Choose a reason for hiding this comment

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

There should probably be a comment here telling people if they make changes here they also need to update tokens/media-queries.ts.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call!

@marcysutton
Copy link
Member Author

One thing you may want to consider for a potential future PR is using code generation to keep tokens/media-queries.ts and types/aphrodite.d.ts.

@kevinb-khan good idea. Do you know of an example of that being done in Wonder Blocks? Could the media-queries.ts file be the source of truth to generate the type definition, or would it have to be the other way around? Some of this will need to change when we move away from Aphrodite, anyway.

Copy link
Member
@jandrade jandrade left a comment

Choose a reason for hiding this comment

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

Looks great! thank you so much for implementing the changes and iterating on the Types 🚀


const mediaQuery = {
// Named
xs: `@media screen and (max-width: ${width.xsMax}px) /* breakpoint.mediaQuery.xs */`,
Copy link
Member

Choose a reason for hiding this comment

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

Is /* breakpoint.mediaQuery.xs */ useful for IDE auto completion or something else?

I was looking at the Docs and that info appears duplicated in the table.

Screenshot 2024-11-04 at 12 02 33 PM

Again, if this is helpful for DX reasons, you can surely leave it as it is.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good question! It was a trick to avoid conflicts for typing of strings. I included it based on this comment in webapp from @kevinb-khan: https://github.com/Khan/webapp/blob/55c4465017a829d53bdc6d00d94d6d93e3b5dfe4/services/static/javascript/shared-styles-package/media-queries.ts#L26

We attach a unique comment string to each of the media queries in this file. That way, if another media query has the same constraints as one of these queries, their strings won't be identical, and they therefore won't conflict.

Admittedly, the typing for this was really hard to get right and I still wasn't that happy with it in the end. It would be one of the first things I'd want to refactor for the Aphrodite successor.

Copy link
Member
@beaesguerra beaesguerra left a comment

Choose a reason for hiding this comment

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

Looks great Marcy! :)

__docs__/wonder-blocks-tokens/tokens-media-queries.mdx Outdated Show resolved Hide resolved
Co-authored-by: Bea Esguerra <beaesguerra@users.noreply.github.com>
@marcysutton marcysutton merged commit 6999fd3 into main Nov 4, 2024
14 checks passed
@marcysutton marcysutton deleted the media-query-tokens branch November 4, 2024 21:47
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