@classic-homes/theme-styles 0.5.1 → 0.8.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 +55 -0
- package/package.json +5 -1
- package/src/accessibility.css +89 -23
- package/src/utilities.css +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# @classic-homes/theme-styles
|
|
2
|
+
|
|
3
|
+
Base styles, accessibility helpers, and utility classes for the Classic Theme design system. Requires the design tokens from `@classic-homes/theme-tokens`.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @classic-homes/theme-styles @classic-homes/theme-tokens tailwindcss
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies: `@classic-homes/theme-tokens@*`, `tailwindcss@>=3.0.0`.
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
Import the styles before the Tailwind directives in your app CSS:
|
|
16
|
+
|
|
17
|
+
```css
|
|
18
|
+
@import '@classic-homes/theme-styles';
|
|
19
|
+
@tailwind base;
|
|
20
|
+
@tailwind components;
|
|
21
|
+
@tailwind utilities;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
The main entry defines the cascade layers, brand fonts, tokens, base, accessibility, and utility styles.
|
|
25
|
+
|
|
26
|
+
## Exports
|
|
27
|
+
|
|
28
|
+
| Import | Contents |
|
|
29
|
+
| ------------------------------------------- | ---------------------------------------------------------- |
|
|
30
|
+
| `@classic-homes/theme-styles` | All styles (fonts, tokens, base, accessibility, utilities) |
|
|
31
|
+
| `@classic-homes/theme-styles/core` | Same as the main entry, without the brand fonts |
|
|
32
|
+
| `@classic-homes/theme-styles/fonts` | Brand fonts |
|
|
33
|
+
| `@classic-homes/theme-styles/base` | Base element styles |
|
|
34
|
+
| `@classic-homes/theme-styles/accessibility` | Accessibility styles |
|
|
35
|
+
| `@classic-homes/theme-styles/utilities` | Utility classes |
|
|
36
|
+
|
|
37
|
+
### Touch field size
|
|
38
|
+
|
|
39
|
+
On touch devices (and any iOS/iPadOS WebKit, including an iPad with a trackpad), text inputs, textareas, selects and contenteditable regions get `font-size: 16px !important`, so iOS doesn't zoom the page when a field is focused. Desktop keeps the compact sizes. Don't add `maximum-scale` to the viewport tag for this — that also blocks pinch-zoom on Android.
|
|
40
|
+
|
|
41
|
+
Opt out with `data-keep-field-size` on a field or any ancestor, for example a canvas whose text boxes are always rendered at a designed size:
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<div class="board-canvas" data-keep-field-size>…</div>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Opted-out fields can still zoom on iOS; stop that another way where needed (for example `maximum-scale=1` on the viewport tag while the canvas is shown).
|
|
48
|
+
|
|
49
|
+
Use `/core` when the app already loads brand fonts:
|
|
50
|
+
|
|
51
|
+
```css
|
|
52
|
+
@import '@classic-homes/theme-styles/core';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The `@layer` order must come before any other `@import` in your CSS. Keep it at the top of the file.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classic-homes/theme-styles",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Base styles and utilities for the Classic Theme design system",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -41,8 +41,12 @@
|
|
|
41
41
|
"tailwindcss": ">=3.0.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@classic-homes/postcss-config": "*",
|
|
45
|
+
"@classic-homes/theme-tailwind-preset": "*",
|
|
46
|
+
"@classic-homes/theme-tokens": "*",
|
|
44
47
|
"postcss": "^8.4.0",
|
|
45
48
|
"postcss-import": "^16.1.1",
|
|
49
|
+
"tailwindcss": "^3.4.0",
|
|
46
50
|
"vitest": "^4.0.0"
|
|
47
51
|
}
|
|
48
52
|
}
|
package/src/accessibility.css
CHANGED
|
@@ -28,36 +28,102 @@
|
|
|
28
28
|
a:focus-visible {
|
|
29
29
|
border-radius: var(--radius, 0.5rem);
|
|
30
30
|
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* The two media blocks below stay outside @layer: nested in a layer, the
|
|
34
|
+
cascade-layers polyfill in @classic-homes/postcss-config leaves an empty
|
|
35
|
+
`@media (forced-colors)` shell at the top of the bundle, ahead of the font
|
|
36
|
+
@import, and browsers then drop the @import. */
|
|
31
37
|
|
|
32
|
-
|
|
38
|
+
/* ===== Reduced Motion (WCAG 2.3.3) ===== */
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
@media (prefers-reduced-motion: reduce) {
|
|
41
|
+
*,
|
|
42
|
+
*::before,
|
|
43
|
+
*::after {
|
|
44
|
+
animation-duration: 0.01ms !important;
|
|
45
|
+
animation-delay: 0ms !important;
|
|
46
|
+
animation-iteration-count: 1 !important;
|
|
47
|
+
transition-duration: 0.01ms !important;
|
|
48
|
+
transition-delay: 0ms !important;
|
|
49
|
+
scroll-behavior: auto !important;
|
|
43
50
|
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* ===== High Contrast Mode Support ===== */
|
|
44
54
|
|
|
45
|
-
|
|
55
|
+
@media (forced-colors: active) {
|
|
56
|
+
/* Ensure borders are visible in high contrast mode */
|
|
57
|
+
button,
|
|
58
|
+
input,
|
|
59
|
+
select,
|
|
60
|
+
textarea,
|
|
61
|
+
[role='button'] {
|
|
62
|
+
border: 1px solid ButtonText;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/* Ensure focus is visible */
|
|
66
|
+
:focus-visible {
|
|
67
|
+
outline: 2px solid Highlight;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
46
70
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
71
|
+
/* ===== Touch Field Size (no iOS zoom-on-focus) ===== */
|
|
72
|
+
|
|
73
|
+
/* iOS (Safari and home-screen web apps) zooms the page to a focused field
|
|
74
|
+
whose font is under 16px, and compact fields (text-sm/text-xs) are. Touch
|
|
75
|
+
devices get 16px text fields; desktop keeps the compact sizes. Unlayered
|
|
76
|
+
and !important so it beats per-field utilities and inline sizes. Use this
|
|
77
|
+
rather than viewport maximum-scale, which also blocks pinch-zoom on
|
|
78
|
+
Android. The media query covers phones and tablets; the @supports block
|
|
79
|
+
(iOS/iPadOS WebKit only) covers an iPad with a trackpad, which reports
|
|
80
|
+
pointer: fine but still zooms.
|
|
81
|
+
|
|
82
|
+
Opt out with data-keep-field-size on a field or container, e.g. a canvas
|
|
83
|
+
whose text boxes are always rendered at a designed size (stop the zoom
|
|
84
|
+
there another way, such as maximum-scale while the canvas is shown). */
|
|
85
|
+
|
|
86
|
+
@media (hover: none) and (pointer: coarse) {
|
|
87
|
+
:is(
|
|
88
|
+
input:not(
|
|
89
|
+
[type='checkbox'],
|
|
90
|
+
[type='radio'],
|
|
91
|
+
[type='range'],
|
|
92
|
+
[type='color'],
|
|
93
|
+
[type='file'],
|
|
94
|
+
[type='button'],
|
|
95
|
+
[type='submit'],
|
|
96
|
+
[type='reset'],
|
|
97
|
+
[type='image'],
|
|
98
|
+
[type='hidden']
|
|
99
|
+
),
|
|
100
|
+
textarea,
|
|
51
101
|
select,
|
|
102
|
+
[contenteditable]:not([contenteditable='false'])
|
|
103
|
+
):not([data-keep-field-size], [data-keep-field-size] *) {
|
|
104
|
+
font-size: 16px !important;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
@supports (-webkit-touch-callout: none) {
|
|
109
|
+
:is(
|
|
110
|
+
input:not(
|
|
111
|
+
[type='checkbox'],
|
|
112
|
+
[type='radio'],
|
|
113
|
+
[type='range'],
|
|
114
|
+
[type='color'],
|
|
115
|
+
[type='file'],
|
|
116
|
+
[type='button'],
|
|
117
|
+
[type='submit'],
|
|
118
|
+
[type='reset'],
|
|
119
|
+
[type='image'],
|
|
120
|
+
[type='hidden']
|
|
121
|
+
),
|
|
52
122
|
textarea,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
/* Ensure focus is visible */
|
|
58
|
-
:focus-visible {
|
|
59
|
-
outline: 2px solid Highlight;
|
|
60
|
-
}
|
|
123
|
+
select,
|
|
124
|
+
[contenteditable]:not([contenteditable='false'])
|
|
125
|
+
):not([data-keep-field-size], [data-keep-field-size] *) {
|
|
126
|
+
font-size: 16px !important;
|
|
61
127
|
}
|
|
62
128
|
}
|
|
63
129
|
|
package/src/utilities.css
CHANGED
|
@@ -170,7 +170,9 @@
|
|
|
170
170
|
* preset (tailwind-preset/index.js) as the single source of truth.
|
|
171
171
|
*
|
|
172
172
|
* The shimmer utility below requires custom background styling beyond
|
|
173
|
-
* what Tailwind's animation config provides, so it remains here.
|
|
173
|
+
* what Tailwind's animation config provides, so it remains here. Its
|
|
174
|
+
* `animation` comes from the preset only: Tailwind's unlayered utility
|
|
175
|
+
* always beats a declaration in this layer, so a second one here is dead.
|
|
174
176
|
*/
|
|
175
177
|
|
|
176
178
|
.animate-shimmer {
|
|
@@ -181,7 +183,6 @@
|
|
|
181
183
|
hsl(var(--muted)) 100%
|
|
182
184
|
);
|
|
183
185
|
background-size: 200% 100%;
|
|
184
|
-
animation: shimmer 2s linear infinite;
|
|
185
186
|
}
|
|
186
187
|
|
|
187
188
|
/* ===== Print Utilities ===== */
|