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

Make sure all the CSS variables used exist (& upgrade the design tokens) #68

Merged
merged 5 commits into from
Sep 8, 2023

Conversation

sandhose
Copy link
Member

@sandhose sandhose commented Sep 4, 2023

After #67, I saw a bunch of places which were using undefined CSS variables. This adds a stylelint plugin to make sure only defined variables are being used.

While looking at this, I saw a bunch of issues that I fixed along the way:

  • the Typography CSS module was using attr-based matches on the class attribute, which did not work with the CSS modules classname hashing
  • the IconButton had the wrong height in Safari, so I fixed it
  • stylelint was actually not being run because of some shell quoting issue
  • the latest versions of the design tokens broke some stuff (because of icons being renamed) so I upgraded them

@sandhose sandhose requested a review from a team as a code owner September 4, 2023 10:41
@sandhose sandhose requested review from SimonBrandner and robintown and removed request for a team September 4, 2023 10:41
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Sep 4, 2023

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3972eb7
Status:⚡️  Build in progress...

View logs

"importFrom": [
"./src/styles/global.css",
"./node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-common.css",
"./node_modules/@vector-im/compound-design-tokens/assets/web/css/cpd-light-mq.css"
Copy link
Member Author

Choose a reason for hiding this comment

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

I chose one of the themes to define the variables

@@ -17,7 +17,7 @@ limitations under the License.
.button {
border-radius: var(--cpd-radius-pill-effect);
cursor: pointer;
-webkit-appeareance: none;
Copy link
Member Author

Choose a reason for hiding this comment

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

That was a typo not being caught by stylelint because of the shell expansion issue

import VisibilityVisible from "@vector-im/compound-design-tokens/icons/visibility-visible.svg";
import VisibilityInvisible from "@vector-im/compound-design-tokens/icons/visibility-invisible.svg";
import VisibilityOn from "@vector-im/compound-design-tokens/icons/visibility-on.svg";
import VisibilityOff from "@vector-im/compound-design-tokens/icons/visibility-off.svg";
Copy link
Member Author

Choose a reason for hiding this comment

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

Those icons were renamed in the design tokens

@@ -18,158 +18,135 @@ limitations under the License.
* Font – Body – Extra Small
*/

[class^="font-body-xs"] {
Copy link
Member Author

Choose a reason for hiding this comment

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

Looking at the CSS output file makes it obvious that this trick does not work with CSS modules


/* Default icon and avatar size */
--cpd-icon-button-size: var(--cpd-space-8x);
--cpd-avatar-size: var(--cpd-space-16x);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is mainly to avoid the "variable is not defined" error for those, even though they are always set within the component

Copy link
Member

@robintown robintown left a comment

Choose a reason for hiding this comment

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

One quick question

@robintown robintown removed the request for review from SimonBrandner September 7, 2023 03:18
@sandhose sandhose force-pushed the quenting/cleanup-variables branch from e0b40c5 to 3972eb7 Compare September 8, 2023 07:08
@sandhose
Copy link
Member Author

sandhose commented Sep 8, 2023

When I merged back main, turns out the recent changes on the Button component (#72) were not passing stylelint, so I changed the new class to be kebab-case instead of snakeCase

@sandhose sandhose merged commit 3fa6216 into main Sep 8, 2023
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.

2 participants