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 CHANGED
@@ -1,106 +1,70 @@
1
1
  # Typewriting Class
2
2
 
3
- Core library for the Typewriting Class CSS-in-TS framework. Provides utility functions, modifiers, theme tokens, and the composition API.
3
+ CSS-in-TypeScript with full autocomplete. Design tokens as properties, not strings.
4
4
 
5
- ## Installation
5
+ ## Install
6
6
 
7
7
  ```bash
8
- bun add typewritingclass
8
+ pnpm add typewritingclass
9
9
  ```
10
10
 
11
- ## Usage
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
- ### Individual imports
20
+ ## Property-access tokens
26
21
 
27
22
  ```ts
28
- import { cx, p, bg, textColor, rounded, flex, gap, when } from 'typewritingclass'
29
- import { hover, md, dark } from 'typewritingclass'
30
- import { blue, white, slate } from 'typewritingclass/theme/colors'
31
-
32
- const card = cx(
33
- p(6), bg(white), rounded('lg'),
34
- flex(), gap(4),
35
- when(hover)(bg(blue[50])),
36
- when(md)(p(8)),
37
- when(dark)(bg(slate[800])),
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
- ## API
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
- ### Composition
37
+ ## Modifiers
52
38
 
53
- - **`cx(...rules)`** — compose utilities into a single class name
54
- - **`when(...modifiers)(...rules)`** — apply styles conditionally
55
-
56
- ### Utilities
57
-
58
- | Category | Functions |
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
- ### Theme tokens
46
+ ## Standalone utilities
80
47
 
81
48
  ```ts
82
- import { blue, slate } from 'typewritingclass/theme/colors'
83
- import { bold, lg } from 'typewritingclass/theme/typography'
84
- import { md } from 'typewritingclass/theme/shadows'
85
- import { lg as lgRadius } from 'typewritingclass/theme/borders'
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
- ### Custom themes
55
+ ## Immutable chains
89
56
 
90
57
  ```ts
91
- import { createTheme } from 'typewritingclass/theme/createTheme'
92
-
93
- const theme = createTheme({
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
- ### Dynamic values
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/theme` | All theme token exports |
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/sizes` | Named sizes |
118
- | `typewritingclass/theme/animations` | Animation keyframe presets |
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 |