Skip to content

Commit 31e56cf

Browse files
committed
Update color variable structure to use 'color' namespace in CSS and JS files
1 parent e2a1874 commit 31e56cf

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

packages/cli/tests/extract/watch/test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ const config: Config = {
4040
btn: 'bg:red'
4141
},
4242
variables: {
43-
primary: '$(blue)'
43+
color: {
44+
primary: '$(color-blue)'
45+
}
4446
}
4547
}
4648
@@ -92,7 +94,7 @@ if (!process.env.CI) {
9294
waitForDataMatch(subprocess, (data) => data.includes('exported'))
9395
])
9496
const fileCSSText = fs.readFileSync(virtualCSSFilepath, { encoding: 'utf8' })
95-
expect(fileCSSText).toContain('.btn{background-color:rgb(var(--blue))')
97+
expect(fileCSSText).toContain('.btn{background-color:var(--color-blue)')
9698
}, 120000)
9799

98100
it('change html file class attr and update', async () => {

site/app/[locale]/guide/cascade-layers/tests/overview/generated.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/app/[locale]/guide/cascade-layers/tests/overview/master.css.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
export default {
22
modes: {
33
light: {
4-
primary: '#000000',
4+
color: {
5+
primary: '#000000',
6+
}
57
},
68
dark: {
7-
primary: '#ffffff',
9+
color: {
10+
primary: '#ffffff',
11+
}
812
}
913
},
1014
components: {

site/app/[locale]/guide/minimization/content.mdx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ This will generate only the relevant CSS based on the usage:
4545
## Bloated CSS variables
4646
(!) Defining CSS variables the traditional way.
4747
```css name=main.css
48-
--primary: #000;
49-
--secondary: #fff;
50-
--tertiary: #f00;
48+
--color-primary: #000;
49+
--color-secondary: #fff;
50+
--color-tertiary: #f00;
5151
... /* Hundreds of CSS variables here... */
5252
```
5353
Although this works, unused variables still end up in the final stylesheet, increasing the CSS payload unnecessarily.
@@ -58,13 +58,15 @@ Master CSS [variables](/guide/variables) are generated by analyzing class declar
5858
```js name=master.css.js
5959
export default {
6060
variables: {
61-
primary: '#000', /* [!code ++] */
62-
secondary: '#fff', /* [!code ++] */
63-
tertiary: '#f00' /* [!code ++] */
61+
color: {
62+
primary: '#000', /* [!code ++] */
63+
secondary: '#fff', /* [!code ++] */
64+
tertiary: '#f00' /* [!code ++] */
65+
}
6466
}
6567
}
6668
```
67-
To use a variable like `primary`, simply reference it in a class. Master CSS will automatically generate the corresponding `--primary` declaration:
69+
To use a variable like `primary`, simply reference it in a class. Master CSS will automatically generate the corresponding `--color-primary` declaration:
6870
```html
6971
<!-- @MARK primary -->
7072
<div class="bg:primary"></div><!-- [!code focus] -->

0 commit comments

Comments
 (0)