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

[BD-46] feat: added CSS custom media query transformer #2068

Conversation

PKulkoRaccoonGang
Copy link
Contributor

@PKulkoRaccoonGang PKulkoRaccoonGang commented Feb 21, 2023

Description

  • Ensure we can generate @custom-media from design tokens with style-dictionary.
  • Ensure we add support for postcss-custom-media to @edx/frontend-build's default Webpack configs for all MFEs.

Issue: #2015

Relative link: Frontend build

Merge Checklist

  • If your update includes visual changes, have they been reviewed by a designer? Send them a link to the Netlify deploy preview, if applicable.
  • Does your change adhere to the documented style conventions?
  • Do any prop types have missing descriptions in the Props API tables in the documentation site (check deploy preview)?
  • Were your changes tested using all available themes (see theme switcher in the header of the deploy preview, under the "Settings" icon)?
  • Were your changes tested in the example app?
  • Is there adequate test coverage for your changes?
  • Consider whether this change needs to reviewed/QA'ed for accessibility (a11y). If so, please add wittjeff and adamstankiewicz as reviewers on this PR.

Post-merge Checklist

  • Verify your changes were released to NPM at the expected version.
  • If you'd like, share your contribution in #show-and-tell.
  • 🎉 🙌 Celebrate! Thanks for your contribution.

@openedx-webhooks openedx-webhooks added the blended PR is managed through 2U's blended developmnt program label Feb 21, 2023
@openedx-webhooks
Copy link

Thanks for the pull request, @PKulkoRaccoonGang!

When this pull request is ready, tag your edX technical lead.

@PKulkoRaccoonGang PKulkoRaccoonGang changed the title [BD-46] DRAFT: added CSS custom media query transformer [BD-46] feat: added CSS custom media query transformer Feb 21, 2023
@codecov
Copy link

codecov bot commented Feb 21, 2023

Codecov Report

Base: 90.77% // Head: 90.77% // No change to project coverage 👍

Coverage data is based on head (f86cf86) compared to base (4bbb0df).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##            alpha    #2068   +/-   ##
=======================================
  Coverage   90.77%   90.77%           
=======================================
  Files         213      213           
  Lines        3501     3501           
  Branches      843      843           
=======================================
  Hits         3178     3178           
  Misses        315      315           
  Partials        8        8           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

It's great seeing how straightforward it is to implement stuff using tokens! Left a comment with a question on here but overall this is just really exciting stuff!

@@ -1,4 +1,5 @@
@import "css/variables";
@import "css/custom-media";
Copy link
Contributor

Choose a reason for hiding this comment

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

is the plan to add more than just breakpoints to this file? it seems we have a couple options going forward:

  • add all media query related stuff to custom-media (media queries cover a range of things, not sure if following that is how we want to group our files or not)
  • add all breakpoints (max-width queries) to custom-breakpoints (or a similarly named file with the same limited scope), add other media queries (orientation etc.) to other .css files

Copy link
Contributor Author

@PKulkoRaccoonGang PKulkoRaccoonGang Feb 22, 2023

Choose a reason for hiding this comment

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

These are good ideas! I think we have opportunities for flexible usage thanks to Post CSS and plugins "custom-media".

Copy link
Member

@adamstankiewicz adamstankiewicz Feb 24, 2023

Choose a reason for hiding this comment

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

I'd lean a bit more towards creating separate formats for the different types of media queries, starting with the custom-breakpoints in this PR (though, maybe custom-media-breakpoints?).

In the future, we could expanding the set of custom media queries around things like device width, etc. (i.e., media queries that depend on CSS variable(s) generated from a design token).

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, I think custom-media-breakpoints is a more obvious naming variant 👍

@PKulkoRaccoonGang PKulkoRaccoonGang force-pushed the Peter_Kulko/css-custom-media-query-transformer branch 2 times, most recently from fadbe74 to b0eb33e Compare February 23, 2023 21:32
@@ -280,9 +280,9 @@ jobs:
uses: hmarr/auto-approve-action@v2
with:
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
github-token: ${{ secrets.requirements_bot_github_token }}
github-token: ${{ secrets.EDX_NETLIFY_PAT }}
Copy link
Member

Choose a reason for hiding this comment

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

[curious] Are these changes remnants of dealing with issues in the Git history? Let's keep this using secrets.requirements_bot_github_token moving forward as that's what's on master. The EDX_NETLIFY_PAT secret is my hack before I knew requirements_bot_github_token existed :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Roll-backed this commit in this pull request

