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

[Bug] grid-template identifiers do not get transformed (with CSS modules) when var() is used #762

Open
mkrause opened this issue Jun 22, 2024 · 3 comments

Comments

@mkrause
Copy link

mkrause commented Jun 22, 2024

See Playground:

.test {
  grid-template: "test" var(--foo);
  grid-template: "test" 1fr;
}

Results in:

.EgL3uq_test {
  grid-template: "test" var(--foo);
  grid-template: "EgL3uq_test" 1fr;
}

Note how this works as expected when 1fr is specified as size, but when var(--foo) is specified the template area name is left as a global identifier "test". This makes it impossible to use grid-template with var(), because the grid-area identifier will still be transformed, preventing the area from being assigned.

@danhorvath
Copy link

danhorvath commented Jul 3, 2024

I experienced the same thing (also with css modules), currently I'm relying on css variables as a workaround.

Source:

.filterRow {
  --filter-row--filter-grid-area: filter;
  --filter-row--operator-grid-area: operator;
  --filter-row--condition-grid-area: condition;

  grid-template-columns: [var(--filter-row--filter-grid-area)] 1fr [var(--filter-row--operator-grid-area)] var(--sizing-300) [var(--filter-row--condition-grid-area)] 1fr;
}

.filter {
  grid-column: var(--filter-row--filter-grid-area);
}

Output:

.EgL3uq_filterRow {
  --filter-row--filter-grid-area: filter;
  --filter-row--operator-grid-area: operator;
  --filter-row--condition-grid-area: condition;
  grid-template-columns: [var(--filter-row--filter-grid-area) ] 1fr [var(--filter-row--operator-grid-area) ] var(--sizing-300) [var(--filter-row--condition-grid-area) ] 1fr;
}

.EgL3uq_filter {
  grid-column: var(--filter-row--filter-grid-area);
}

This works across files too, albeit stylelint and vscode report issues with the syntax.

@mkrause
Copy link
Author

mkrause commented Jul 5, 2024

@danhorvath Another workaround is to disable identifier transformations for grid altogether using:

cssModules: {
  grid: false
},

@danhorvath
Copy link

thanks for the tip @mkrause! 🙏

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

No branches or pull requests

2 participants