@zvndev/yable-themes 0.1.0

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 ADDED
@@ -0,0 +1,187 @@
1
+ # @zvndev/yable-themes
2
+
3
+ CSS design token system for the Yable data table engine.
4
+
5
+ `@zvndev/yable-themes` provides structural CSS, 100+ design tokens as CSS custom properties, built-in themes, and automatic dark mode support. Import a single CSS file to style any Yable table.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @zvndev/yable-themes
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```tsx
16
+ // Import the complete stylesheet (tokens + base + all themes)
17
+ import '@zvndev/yable-themes'
18
+
19
+ // Or import individual pieces
20
+ import '@zvndev/yable-themes/tokens.css' // Design tokens only
21
+ import '@zvndev/yable-themes/default.css' // Default theme
22
+ import '@zvndev/yable-themes/stripe.css' // Stripe theme
23
+ import '@zvndev/yable-themes/compact.css' // Compact theme
24
+ ```
25
+
26
+ Then apply a theme via the `theme` prop (React) or `theme` option (vanilla):
27
+
28
+ ```tsx
29
+ // React
30
+ <Table table={table} theme="stripe" />
31
+
32
+ // Vanilla
33
+ renderTable(table, { theme: 'stripe' })
34
+ ```
35
+
36
+ ## Available Themes
37
+
38
+ | Theme | Class | Description |
39
+ |---|---|---|
40
+ | **Default** | `yable-theme-default` | Clean, neutral table with subtle hover and selection states |
41
+ | **Stripe** | `yable-theme-stripe` | Alternating row backgrounds for easy scanning |
42
+ | **Compact** | `yable-theme-compact` | Reduced padding for dense data displays |
43
+
44
+ All themes support **automatic dark mode** via `prefers-color-scheme: dark`. You can also force dark mode by adding `data-yable-theme="dark"` to any parent element, or lock to light mode with `data-yable-theme="light"`.
45
+
46
+ ## Variant Props
47
+
48
+ In addition to themes, the `<Table>` component (and `renderTable` in vanilla) accepts variant modifiers:
49
+
50
+ | Prop | CSS Class | Effect |
51
+ |---|---|---|
52
+ | `stickyHeader` | `yable--sticky-header` | Pin the header row when scrolling |
53
+ | `striped` | `yable--striped` | Alternate row backgrounds |
54
+ | `bordered` | `yable--bordered` | Add cell borders |
55
+ | `compact` | `yable--compact` | Reduce cell padding |
56
+
57
+ These can be combined with any theme.
58
+
59
+ ## Design Tokens (CSS Custom Properties)
60
+
61
+ All visual properties are controlled via CSS custom properties defined on `:root`. Override any token to customize the appearance.
62
+
63
+ ### Surface Colors
64
+
65
+ | Token | Default (Light) | Description |
66
+ |---|---|---|
67
+ | `--yable-bg` | `#ffffff` | Table background |
68
+ | `--yable-bg-header` | `#fafafa` | Header row background |
69
+ | `--yable-bg-footer` | `#fafafa` | Footer background |
70
+ | `--yable-bg-row` | `transparent` | Default row background |
71
+ | `--yable-bg-row-alt` | `rgba(0,0,0,0.015)` | Alternating row background |
72
+ | `--yable-bg-row-hover` | `rgba(0,0,0,0.025)` | Row hover background |
73
+ | `--yable-bg-row-selected` | `rgba(59,130,246,0.06)` | Selected row background |
74
+ | `--yable-bg-cell-editing` | `#ffffff` | Editing cell background |
75
+ | `--yable-bg-pinned` | `#fdfdfd` | Pinned column/row background |
76
+
77
+ ### Text Colors
78
+
79
+ | Token | Default | Description |
80
+ |---|---|---|
81
+ | `--yable-text-primary` | `#111827` | Primary text |
82
+ | `--yable-text-secondary` | `#6b7280` | Secondary/muted text |
83
+ | `--yable-text-tertiary` | `#9ca3af` | Tertiary/disabled text |
84
+ | `--yable-text-header` | `#374151` | Header text |
85
+ | `--yable-text-placeholder` | `#9ca3af` | Input placeholder text |
86
+
87
+ ### Borders
88
+
89
+ | Token | Default | Description |
90
+ |---|---|---|
91
+ | `--yable-border-color` | `#e5e7eb` | Standard border color |
92
+ | `--yable-border-color-strong` | `#d1d5db` | Emphasized border (header bottom) |
93
+ | `--yable-border-width` | `1px` | Border thickness |
94
+ | `--yable-border-radius` | `8px` | Container corner radius |
95
+
96
+ ### Spacing
97
+
98
+ | Token | Default | Description |
99
+ |---|---|---|
100
+ | `--yable-cell-padding-x` | `16px` | Horizontal cell padding |
101
+ | `--yable-cell-padding-y` | `10px` | Vertical cell padding |
102
+ | `--yable-header-padding-x` | `16px` | Horizontal header padding |
103
+ | `--yable-header-padding-y` | `10px` | Vertical header padding |
104
+
105
+ ### Typography
106
+
107
+ | Token | Default | Description |
108
+ |---|---|---|
109
+ | `--yable-font-family` | System font stack | Font family |
110
+ | `--yable-font-size` | `13px` | Base font size |
111
+ | `--yable-font-size-sm` | `12px` | Small font size |
112
+ | `--yable-font-size-header` | `12px` | Header font size |
113
+
114
+ ### Accent / Interactive
115
+
116
+ | Token | Default | Description |
117
+ |---|---|---|
118
+ | `--yable-accent` | `#2563eb` | Primary accent color (sort icons, selected states, pagination active) |
119
+ | `--yable-accent-hover` | `#1d4ed8` | Accent hover state |
120
+ | `--yable-accent-light` | `rgba(37,99,235,0.08)` | Accent background tint |
121
+
122
+ ### Sizing
123
+
124
+ | Token | Default | Description |
125
+ |---|---|---|
126
+ | `--yable-row-min-height` | `40px` | Minimum row height |
127
+ | `--yable-header-min-height` | `40px` | Minimum header height |
128
+ | `--yable-input-height` | `28px` | In-cell form control height |
129
+
130
+ ### Transitions
131
+
132
+ | Token | Default | Description |
133
+ |---|---|---|
134
+ | `--yable-transition-fast` | `100ms ease` | Fast transitions (hover, focus) |
135
+ | `--yable-transition` | `150ms ease` | Standard transitions |
136
+ | `--yable-transition-slow` | `250ms ease` | Slow transitions |
137
+
138
+ ## Custom Theme Example
139
+
140
+ Override tokens on any parent element to create a custom theme:
141
+
142
+ ```css
143
+ .my-custom-theme {
144
+ --yable-accent: #10b981;
145
+ --yable-accent-hover: #059669;
146
+ --yable-accent-light: rgba(16, 185, 129, 0.08);
147
+ --yable-bg-header: #f0fdf4;
148
+ --yable-text-header: #166534;
149
+ --yable-border-radius: 12px;
150
+ --yable-font-size: 14px;
151
+ }
152
+ ```
153
+
154
+ ```tsx
155
+ <div className="my-custom-theme">
156
+ <Table table={table} />
157
+ </div>
158
+ ```
159
+
160
+ ## Dark Mode
161
+
162
+ Dark mode activates automatically via `prefers-color-scheme: dark`. All tokens have dark-mode counterparts defined in `tokens.css`. To override manually:
163
+
164
+ ```html
165
+ <!-- Force dark mode -->
166
+ <div data-yable-theme="dark">
167
+ <Table table={table} />
168
+ </div>
169
+
170
+ <!-- Force light mode (even if system is dark) -->
171
+ <div data-yable-theme="light">
172
+ <Table table={table} />
173
+ </div>
174
+ ```
175
+
176
+ ## CSS Architecture
177
+
178
+ The stylesheet is structured in layers:
179
+
180
+ 1. **`tokens.css`** -- all CSS custom properties (light + dark)
181
+ 2. **`base.css`** -- structural styles (layout, positioning, ARIA, form controls)
182
+ 3. **`themes/*.css`** -- theme-specific overrides
183
+ 4. **`index.css`** -- imports all of the above
184
+
185
+ ## License
186
+
187
+ MIT