Skip to content

Commit 041c415

Browse files
committed
chore: update test, update readme
1 parent ff0dfe1 commit 041c415

File tree

3 files changed

+91
-12
lines changed

3 files changed

+91
-12
lines changed

README.md

+77-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# tailwindcss-material-tokens
2-
Import the tokens of web components in material 3 into tailwindcss and use them through plugins.
2+
3+
_If you wish, you are welcome to submit a document update request_
4+
5+
---
6+
7+
Import the Material Design tokens into tailwindcss and use them through plugins.
38

49
+ ESM Supported Only
510
+ Typescript Supported
@@ -22,6 +27,9 @@ export default {
2227
],
2328
}
2429
```
30+
31+
---
32+
2533
_If you don’t want to be troubled by the original styles of tailwindcss, please try to turn off the styles that come with tailwindcss (color, rounded, shadow, text)._
2634

2735
![Screenshot1](https://github.com/glare-labs/tailwindcss-material-tokens/blob/main/imgs/Part-1.png?raw=true)
@@ -38,34 +46,45 @@ For example:
3846

3947
### provideColor & provide*
4048
```typescript
41-
import { provideColor, provideElevation, provideMotion, provideShape, provideTypography } from '@glare-labs/tailwindcss-material-tokens'
49+
import { provideBorder, provideColor, provideElevation, provideMotion, provideShape, provideSizing, provideTypography, provideWindowMediaQuery } from '@glare-labs/tailwindcss-material-tokens'
50+
4251

52+
const border = provideBorder()
4353
const color = provideColor()
4454
const elevation = provideElevation()
4555
const motion = provideMotion()
4656
const shape = provideShape()
57+
const sizing = provideSizing()
4758
const typography = provideTypography()
59+
const width = provideSizing()
60+
const mq = provideWindowMediaQuery()
4861

4962
/** @type {import('tailwindcss').Config} */
5063
export default {
5164
// ...
5265

5366
plugins: [
54-
color.plugin(),
55-
elevation.plugin(),
56-
motion.plugin(),
57-
shape.plugin(),
58-
typography.plugin(),
67+
border.getPlugin(),
68+
color.getPlugin(),
69+
elevation.getPlugin(),
70+
motion.getPlugin(),
71+
shape.getPlugin(),
72+
sizing.getPlugin(),
73+
typography.getPlugin(),
74+
width.getPlugin(),
75+
mq.getPlugin(),
5976
],
6077
}
6178
```
6279

6380
### provideAll
6481
provideAll includes:
82+
- border
6583
- color
6684
- elevation
6785
- motion
6886
- shape
87+
- sizing
6988
- typography
7089

7190
```typescript
@@ -78,12 +97,61 @@ export default {
7897
// ...
7998

8099
plugins: [
81-
...all.allPlugins()
100+
...all.getAllPlugins()
82101
],
83102
}
84103
```
85104

86-
## Default Value
105+
## APIs
106+
107+
Most plugins support `prefix`, `hardcodeDefaultValue`, `excludeTokens` and `customTokens` options.
108+
109+
### prefix
110+
prefix represents a public CSS variable:
111+
112+
```typescript
113+
const color = provideColor({
114+
prefix: 'my-product-prefix'
115+
})
116+
```
117+
118+
the result:
119+
```css
120+
.bg-primary {
121+
background-color: var(--my-product-prefix-primary, #005ac1);
122+
}
123+
```
124+
125+
### hardcodeDefaultValue
126+
If hardcodeDefaultValue is true, the CSS contains a default value.
127+
128+
```typescript
129+
const color = provideColor({
130+
prefix: 'my-product-prefix',
131+
hardcodeDefaultValue: false,
132+
})
133+
```
134+
135+
the result:
136+
```css
137+
.bg-primary {
138+
background-color: var(--my-product-prefix-primary,);
139+
}
140+
```
141+
142+
### excludeTokens
143+
excludeTokens is a token blacklist, including unnecessary token groups.
144+
145+
```typescript
146+
const color = provideColor({
147+
excludeTokens: [
148+
// remove .bg-primary and .text-primary
149+
'primary'
150+
]
151+
})
152+
```
153+
154+
## Default Color Values
87155

88156
_Contains only color._
89157
```javascript

test/index.html

+9
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,15 @@ <h1>Window Media Query</h1>
264264
<span class="large:bg-primary large:text-on-primary">Large [max-width: 1600px]</span>
265265
<span class="extra-large:bg-primary extra-large:text-on-primary">ExtraLarge [min-width: 1600px]</span>
266266
</div>
267+
268+
<h1>Sizing</h1>
269+
<div
270+
class="[&>span]:h-10 [&>span]:border [&>span]:border-outline-variant grid grid-cols-1 gap-2 [&>span]:grid [&>span]:items-center [&>span]:justify-start [&>span]:pl-8">
271+
<span class="w-compact">w-compact</span>
272+
<span class="w-medium">w-medium</span>
273+
<span class="w-expanded">w-expanded</span>
274+
<span class="w-large">w-large</span>
275+
</div>
267276
</div>
268277

269278

test/tailwind.config.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { provideBorder, provideColor, provideElevation, provideMotion, provideShape, provideTypography, provideWindowMediaQuery } from '../src/index'
1+
import { provideBorder, provideColor, provideElevation, provideMotion, provideShape, provideSizing, provideTypography, provideWindowMediaQuery } from '../src/index'
22

3-
const color = provideColor({})
3+
const color = provideColor()
44
const elevation = provideElevation({})
55
const motion = provideMotion()
66
const shape = provideShape()
77
const typo = provideTypography()
88
const border = provideBorder({})
99
const mq = provideWindowMediaQuery()
10+
const width = provideSizing()
1011

1112
/** @type {import('tailwindcss').Config} */
1213
export default {
@@ -20,7 +21,8 @@ export default {
2021
shape.getPlugin(),
2122
typo.getPlugin(),
2223
border.getPlugin(),
23-
mq.getPlugin()
24+
mq.getPlugin(),
25+
width.getPlugin(),
2426
],
2527
}
2628

0 commit comments

Comments
 (0)