typewritingclass 0.3.2 → 0.3.4
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 +48 -5
- package/dist/index.cjs +471 -76
- package/dist/index.d.cts +156 -729
- package/dist/index.d.ts +156 -729
- package/dist/index.js +538 -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-B-eG4WLT.d.cts} +170 -1
- package/dist/{types-C2b7lqJA.d.ts → types-B-eG4WLT.d.ts} +170 -1
- package/package.json +5 -3
- package/preflight.css +203 -0
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Core library for the Typewriting Class CSS-in-TS framework. Provides utility fun
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
8
|
+
pnpm add typewritingclass
|
|
9
9
|
```
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
@@ -16,13 +16,54 @@ bun add typewritingclass
|
|
|
16
16
|
import { tw } from 'typewritingclass'
|
|
17
17
|
|
|
18
18
|
const card = tw
|
|
19
|
-
.bg
|
|
19
|
+
.bg.white.rounded.lg.p(6).flex.gap(4)
|
|
20
20
|
.hover(tw.bg('blue-50'))
|
|
21
21
|
.md.p(8)
|
|
22
22
|
.dark(tw.bg('slate-800'))
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
###
|
|
25
|
+
### Property-access tokens
|
|
26
|
+
|
|
27
|
+
Design tokens are accessed via property names — no strings needed:
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
tw.bg.blue500 // background-color: #3b82f6
|
|
31
|
+
tw.textColor.slate900 // color: #0f172a
|
|
32
|
+
tw.rounded.lg // border-radius: 0.5rem
|
|
33
|
+
tw.shadow.md // box-shadow: ...
|
|
34
|
+
tw.text.lg // font-size: 1.125rem; line-height: 1.75rem
|
|
35
|
+
tw.font.bold // font-weight: 700
|
|
36
|
+
tw.items.center // align-items: center
|
|
37
|
+
tw.justify.between // justify-content: space-between
|
|
38
|
+
tw.cursor.pointer // cursor: pointer
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Color tokens support opacity via callable syntax:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
tw.bg.blue500(50) // background-color: rgb(59 130 246 / 0.5)
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Individual imports with property-access tokens
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { cx, bg, rounded, p, when, hover } from 'typewritingclass'
|
|
51
|
+
|
|
52
|
+
cx(bg.blue500, rounded.lg, p(4))
|
|
53
|
+
|
|
54
|
+
// With opacity
|
|
55
|
+
cx(bg.blue500(25), rounded.lg, p(4))
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Arbitrary / custom values
|
|
59
|
+
|
|
60
|
+
Pass any CSS value as a string argument:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
tw.bg('white').rounded('lg').p(6).shadow('md')
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Individual imports (functional style)
|
|
26
67
|
|
|
27
68
|
```ts
|
|
28
69
|
import { cx, p, bg, textColor, rounded, flex, gap, when } from 'typewritingclass'
|
|
@@ -43,9 +84,11 @@ const card = cx(
|
|
|
43
84
|
### Chainable builder
|
|
44
85
|
|
|
45
86
|
- **`tw`** — proxy-based chainable API with access to all utilities and modifiers via a single import
|
|
46
|
-
- Property
|
|
47
|
-
-
|
|
87
|
+
- Property-access tokens: `tw.bg.blue500`, `tw.rounded.lg`, `tw.font.bold`
|
|
88
|
+
- Property syntax for modifiers: `tw.hover.bg.blue500`
|
|
89
|
+
- Function syntax for multi-utility modifiers: `tw.hover(tw.bg.blue500.textColor.white)`
|
|
48
90
|
- Value-less utilities as properties: `tw.flex.flexCol.relative`
|
|
91
|
+
- Arbitrary values: `tw.bg('custom-color').p(6)`
|
|
49
92
|
- Resolves to class string via `.toString()`, `.value`, `.className`, or template literals
|
|
50
93
|
|
|
51
94
|
### Composition
|