typewritingclass 0.3.3 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -80
- package/dist/index.cjs +482 -76
- package/dist/index.d.cts +160 -730
- package/dist/index.d.ts +160 -730
- package/dist/index.js +549 -143
- package/dist/rule.d.cts +1 -1
- package/dist/rule.d.ts +1 -1
- package/dist/runtime.d.cts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/{types-C2b7lqJA.d.cts → types-uXRYakpo.d.cts} +180 -1
- package/dist/{types-C2b7lqJA.d.ts → types-uXRYakpo.d.ts} +180 -1
- package/package.json +16 -1
package/README.md
CHANGED
|
@@ -1,106 +1,70 @@
|
|
|
1
1
|
# Typewriting Class
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CSS-in-TypeScript with full autocomplete. Design tokens as properties, not strings.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
pnpm add typewritingclass
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
### Chainable API (recommended)
|
|
11
|
+
## Use
|
|
14
12
|
|
|
15
13
|
```ts
|
|
14
|
+
import 'typewritingclass/inject'
|
|
16
15
|
import { tw } from 'typewritingclass'
|
|
17
16
|
|
|
18
|
-
const card = tw
|
|
19
|
-
.bg('white').rounded('lg').p(6).flex.gap(4)
|
|
20
|
-
.hover(tw.bg('blue-50'))
|
|
21
|
-
.md.p(8)
|
|
22
|
-
.dark(tw.bg('slate-800'))
|
|
17
|
+
const card = tw.bg.white.rounded.lg.p(6).shadow.md
|
|
23
18
|
```
|
|
24
19
|
|
|
25
|
-
|
|
20
|
+
## Property-access tokens
|
|
26
21
|
|
|
27
22
|
```ts
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
23
|
+
tw.bg.blue500 // background-color: #3b82f6
|
|
24
|
+
tw.textColor.slate900 // color: #0f172a
|
|
25
|
+
tw.rounded.lg // border-radius: 0.5rem
|
|
26
|
+
tw.shadow.md // box-shadow: ...
|
|
27
|
+
tw.text.lg // font-size + line-height
|
|
28
|
+
tw.font.bold // font-weight: 700
|
|
29
|
+
tw.items.center // align-items: center
|
|
30
|
+
tw.cursor.pointer // cursor: pointer
|
|
31
|
+
|
|
32
|
+
tw.bg.blue500(50) // 50% opacity
|
|
39
33
|
```
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### Chainable builder
|
|
44
|
-
|
|
45
|
-
- **`tw`** — proxy-based chainable API with access to all utilities and modifiers via a single import
|
|
46
|
-
- Property syntax for modifiers: `tw.hover.bg('blue-500')`
|
|
47
|
-
- Function syntax for multi-utility modifiers: `tw.hover(tw.bg('blue-500').textColor('white'))`
|
|
48
|
-
- Value-less utilities as properties: `tw.flex.flexCol.relative`
|
|
49
|
-
- Resolves to class string via `.toString()`, `.value`, `.className`, or template literals
|
|
35
|
+
Any CSS value works as a string argument: `tw.bg('#ff6347')`.
|
|
50
36
|
|
|
51
|
-
|
|
37
|
+
## Modifiers
|
|
52
38
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|---|---|
|
|
60
|
-
| Spacing | `p`, `px`, `py`, `pt`, `pr`, `pb`, `pl`, `m`, `mx`, `my`, `mt`, `mr`, `mb`, `ml`, `gap`, `gapX`, `gapY` |
|
|
61
|
-
| Colors | `bg`, `textColor`, `borderColor` |
|
|
62
|
-
| Typography | `text`, `font`, `tracking`, `leading`, `textAlign` |
|
|
63
|
-
| Layout | `flex`, `flexCol`, `flexRow`, `grid`, `gridCols`, `gridRows`, `display`, `items`, `justify`, `self` |
|
|
64
|
-
| Sizing | `w`, `h`, `size`, `minW`, `minH`, `maxW`, `maxH` |
|
|
65
|
-
| Position | `relative`, `absolute`, `fixed`, `sticky`, `top`, `right`, `bottom`, `left`, `inset`, `z` |
|
|
66
|
-
| Borders | `rounded`, `roundedT`, `roundedB`, `roundedL`, `roundedR`, `border`, `borderT`, `borderR`, `borderB`, `borderL`, `ring` |
|
|
67
|
-
| Effects | `shadow`, `opacity`, `backdrop` |
|
|
68
|
-
| Interactivity | `cursor`, `select`, `pointerEvents` |
|
|
69
|
-
| Overflow | `overflow`, `overflowX`, `overflowY` |
|
|
70
|
-
|
|
71
|
-
### Modifiers
|
|
72
|
-
|
|
73
|
-
| Type | Modifiers |
|
|
74
|
-
|---|---|
|
|
75
|
-
| Pseudo-classes | `hover`, `focus`, `active`, `disabled`, `focusVisible`, `focusWithin`, `firstChild`, `lastChild` |
|
|
76
|
-
| Responsive | `sm` (640px), `md` (768px), `lg` (1024px), `xl` (1280px), `_2xl` (1536px) |
|
|
77
|
-
| Color scheme | `dark` |
|
|
39
|
+
```ts
|
|
40
|
+
tw.hover.bg.blue500
|
|
41
|
+
tw.dark.bg.slate900
|
|
42
|
+
tw.md.p(8)
|
|
43
|
+
tw.hover(tw.bg.blue500.textColor.white)
|
|
44
|
+
```
|
|
78
45
|
|
|
79
|
-
|
|
46
|
+
## Standalone utilities
|
|
80
47
|
|
|
81
48
|
```ts
|
|
82
|
-
import {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
49
|
+
import { cx, bg, rounded, p } from 'typewritingclass'
|
|
50
|
+
|
|
51
|
+
cx(bg.blue500, rounded.lg, p(4))
|
|
52
|
+
cx(bg.blue500(25), rounded.lg, p(4))
|
|
86
53
|
```
|
|
87
54
|
|
|
88
|
-
|
|
55
|
+
## Immutable chains
|
|
89
56
|
|
|
90
57
|
```ts
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
colors: { brand: { 500: '#6366f1' } },
|
|
95
|
-
})
|
|
58
|
+
const base = tw.flex.flexCol
|
|
59
|
+
const a = base.gap(4) // base unchanged
|
|
60
|
+
const b = base.gap(8)
|
|
96
61
|
```
|
|
97
62
|
|
|
98
|
-
|
|
63
|
+
## Dynamic values
|
|
99
64
|
|
|
100
65
|
```ts
|
|
101
66
|
import { dcx, bg, p, dynamic } from 'typewritingclass'
|
|
102
67
|
|
|
103
|
-
// Wrap a runtime value with dynamic(), then compose via dcx()
|
|
104
68
|
const { className, style } = dcx(p(4), bg(dynamic(userColor)))
|
|
105
69
|
```
|
|
106
70
|
|
|
@@ -108,16 +72,12 @@ const { className, style } = dcx(p(4), bg(dynamic(userColor)))
|
|
|
108
72
|
|
|
109
73
|
| Path | Contents |
|
|
110
74
|
|---|---|
|
|
111
|
-
| `typewritingclass` | Core API (`cx`, `when`, all utilities and modifiers) |
|
|
112
|
-
| `typewritingclass/
|
|
75
|
+
| `typewritingclass` | Core API (`tw`, `cx`, `when`, all utilities and modifiers) |
|
|
76
|
+
| `typewritingclass/inject` | Runtime style injection (import once in your entry file) |
|
|
77
|
+
| `typewritingclass/preflight.css` | Optional CSS reset |
|
|
113
78
|
| `typewritingclass/theme/colors` | Color scales |
|
|
114
79
|
| `typewritingclass/theme/typography` | Font sizes, weights, line heights |
|
|
115
80
|
| `typewritingclass/theme/shadows` | Shadow presets |
|
|
116
81
|
| `typewritingclass/theme/borders` | Border radius tokens |
|
|
117
|
-
| `typewritingclass/theme/
|
|
118
|
-
| `typewritingclass/
|
|
119
|
-
| `typewritingclass/theme/filters` | Filter presets |
|
|
120
|
-
| `typewritingclass/theme/createTheme` | `createTheme()` |
|
|
121
|
-
| `typewritingclass/inject` | Runtime style injection (auto-initializing side-effect import) |
|
|
122
|
-
| `typewritingclass/runtime` | `__twcDynamic()` (internal compiler helper) |
|
|
123
|
-
| `typewritingclass/rule` | `createRule()`, `createDynamicRule()`, `wrapWithSelector()`, `wrapWithMediaQuery()` |
|
|
82
|
+
| `typewritingclass/theme/createTheme` | `createTheme()` for custom themes |
|
|
83
|
+
| `typewritingclass/rule` | `createRule()`, `wrapWithSelector()`, etc. for custom utilities |
|