Skip to content

Commit 5372bd8

Browse files
committed
Docs: New guide Typography
1 parent 2da2c59 commit 5372bd8

File tree

13 files changed

+335
-293
lines changed

13 files changed

+335
-293
lines changed

internal

packages/core/src/config/rules.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ const rules = {
513513
unit: 'rem',
514514
declarations: {
515515
'font-size': undefined,
516-
'line-height': ['max(1.8em - max(0rem, ', undefined, ' - 1.125rem) * 1.2', ', ', undefined ,')']
516+
'line-height': ['max(1.8em - max(0rem, ', undefined, ' - 1rem) * 1.2', ', ', undefined ,')']
517517
},
518518
type: SyntaxRuleType.Shorthand,
519519
namespaces: ['font-size']

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

Lines changed: 16 additions & 193 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Apply them using the color-realted syntax:
2525
<!-- @MARK bg:primary-5 --><!-- @MARK fg:primary-60 -->
2626
<div class="bg:primary-5 fg:primary-60">…</div>
2727
```
28+
See the [color variables](/guide/variables#use-custom-colors) for more details on how to add custom colors.
2829

2930
### With variable modes
3031
You can also use [variable modes to define colors](#add-colors-based-on-modes) for different themes, such as light and dark modes.
@@ -36,134 +37,7 @@ As your styles grow, arbitrarily applying `@dark` or `@light` in template markup
3637

3738
---
3839

39-
## Customizing colors
40-
### Add a color
41-
Add the primary color using `#000`, `oklch(0% 0 none)`, or `hsl(0 0% 0%)`.
42-
<Code lang="js" name="master.css.js">{require('../../../../../packages/server/tests/fixtures/add-a-color/master.css.js?raw')}</Code>
43-
Apply it using color-related syntax and even change the opacity.
44-
<Code lang="html">{require('../../../../../packages/server/tests/fixtures/add-a-color/template.html?raw')}</Code>
45-
<details>
46-
<summary>Generated CSS</summary>
47-
<div>
48-
<Code lang="css" beautify>{require('../../../../../packages/server/tests/fixtures/add-a-color/generated.css?raw')}</Code>
49-
</div>
50-
</details>
51-
52-
(i) If a color is used only once in all markups, you can optionally not abstract it into a token.
53-
```html
54-
<button class="bg:#ceb195">Milk Tea</button>
55-
```
56-
Variables only support `rgb` and `hsl`, in the future, they will be compatible with all native CSS functions, such as `rgba`, `hsla`, `lab`, and others. [#346](https://github.com/master-co/css/issues/346)
57-
58-
### Add a color with opacity
59-
Add color variables with opacity using `#00000080`, `rgb(0 0 0/.5)`, or `hsl(0 0% 0%/.5)`.
60-
<Code lang="js" name="master.css.js">{require('../../../../../packages/server/tests/fixtures/add-a-color-with-opacity/master.css.js?raw')}</Code>
61-
Apply it using color-related syntax like [`fg:`](/reference/color).
62-
<Code lang="html">{require('../../../../../packages/server/tests/fixtures/add-a-color-with-opacity/template.html?raw')}</Code>
63-
<details>
64-
<summary>Generated CSS</summary>
65-
<div>
66-
<Code lang="css" beautify>{require('../../../../../packages/server/tests/fixtures/add-a-color-with-opacity/generated.css?raw')}</Code>
67-
</div>
68-
</details>
69-
(x) Color variables with opacity cannot use `/alpha` to change the opacity.
70-
```html
71-
<!-- @MARK primary/.5 -->
72-
<div class="fg:primary/.5">…</div>
73-
```
74-
75-
### Add a color alias
76-
Create an alias for a color to link its value to an existing color.
77-
<Code lang="js" name="master.css.js">{require('../../../../../packages/server/tests/fixtures/add-an-alias/master.css.js?raw')}</Code>
78-
Apply it using color-related syntax.
79-
<Code lang="html">{require('../../../../../packages/server/tests/fixtures/add-an-alias/template.html?raw')}</Code>
80-
<details>
81-
<summary>Generated CSS</summary>
82-
<div>
83-
<Code lang="css" beautify>{require('../../../../../packages/server/tests/fixtures/add-an-alias/generated.css?raw')}</Code>
84-
</div>
85-
</details>
86-
For example, say you have multiple color variables referencing the same color token. If that color needs updating, you would only need to update the source instead of manually updating every instance of the color.
87-
88-
### Add a color alias with opacity
89-
Create an alias for a color with opacity to link its value to an existing color.
90-
<Code lang="js" name="master.css.js">{require('../../../../../packages/server/tests/fixtures/add-an-alias-with-opacity/master.css.js?raw')}</Code>
91-
Apply it using color-related syntax like [`fg:`](/reference/color).
92-
<Code lang="html">{require('../../../../../packages/server/tests/fixtures/add-an-alias-with-opacity/template.html?raw')}</Code>
93-
<details>
94-
<summary>Generated CSS</summary>
95-
<div>
96-
<Code lang="css" beautify>{require('../../../../../packages/server/tests/fixtures/add-an-alias-with-opacity/generated.css?raw')}</Code>
97-
</div>
98-
</details>
99-
As shown above, creating an alias `secondary` linked to an existing alias `primary` with opacity `/.5` is possible, and the opacity will be multiplied `0.5 * 0.5 = 0.25`.
100-
101-
### Add color shades
102-
Sets multiple shades for a single color.
103-
```js name=master.css.js
104-
export default {
105-
variables: {
106-
primary: { /* [!code ++] */
107-
'': '#1192e8', /* primary */ /* [!code ++] */
108-
10: '#e5f6ff', /* primary-10 */ /* [!code ++] */
109-
20: '#bae6ff', /* primary-20 */ /* [!code ++] */
110-
} /* [!code ++] */
111-
}
112-
}
113-
```
114-
Apply it using color-related syntax like [`fill:`](/reference/fill).
115-
```html
116-
<!-- @MARK fill:primary-20 -->
117-
<svg class="fill:primary-20 …">20</svg>
118-
```
119-
120-
### Add colors based on modes
121-
Add color variables in different theme modes.
122-
<Code lang="js" name="master.css.js">{require('../../../../../packages/server/tests/fixtures/add-colors-by-theme/master.css.js?raw')}</Code>
123-
Using modes for variables, you can access a single source of truth and simplify the markup.
124-
<Code lang="html">{require('../../../../../packages/server/tests/fixtures/add-colors-by-theme/template.html?raw')}</Code>
125-
<details>
126-
<summary>Generated CSS</summary>
127-
<div>
128-
<Code lang="css" beautify>{require('../../../../../packages/server/tests/fixtures/add-colors-by-theme/generated.css?raw')}</Code>
129-
</div>
130-
</details>
131-
132-
### Override default colors
133-
(!) Access the same key as the preset to override default colors, like `blue-5` ~ `blue-95`.
134-
```js name=master.css.js
135-
export default {
136-
variables: {
137-
blue: '#4589ff' /* [!code ++] */
138-
}
139-
}
140-
```
141-
142-
(o) Use `app-*` to avoid conflicts with defaults and keep `blue-*` colors consistent.
143-
144-
<Code lang="js" name="master.css.js">{require('../../../../../packages/server/tests/fixtures/override-default-colors/master.css.js?raw')}</Code>
145-
Apply custom colors for the current application.
146-
<Code lang="html">{require('../../../../../packages/server/tests/fixtures/override-default-colors/template.html?raw')}</Code>
147-
<details>
148-
<summary>Generated CSS</summary>
149-
<div>
150-
<Code lang="css" beautify>{require('../../../../../packages/server/tests/fixtures/override-default-colors/generated.css?raw')}</Code>
151-
</div>
152-
</details>
153-
154-
---
155-
156-
## Design tokens
157-
In addition to the [default color palette](#default-color-palette), you can also use the Master CSS default tokens and follow the namespace convention to customize your own design.
158-
159-
| Token | Keywords |
160-
|---------------------------------------------------|---------------------------------------------------------------------------|
161-
| <Bg className="bg:white" />`white` | |
162-
| <Bg className="bg:black" />`black` | |
163-
| <Bg className="bg:base" />`base` | background for page, modal |
164-
| <Bg className="bg:invert" />`invert` | inverted color of the background |
165-
166-
### Primitive colors
40+
## Primitive colors
16741
<ExpandContent>
16842
| Normal | Active | Text on Color |
16943
|----------------------------------------------------|--------------------------------------------------|-------------------------------------------------------|
@@ -191,6 +65,13 @@ In addition to the [default color palette](#default-color-palette), you can also
19165
| <Bg className="bg:red" />`red` | <Bg className="bg:red-active" />`red-active` | <Aa className="fg:red-text" />`red-text` |
19266
</ExpandContent>
19367

68+
| Token | Keywords |
69+
|---------------------------------------------------|---------------------------------------------------------------------------|
70+
| <Bg className="bg:white" />`white` | |
71+
| <Bg className="bg:black" />`black` | |
72+
| <Bg className="bg:base" />`base` | background for page, modal |
73+
| <Bg className="bg:invert" />`invert` | inverted color of the background |
74+
19475
By default, theme modes [drive](/guide/configuration#default-mode) base color variables meticulously adjusted in light and dark modes.
19576
<Demo $py={0} $px={0}>
19677
<DemoLight>
@@ -224,7 +105,9 @@ Apply the custom color:
224105
<p class="bg:primary"></p>
225106
```
226107

227-
### Text colors
108+
---
109+
110+
## Text colors
228111
<ExpandContent>
229112
| Token | Descriptions |
230113
|---------------------------------------------------|---------------------------------------------------------------------------|
@@ -259,7 +142,6 @@ Apply the custom color:
259142
</ExpandContent>
260143

261144
By default, theme modes [drive](/guide/configuration#default-mode) text variables are meticulously adjusted in light and dark modes.
262-
263145
<Demo $py={0} $px={0}>
264146
<DemoLight>
265147
<div className="fg:yellow font:heavy font:96">M</div>
@@ -278,47 +160,11 @@ By default, theme modes [drive](/guide/configuration#default-mode) text variable
278160
<span class="fg:yellow">M</span>
279161
</div>
280162
```
163+
See the [color](/reference/color#use-custom-text-colors) reference for more details on how to add custom text colors.
281164

282-
Add a color to the text variables group.
283-
```js name=master.css.js
284-
export default {
285-
variables: {
286-
text: {
287-
primary: '#000' /* [!code ++] */
288-
}
289-
}
290-
}
291-
```
292-
Apply the custom color:
293-
```html
294-
<!-- @MARK primary -->
295-
<p class="fg:primary"></p>
296-
```
297-
Apply the defined `text-*` variables using the inherited rules <TextHeirs />.
298-
```html
299-
<!-- @MARK light -->
300-
<html class="light">
301-
<body class="fg:neutral"></body> <!-- [!code highlight] -->
302-
<body class="fg:text-neutral">equals</body>
303-
<body class="fg:$text-neutral">equals</body>
304-
</html>
305-
```
306-
(x) We set the [foreground color](/reference/color) of elements using `fg:color` rather than the [text-specific](/reference/text-fill-color) `text:color`.
307-
```html
308-
<p class="text:pink">text-fill-color properity</p>
309-
```
310-
Besides inheriting the above rules, you can use `text-*` to access global text color variables in other syntax.
311-
```html
312-
<!-- @MARK text-light -->
313-
<svg class="stroke:text-light"></svg>
314-
```
315-
To escape inherited text colors, use `$blue` to apply `variables.blue` instead of `variables.text.blue`.
316-
```html
317-
<!-- @MARK $blue -->
318-
<p class="fg:$blue">…</p>
319-
```
165+
---
320166

321-
### Frame colors
167+
## Frame colors
322168
| Token | Descriptions |
323169
|---------------------------------------------------------|---------------------------------------------------------------------------|
324170
| <Bg className="outline:neutral" />`frame-neutral` | |
@@ -346,27 +192,4 @@ By default, theme modes [drive](/guide/configuration#default-mode) frame variabl
346192
<div class="b:3x|neutral size:96"></div>
347193
</div>
348194
```
349-
350-
Add a color to the frame variables group.
351-
```js name=master.css.js
352-
export default {
353-
modes: {
354-
light: {
355-
frame: {
356-
light: '$slate-60/.2' /* [!code highlight] */
357-
}
358-
},
359-
dark: {
360-
frame: {
361-
light: '$gray-30/.2' /* [!code highlight] */
362-
}
363-
}
364-
}
365-
}
366-
```
367-
Apply the defined `frame-*` variables using the inherited rules <FrameHeirs />.
368-
```html
369-
<div class="outline:neutral"></div> <!-- [!code highlight] -->
370-
<div class="outline:frame-neutral">equals</div>
371-
<div class="outline:$frame-neutral">equals</div>
372-
```
195+
See the [border color](/reference/border-color#use-custom-border-colors) reference for more details on how to add custom border colors.

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

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)