@@ -2,7 +2,8 @@

name: Lint Commit Messages

on: pull_request
on:
Copy link
Member

Choose a reason for hiding this comment

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

Similar comment as above for this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Roll-backed this commit in this pull request

@@ -154,4 +154,24 @@ StyleDictionary.registerFormat({
},
});

/**
* Formatter to generate CSS custom media queries.
Copy link
Member

Choose a reason for hiding this comment

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

nit: maybe add "custom media queries for responsive breakpoints"?

Copy link
Contributor Author

@PKulkoRaccoonGang PKulkoRaccoonGang Feb 24, 2023

Choose a reason for hiding this comment

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

Exactly, thanks

@@ -1,4 +1,5 @@
@import "css/variables";
@import "css/custom-media";
Copy link
Member

@adamstankiewicz adamstankiewicz Feb 24, 2023

Choose a reason for hiding this comment

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

I'd lean a bit more towards creating separate formats for the different types of media queries, starting with the custom-breakpoints in this PR (though, maybe custom-media-breakpoints?).

In the future, we could expanding the set of custom media queries around things like device width, etc. (i.e., media queries that depend on CSS variable(s) generated from a design token).

* 'breakpoints' subcategory, and generates a CSS custom media queries.
*/
StyleDictionary.registerFormat({
name: 'css/custom-media',
Copy link
Member

Choose a reason for hiding this comment

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

As suggested in the previous comment, let's plan on having distinct transforms for different types of media queries. In this case, we're working with responsive breakpoints, so per the suggestion above, perhaps css/custom-media-breakpoints here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks

StyleDictionary.registerFormat({
name: 'css/custom-media',
formatter({ dictionary, file }) {
const { size: { breakpoint } } = dictionary.properties;
Copy link
Member

Choose a reason for hiding this comment

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

This is neat to see that this wasn't that large of a lift given what we already had! 🚀

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, it's very simple thanks to the Style Dictionary setups 💯

@adamstankiewicz adamstankiewicz linked an issue Feb 24, 2023 that may be closed by this pull request
4 tasks
@PKulkoRaccoonGang PKulkoRaccoonGang force-pushed the Peter_Kulko/css-custom-media-query-transformer branch from b0eb33e to af5afdc Compare February 24, 2023 11:19
@adamstankiewicz adamstankiewicz merged commit 577ac74 into openedx:alpha Feb 24, 2023
@openedx-webhooks
Copy link

@PKulkoRaccoonGang 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@adamstankiewicz
Copy link
Member

Also merged/released the associated @edx/frontend-build PR here at v12.6.0: https://github.com/openedx/frontend-build/releases/tag/v12.6.0

@edx-semantic-release
Copy link
Contributor

🎉 This PR is included in version 21.0.0-alpha.14 🎉

The release is available on:

Your semantic-release bot 📦🚀

monteri pushed a commit to raccoongang/paragon that referenced this pull request Aug 17, 2023
* feat: added CSS custom media query transformer

* refactor: refactoring after review

* refactor: refactoring after review
PKulkoRaccoonGang added a commit to raccoongang/paragon that referenced this pull request Aug 18, 2023
* feat: added CSS custom media query transformer

* refactor: refactoring after review

* refactor: refactoring after review
@edx-semantic-release
Copy link
Contributor

🎉 This PR is included in version 22.0.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@openedx-semantic-release-bot

🎉 This PR is included in version 23.0.0-alpha.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

PKulkoRaccoonGang added a commit that referenced this pull request Aug 1, 2024
* feat: added CSS custom media query transformer

* refactor: refactoring after review

* refactor: refactoring after review
PKulkoRaccoonGang added a commit that referenced this pull request Aug 4, 2024
* feat: added CSS custom media query transformer

* refactor: refactoring after review

* refactor: refactoring after review
PKulkoRaccoonGang added a commit that referenced this pull request Aug 4, 2024
* feat: added CSS custom media query transformer

* refactor: refactoring after review

* refactor: refactoring after review
PKulkoRaccoonGang added a commit that referenced this pull request Aug 5, 2024
* feat: added CSS custom media query transformer

* refactor: refactoring after review

* refactor: refactoring after review
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blended PR is managed through 2U's blended developmnt program released on @alpha
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

[discovery] CSS @media query definitions can't be used with CSS variables
7 participants