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

Add postcss and postcss-preset-env #459

Merged
merged 8 commits into from Aug 23, 2022

Conversation

tiagoalvesdulce
Copy link
Member

Right now we have to copy-paste the entire media definition through all CSS code, for example: @media screen and (max-width: 560px))... For some time I researched a solution to let us have "global" breakpoint variables and share it with apps that consume pi-ui so they could also make use of pi-ui defined breakpoints. The best solution I could find is to use custom media queries. In order to use it, we need a PostCSS plugin. I decided to use postcss-preset-env so we can make use of other cool "css next" stuff like nesting rules. All features can be turned on/off using the stage and features options from postcss-preset-env. Now, we can write the media query above like: @media (--xs-viewport).

I also added a PostCSS addon to storybook so it transforms the CSS correctly to our docs.

With these new additions we can improve a lot the way we write our CSS. This PR doesn't meant to do this but in the future a lot of things can be done.

This PR should be completely backwards compatible. That means pi-ui consumers like politeiagui and decrediton don't have to do anything. Although, now pi-ui includes an exports.css file in the compiled bundle. The consumers can add postcss-preset-env or postcss-custom-media and importFrom this file to make use of the breakpoints defined by pi-ui. I will open a politeiagui PR to do just that soon.

Copy link
Member

@victorgcramos victorgcramos left a comment

Choose a reason for hiding this comment

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

Looking good and works on politeiagui as expected.

@victorgcramos victorgcramos merged commit f52f208 into decred:master Aug 23, 2022
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.

None yet

2 participants