@oprt/tailwind 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +185 -2
- package/dist/index.cjs +551 -0
- package/dist/index.d.cts +14 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +517 -0
- package/package.json +49 -3
package/dist/index.js
ADDED
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import plugin from "tailwindcss/plugin";
|
|
3
|
+
|
|
4
|
+
// src/cut.ts
|
|
5
|
+
var CUT_RATIO = 0.4;
|
|
6
|
+
var ROUNDS = "@supports (width: round(1px, 1px))";
|
|
7
|
+
var size = (name) => {
|
|
8
|
+
const share = `calc(var(--oprt-height-${name}) * ${CUT_RATIO})`;
|
|
9
|
+
return {
|
|
10
|
+
"--oprt-cut-size": share,
|
|
11
|
+
[ROUNDS]: { "--oprt-cut-size": `round(${share}, 1px)` }
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
var ENABLED = ":not(:disabled):not([aria-disabled=true])";
|
|
15
|
+
var BOTH = {
|
|
16
|
+
"--oprt-cut-tr": "var(--oprt-cut-depth)",
|
|
17
|
+
"--oprt-cut-bl": "var(--oprt-cut-depth)"
|
|
18
|
+
};
|
|
19
|
+
var TR = "var(--oprt-cut-tr, 0px)";
|
|
20
|
+
var BL = "var(--oprt-cut-bl, 0px)";
|
|
21
|
+
var LENGTH = { syntax: '"<length>"', inherits: "false", "initial-value": "0px" };
|
|
22
|
+
var cutProperties = {
|
|
23
|
+
"@property --oprt-cut-tr": LENGTH,
|
|
24
|
+
"@property --oprt-cut-bl": LENGTH
|
|
25
|
+
};
|
|
26
|
+
var EDGE = "var(--oprt-cut-edge, transparent)";
|
|
27
|
+
var STROKE_TOP_RIGHT = `linear-gradient(to top right, transparent calc(50% - 1.5px), ${EDGE} calc(50% - 1px), ${EDGE} 50%, transparent 50%)`;
|
|
28
|
+
var STROKE_BOTTOM_LEFT = `linear-gradient(to top right, transparent 50%, ${EDGE} 50%, ${EDGE} calc(50% + 1px), transparent calc(50% + 1.5px))`;
|
|
29
|
+
var stripes = (width) => `repeating-linear-gradient(45deg, color-mix(in srgb, var(--oprt-error) 10%, transparent) 0 ${width}, transparent ${width} var(--oprt-space-1))`;
|
|
30
|
+
var STRIPES = { "--oprt-cut-hatch": stripes("var(--oprt-space-0-5)") };
|
|
31
|
+
var STRIPES_PRESSED = { "--oprt-cut-hatch": stripes("calc(var(--oprt-space-0-5) * 1.5)") };
|
|
32
|
+
var cutDefaults = {
|
|
33
|
+
":where(.oprt-cut)": { "--oprt-cut-fill": "transparent", "--oprt-cut-edge": "transparent" }
|
|
34
|
+
};
|
|
35
|
+
var cutUtilities = {
|
|
36
|
+
".oprt-cut": {
|
|
37
|
+
position: "relative",
|
|
38
|
+
isolation: "isolate",
|
|
39
|
+
"--oprt-cut-depth": "var(--oprt-cut, var(--oprt-cut-size, 0px))",
|
|
40
|
+
"&::before": {
|
|
41
|
+
content: '""',
|
|
42
|
+
position: "absolute",
|
|
43
|
+
inset: "-1px",
|
|
44
|
+
"z-index": "-1",
|
|
45
|
+
"pointer-events": "none",
|
|
46
|
+
"--oprt-cut-tr": "inherit",
|
|
47
|
+
"--oprt-cut-bl": "inherit",
|
|
48
|
+
border: `1px solid ${EDGE}`,
|
|
49
|
+
"background-color": "var(--oprt-cut-fill, transparent)",
|
|
50
|
+
"background-image": `${STROKE_TOP_RIGHT}, ${STROKE_BOTTOM_LEFT}, var(--oprt-cut-hatch, none)`,
|
|
51
|
+
"background-position": "top right, bottom left, 0 0",
|
|
52
|
+
"background-size": `${TR} ${TR}, ${BL} ${BL}, auto`,
|
|
53
|
+
"background-repeat": "no-repeat, no-repeat, repeat",
|
|
54
|
+
"background-origin": "border-box",
|
|
55
|
+
"clip-path": `polygon(0 0, calc(100% - ${TR}) 0, 100% ${TR}, 100% 100%, ${BL} 100%, 0 calc(100% - ${BL}))`,
|
|
56
|
+
// The layer animates the two depths itself, on the element's timing. Animated on the element
|
|
57
|
+
// and inherited here, they left Safari's clip behind: the value moved, but the clip and the
|
|
58
|
+
// strokes were not worked out again, so a cut never appeared until something else changed.
|
|
59
|
+
"transition-property": "background-color, border-color, --oprt-cut-tr, --oprt-cut-bl",
|
|
60
|
+
"transition-duration": "inherit",
|
|
61
|
+
"transition-timing-function": "inherit"
|
|
62
|
+
},
|
|
63
|
+
// Contact cuts both corners. Hover counts only where a pointer can hover: on a touch screen a
|
|
64
|
+
// tap would otherwise leave the button cut until the next tap elsewhere.
|
|
65
|
+
[`&:active${ENABLED}, &:focus-visible${ENABLED}`]: BOTH,
|
|
66
|
+
"@media (hover: hover)": { [`&:hover${ENABLED}`]: BOTH },
|
|
67
|
+
// Forced colors replace every color the layer draws with, so it steps aside and the
|
|
68
|
+
// element's own border, which that mode makes visible, is the boundary.
|
|
69
|
+
"@media (forced-colors: active)": { "&::before": { display: "none" } }
|
|
70
|
+
},
|
|
71
|
+
".oprt-cut-sm": size("sm"),
|
|
72
|
+
".oprt-cut-md": size("md"),
|
|
73
|
+
".oprt-cut-lg": size("lg"),
|
|
74
|
+
/** No cut, for this control or for every control inside this element. */
|
|
75
|
+
".oprt-cut-none": { "--oprt-cut": "0px" },
|
|
76
|
+
/** The top-right corner is cut at rest. */
|
|
77
|
+
".oprt-cut-standing": { "--oprt-cut-tr": "var(--oprt-cut-depth)" },
|
|
78
|
+
/** Hazard stripes fill the control while it is armed: hovered, focused from the keyboard, pressed. */
|
|
79
|
+
".oprt-cut-hazard": {
|
|
80
|
+
[`&:focus-visible${ENABLED}`]: STRIPES,
|
|
81
|
+
"@media (hover: hover)": { [`&:hover${ENABLED}`]: STRIPES },
|
|
82
|
+
[`&:active${ENABLED}`]: STRIPES_PRESSED
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// src/motion.ts
|
|
87
|
+
var duration = (role) => `calc(var(--oprt-motion-${role}) * var(--oprt-motion-factor, 1))`;
|
|
88
|
+
var response = "var(--oprt-motion-ease-response)";
|
|
89
|
+
var move = "var(--oprt-motion-ease-move)";
|
|
90
|
+
var motionUtilities = {
|
|
91
|
+
".oprt-motion": {
|
|
92
|
+
"&[data-oprt-motion=none]": { "--oprt-motion-factor": "0" },
|
|
93
|
+
"&[data-oprt-motion=none], &[data-oprt-motion=none] *": { "transition-property": "none" },
|
|
94
|
+
"@media (prefers-reduced-motion: reduce)": {
|
|
95
|
+
"--oprt-motion-factor": "0",
|
|
96
|
+
"&.oprt-motion, &.oprt-motion *": { "transition-property": "none" }
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
".oprt-motion-press": {
|
|
100
|
+
position: "relative",
|
|
101
|
+
scale: "1",
|
|
102
|
+
// A control that carries the cut animates its two depths in the cut's own layer, on this
|
|
103
|
+
// timing, which the layer inherits (see ./cut).
|
|
104
|
+
"transition-property": "scale, background-color, border-color, color",
|
|
105
|
+
"transition-duration": duration("release"),
|
|
106
|
+
"transition-timing-function": response,
|
|
107
|
+
"&::after": {
|
|
108
|
+
content: '""',
|
|
109
|
+
position: "absolute",
|
|
110
|
+
inset: "0",
|
|
111
|
+
scale: "1",
|
|
112
|
+
"transition-property": "scale",
|
|
113
|
+
"transition-duration": "inherit",
|
|
114
|
+
"transition-timing-function": "inherit"
|
|
115
|
+
},
|
|
116
|
+
"&:active:not(:disabled):not([aria-disabled=true])": {
|
|
117
|
+
"--oprt-press-target-scale": "calc(1 + (var(--oprt-motion-press-scale) - 1) * var(--oprt-motion-factor, 1))",
|
|
118
|
+
scale: "var(--oprt-press-target-scale)",
|
|
119
|
+
"transition-duration": duration("press"),
|
|
120
|
+
// The transparent hit surface exactly compensates for visual compression.
|
|
121
|
+
"&::after": { scale: "calc(1 / var(--oprt-press-target-scale))" }
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
".oprt-motion-track": {
|
|
125
|
+
"transition-property": "background-color, border-color",
|
|
126
|
+
"transition-duration": duration("state"),
|
|
127
|
+
"transition-timing-function": response
|
|
128
|
+
},
|
|
129
|
+
// Tailwind 4's `translate-x-*` moves the thumb with `translate`; `transform` stays for a thumb
|
|
130
|
+
// moved by a style of its own.
|
|
131
|
+
".oprt-motion-thumb": {
|
|
132
|
+
"transition-property": "translate, transform, background-color",
|
|
133
|
+
"transition-duration": duration("state"),
|
|
134
|
+
"transition-timing-function": `${move}, ${move}, ${response}`
|
|
135
|
+
},
|
|
136
|
+
".oprt-motion-check": {
|
|
137
|
+
display: "block",
|
|
138
|
+
position: "absolute",
|
|
139
|
+
inset: "0",
|
|
140
|
+
margin: "auto",
|
|
141
|
+
opacity: "0",
|
|
142
|
+
scale: "var(--oprt-motion-mark-scale)",
|
|
143
|
+
"transition-property": "opacity, scale",
|
|
144
|
+
"transition-duration": duration("state"),
|
|
145
|
+
"transition-timing-function": response,
|
|
146
|
+
"[data-selected]:not([data-indeterminate]) &.oprt-cb-check, [data-indeterminate] &.oprt-cb-bar": {
|
|
147
|
+
opacity: "1",
|
|
148
|
+
scale: "1"
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
".oprt-motion-tabs": {
|
|
152
|
+
position: "relative",
|
|
153
|
+
"&[data-indicator-ready] [role=tab][data-selected]": { "border-bottom-color": "transparent" },
|
|
154
|
+
"&[data-orientation=vertical]": {
|
|
155
|
+
"border-bottom-width": "0",
|
|
156
|
+
"border-inline-end-width": "1px",
|
|
157
|
+
"flex-direction": "column",
|
|
158
|
+
"& [role=tab]": {
|
|
159
|
+
"margin-bottom": "0",
|
|
160
|
+
"border-bottom-width": "1px",
|
|
161
|
+
"border-inline-end-width": "2px"
|
|
162
|
+
},
|
|
163
|
+
"&:not([data-indicator-ready]) [role=tab][data-selected]": {
|
|
164
|
+
"border-inline-end-color": "var(--oprt-accent)",
|
|
165
|
+
"border-bottom-color": "transparent"
|
|
166
|
+
},
|
|
167
|
+
"&[data-indicator-ready] [role=tab][data-selected]": {
|
|
168
|
+
"border-inline-end-color": "transparent"
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
// A horizontal tab list scrolls (design call DC-14) and lays its last pixel row over the rail
|
|
173
|
+
// line its row draws, so the indicator sits on the list's own bottom edge, inside what scrolls,
|
|
174
|
+
// and still straddles the line.
|
|
175
|
+
".oprt-motion-indicator": {
|
|
176
|
+
position: "absolute",
|
|
177
|
+
bottom: "0",
|
|
178
|
+
left: "0",
|
|
179
|
+
width: "1px",
|
|
180
|
+
height: "2px",
|
|
181
|
+
"pointer-events": "none",
|
|
182
|
+
"transform-origin": "left center",
|
|
183
|
+
"background-color": "var(--oprt-accent)",
|
|
184
|
+
"transition-property": "transform",
|
|
185
|
+
"transition-duration": duration("state"),
|
|
186
|
+
"transition-timing-function": move,
|
|
187
|
+
"&[data-immediate=true]": { "transition-duration": "0s", "transition-property": "none" },
|
|
188
|
+
// Forced colors replace a background with the page color, which would hide the selected
|
|
189
|
+
// tab's underline: draw it in Highlight instead (Tabs-R3).
|
|
190
|
+
"@media (forced-colors: active)": {
|
|
191
|
+
"forced-color-adjust": "none",
|
|
192
|
+
"background-color": "Highlight"
|
|
193
|
+
},
|
|
194
|
+
"[data-orientation=vertical] > &": {
|
|
195
|
+
bottom: "auto",
|
|
196
|
+
top: "0",
|
|
197
|
+
left: "auto",
|
|
198
|
+
right: "auto",
|
|
199
|
+
"inset-inline-end": "-1px",
|
|
200
|
+
width: "2px",
|
|
201
|
+
height: "1px",
|
|
202
|
+
"transform-origin": "center top"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
".oprt-motion-panel": {
|
|
206
|
+
height: "var(--disclosure-panel-height)",
|
|
207
|
+
overflow: "clip",
|
|
208
|
+
"transition-property": "height",
|
|
209
|
+
"transition-duration": duration("expand"),
|
|
210
|
+
"transition-timing-function": move,
|
|
211
|
+
"&[aria-hidden=true]": { "transition-duration": duration("collapse") }
|
|
212
|
+
},
|
|
213
|
+
// `rotate-180` turns the chevron with `rotate` in Tailwind 4.
|
|
214
|
+
".oprt-motion-chevron": {
|
|
215
|
+
"transition-property": "rotate, transform",
|
|
216
|
+
"transition-duration": duration("expand"),
|
|
217
|
+
"transition-timing-function": move,
|
|
218
|
+
".oprt-motion-disclosure:not([data-expanded]) &": {
|
|
219
|
+
"transition-duration": duration("collapse")
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
".oprt-motion-popover-chevron": {
|
|
223
|
+
transform: "rotate(0deg)",
|
|
224
|
+
"transition-property": "transform",
|
|
225
|
+
"transition-duration": duration("exit"),
|
|
226
|
+
"transition-timing-function": response,
|
|
227
|
+
"[aria-expanded=true] > &": {
|
|
228
|
+
transform: "rotate(180deg)",
|
|
229
|
+
"transition-duration": duration("enter")
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
".oprt-motion-overlay": {
|
|
233
|
+
opacity: "1",
|
|
234
|
+
"transition-property": "opacity",
|
|
235
|
+
"transition-duration": duration("enter"),
|
|
236
|
+
"transition-timing-function": response,
|
|
237
|
+
"&[data-entering], &[data-exiting]": { opacity: "calc(1 - var(--oprt-motion-factor, 1))" },
|
|
238
|
+
"&[data-exiting]": { "transition-duration": duration("exit") }
|
|
239
|
+
},
|
|
240
|
+
".oprt-motion-surface": {
|
|
241
|
+
scale: "1",
|
|
242
|
+
opacity: "1",
|
|
243
|
+
"transition-property": "scale, opacity",
|
|
244
|
+
"transition-duration": duration("enter"),
|
|
245
|
+
"transition-timing-function": response,
|
|
246
|
+
"&[data-entering], &[data-exiting]": {
|
|
247
|
+
scale: "calc(1 + (var(--oprt-motion-surface-scale) - 1) * var(--oprt-motion-factor, 1))",
|
|
248
|
+
opacity: "calc(1 - var(--oprt-motion-factor, 1))"
|
|
249
|
+
},
|
|
250
|
+
"&[data-exiting]": { "transition-duration": duration("exit") }
|
|
251
|
+
},
|
|
252
|
+
".oprt-motion-popover": {
|
|
253
|
+
"transform-origin": "var(--trigger-anchor-point, center)",
|
|
254
|
+
translate: "0 0",
|
|
255
|
+
scale: "1",
|
|
256
|
+
opacity: "1",
|
|
257
|
+
"transition-property": "translate, scale, opacity",
|
|
258
|
+
"transition-duration": duration("enter"),
|
|
259
|
+
"transition-timing-function": response,
|
|
260
|
+
"&[data-entering], &[data-exiting]": {
|
|
261
|
+
translate: "var(--oprt-popover-x, 0px) var(--oprt-popover-y, 0px)",
|
|
262
|
+
scale: "calc(1 + (var(--oprt-motion-surface-scale) - 1) * var(--oprt-motion-factor, 1))",
|
|
263
|
+
opacity: "calc(1 - var(--oprt-motion-factor, 1))"
|
|
264
|
+
},
|
|
265
|
+
"&[data-placement=bottom]": {
|
|
266
|
+
"--oprt-popover-y": "calc(-1 * var(--oprt-motion-travel) * var(--oprt-motion-factor, 1))"
|
|
267
|
+
},
|
|
268
|
+
"&[data-placement=top]": {
|
|
269
|
+
"--oprt-popover-y": "calc(var(--oprt-motion-travel) * var(--oprt-motion-factor, 1))"
|
|
270
|
+
},
|
|
271
|
+
"&[data-placement=right]": {
|
|
272
|
+
"--oprt-popover-x": "calc(-1 * var(--oprt-motion-travel) * var(--oprt-motion-factor, 1))"
|
|
273
|
+
},
|
|
274
|
+
"&[data-placement=left]": {
|
|
275
|
+
"--oprt-popover-x": "calc(var(--oprt-motion-travel) * var(--oprt-motion-factor, 1))"
|
|
276
|
+
},
|
|
277
|
+
"&[data-exiting]": {
|
|
278
|
+
"transition-duration": duration("exit"),
|
|
279
|
+
"pointer-events": "none"
|
|
280
|
+
},
|
|
281
|
+
// Collision flips settle travel immediately; the surface still arrives.
|
|
282
|
+
"&:where([data-oprt-repositioned]:not([data-exiting]))": {
|
|
283
|
+
"transition-property": "scale, opacity"
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
var HATCH_REPEAT = "calc(var(--oprt-space-1) * 1.41421)";
|
|
288
|
+
var slideKeyframes = {
|
|
289
|
+
"oprt-slide": {
|
|
290
|
+
from: { translate: "0 0" },
|
|
291
|
+
to: { translate: "var(--oprt-slide-distance) 0" }
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
var slideMotion = (distance) => ({
|
|
295
|
+
"--oprt-slide-distance": distance,
|
|
296
|
+
animation: "oprt-slide 1.5s linear infinite",
|
|
297
|
+
"@media (prefers-reduced-motion: reduce)": { animation: "none" },
|
|
298
|
+
"@media (forced-colors: active)": { animation: "none" },
|
|
299
|
+
"[data-oprt-motion=none] &": { animation: "none" }
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// src/index.ts
|
|
303
|
+
var SPACING = {
|
|
304
|
+
// No 7u — char-grid skips to 8u. Mirrors --oprt-space-* CSS tokens.
|
|
305
|
+
"0.5u": "var(--oprt-space-0-5)",
|
|
306
|
+
"1u": "var(--oprt-space-1)",
|
|
307
|
+
"1.5u": "calc(var(--oprt-space-1) * 1.5)",
|
|
308
|
+
"2u": "var(--oprt-space-2)",
|
|
309
|
+
"2.5u": "calc(var(--oprt-space-1) * 2.5)",
|
|
310
|
+
"3u": "var(--oprt-space-3)",
|
|
311
|
+
"4u": "var(--oprt-space-4)",
|
|
312
|
+
"5u": "var(--oprt-space-5)",
|
|
313
|
+
"6u": "var(--oprt-space-6)",
|
|
314
|
+
"8u": "var(--oprt-space-8)",
|
|
315
|
+
// 12u for Select popover max-height (~96px).
|
|
316
|
+
"12u": "calc(var(--oprt-space-6) * 2)",
|
|
317
|
+
// Compact plots span two of the foundation's 8u blocks.
|
|
318
|
+
"16u": "calc(var(--oprt-space-8) * 2)",
|
|
319
|
+
// CommandPalette list height: ten 4u rows before it scrolls.
|
|
320
|
+
"40u": "calc(var(--oprt-space-8) * 5)",
|
|
321
|
+
"oprt-cell-inline": "var(--oprt-table-cell-inline)",
|
|
322
|
+
"oprt-cell-block": "var(--oprt-table-cell-block)",
|
|
323
|
+
"oprt-cell-block-dense": "var(--oprt-table-cell-block-dense)"
|
|
324
|
+
};
|
|
325
|
+
var HEIGHT = {
|
|
326
|
+
"oprt-sm": "var(--oprt-height-sm)",
|
|
327
|
+
"oprt-md": "var(--oprt-height-md)",
|
|
328
|
+
"oprt-lg": "var(--oprt-height-lg)",
|
|
329
|
+
"oprt-badge-sm": "var(--oprt-badge-height-sm)",
|
|
330
|
+
"oprt-badge-md": "var(--oprt-badge-height-md)",
|
|
331
|
+
"oprt-row": "var(--oprt-table-row)",
|
|
332
|
+
"oprt-row-dense": "var(--oprt-table-row-dense)",
|
|
333
|
+
// Rail thicknesses for track-and-thumb controls. Deliberately off the 8px
|
|
334
|
+
// char grid: 1u (8px) is half the md thumb and reads as a bar, not a rail.
|
|
335
|
+
// Held at ~1/4 of the thumb at every size.
|
|
336
|
+
"oprt-track-sm": "var(--oprt-track-sm)",
|
|
337
|
+
"oprt-track-md": "var(--oprt-track-md)",
|
|
338
|
+
"oprt-track-lg": "var(--oprt-track-lg)"
|
|
339
|
+
};
|
|
340
|
+
var typeStep = (step) => [
|
|
341
|
+
`var(--oprt-type-${step})`,
|
|
342
|
+
{
|
|
343
|
+
lineHeight: `var(--oprt-line-${step})`,
|
|
344
|
+
letterSpacing: `var(--oprt-tracking-${step})`,
|
|
345
|
+
fontWeight: `var(--oprt-weight-${step})`
|
|
346
|
+
}
|
|
347
|
+
];
|
|
348
|
+
var FONT_SIZE = {
|
|
349
|
+
"oprt-xs": typeStep("xs"),
|
|
350
|
+
"oprt-sm": typeStep("sm"),
|
|
351
|
+
"oprt-base": typeStep("base"),
|
|
352
|
+
"oprt-md": typeStep("md"),
|
|
353
|
+
"oprt-lg": typeStep("lg"),
|
|
354
|
+
"oprt-xl": typeStep("xl"),
|
|
355
|
+
"oprt-2xl": typeStep("2xl")
|
|
356
|
+
};
|
|
357
|
+
var BORDER_RADIUS = {
|
|
358
|
+
none: "0px",
|
|
359
|
+
sm: "0px",
|
|
360
|
+
DEFAULT: "0px",
|
|
361
|
+
md: "0px",
|
|
362
|
+
lg: "0px",
|
|
363
|
+
xl: "0px",
|
|
364
|
+
"2xl": "0px",
|
|
365
|
+
"3xl": "0px",
|
|
366
|
+
full: "0px"
|
|
367
|
+
};
|
|
368
|
+
var COLORS = {
|
|
369
|
+
bg: "var(--oprt-bg)",
|
|
370
|
+
"surface-1": "var(--oprt-surface-1)",
|
|
371
|
+
"surface-2": "var(--oprt-surface-2)",
|
|
372
|
+
"surface-3": "var(--oprt-surface-3)",
|
|
373
|
+
border: "var(--oprt-border)",
|
|
374
|
+
"border-strong": "var(--oprt-border-strong)",
|
|
375
|
+
"border-focus": "var(--oprt-border-focus)",
|
|
376
|
+
// The boundary of a control: `border-oprt-border-control`. `border-oprt-border` is for layout lines.
|
|
377
|
+
"border-control": "var(--oprt-border-control)",
|
|
378
|
+
text: "var(--oprt-text)",
|
|
379
|
+
"text-dim": "var(--oprt-text-dim)",
|
|
380
|
+
// An empty field's placeholder: brighter than text-dim, which is also the disabled text.
|
|
381
|
+
"text-placeholder": "var(--oprt-text-placeholder)",
|
|
382
|
+
"text-muted": "var(--oprt-text-muted)",
|
|
383
|
+
accent: "var(--oprt-accent)",
|
|
384
|
+
"accent-light": "var(--oprt-accent-light)",
|
|
385
|
+
"accent-hover": "var(--oprt-accent-hover)",
|
|
386
|
+
"accent-active": "var(--oprt-accent-active)",
|
|
387
|
+
"accent-ghost": "var(--oprt-accent-ghost)",
|
|
388
|
+
"accent-bg": "var(--oprt-accent-bg)",
|
|
389
|
+
"accent-border": "var(--oprt-accent-border)",
|
|
390
|
+
success: "var(--oprt-success)",
|
|
391
|
+
warning: "var(--oprt-warning)",
|
|
392
|
+
error: "var(--oprt-error)",
|
|
393
|
+
info: "var(--oprt-info)",
|
|
394
|
+
"success-subtle": "var(--oprt-success-subtle)",
|
|
395
|
+
"success-strong": "var(--oprt-success-strong)",
|
|
396
|
+
"warning-subtle": "var(--oprt-warning-subtle)",
|
|
397
|
+
"warning-strong": "var(--oprt-warning-strong)",
|
|
398
|
+
"error-subtle": "var(--oprt-error-subtle)",
|
|
399
|
+
"error-strong": "var(--oprt-error-strong)",
|
|
400
|
+
"info-subtle": "var(--oprt-info-subtle)",
|
|
401
|
+
"info-strong": "var(--oprt-info-strong)",
|
|
402
|
+
"cat-1": "var(--oprt-cat-1)",
|
|
403
|
+
"cat-2": "var(--oprt-cat-2)",
|
|
404
|
+
"cat-3": "var(--oprt-cat-3)",
|
|
405
|
+
"cat-4": "var(--oprt-cat-4)",
|
|
406
|
+
"cat-5": "var(--oprt-cat-5)",
|
|
407
|
+
"cat-6": "var(--oprt-cat-6)",
|
|
408
|
+
"cat-7": "var(--oprt-cat-7)",
|
|
409
|
+
"cat-8": "var(--oprt-cat-8)",
|
|
410
|
+
"data-seq-1": "var(--oprt-data-seq-1)",
|
|
411
|
+
"data-seq-2": "var(--oprt-data-seq-2)",
|
|
412
|
+
"data-seq-3": "var(--oprt-data-seq-3)",
|
|
413
|
+
"data-seq-4": "var(--oprt-data-seq-4)",
|
|
414
|
+
"data-seq-5": "var(--oprt-data-seq-5)",
|
|
415
|
+
"chart-grid": "var(--oprt-chart-grid)",
|
|
416
|
+
"chart-axis": "var(--oprt-chart-axis)",
|
|
417
|
+
"chart-threshold": "var(--oprt-chart-threshold)",
|
|
418
|
+
"surface-4": "var(--oprt-surface-4)",
|
|
419
|
+
"surface-5": "var(--oprt-surface-5)",
|
|
420
|
+
"surface-6": "var(--oprt-surface-6)",
|
|
421
|
+
"border-subtle": "var(--oprt-border-subtle)",
|
|
422
|
+
"surface-hover": "var(--oprt-surface-hover)",
|
|
423
|
+
"surface-active": "var(--oprt-surface-active)",
|
|
424
|
+
"surface-selected": "var(--oprt-surface-selected)",
|
|
425
|
+
"overlay-scrim": "var(--oprt-overlay-scrim)"
|
|
426
|
+
};
|
|
427
|
+
var TRANSITION_DURATION = {
|
|
428
|
+
"oprt-instant": "var(--oprt-duration-instant)",
|
|
429
|
+
"oprt-fast": "var(--oprt-duration-fast)",
|
|
430
|
+
"oprt-normal": "var(--oprt-duration-normal)",
|
|
431
|
+
"oprt-slow": "var(--oprt-duration-slow)"
|
|
432
|
+
};
|
|
433
|
+
var TRANSITION_TIMING = {
|
|
434
|
+
oprt: "var(--oprt-easing)"
|
|
435
|
+
};
|
|
436
|
+
var LETTER_SPACING = {
|
|
437
|
+
"oprt-xs": "var(--oprt-tracking-xs)",
|
|
438
|
+
"oprt-sm": "var(--oprt-tracking-sm)",
|
|
439
|
+
// Uppercase control labels. The type-scale trackings above are tuned for
|
|
440
|
+
// their own size; `oprt-sm` (0.12em) is right for 9px overlines and far too
|
|
441
|
+
// wide once the same class lands on an 11px/13px control at weight 500-600.
|
|
442
|
+
// Tracking must fall as size and weight rise, so these are bound to a
|
|
443
|
+
// component's SIZE variant, never to its base class.
|
|
444
|
+
"oprt-caps": "var(--oprt-tracking-caps)",
|
|
445
|
+
// 11px uppercase controls
|
|
446
|
+
"oprt-caps-lg": "var(--oprt-tracking-caps-lg)",
|
|
447
|
+
// 13px uppercase controls
|
|
448
|
+
"oprt-base": "var(--oprt-tracking-base)",
|
|
449
|
+
"oprt-md": "var(--oprt-tracking-md)",
|
|
450
|
+
"oprt-lg": "var(--oprt-tracking-lg)",
|
|
451
|
+
"oprt-xl": "var(--oprt-tracking-xl)",
|
|
452
|
+
"oprt-2xl": "var(--oprt-tracking-2xl)"
|
|
453
|
+
};
|
|
454
|
+
var BOX_SHADOW = {
|
|
455
|
+
// Focus indicator: a 1px ring in the focus border color (WCAG 2.4.7). The exact geometry and
|
|
456
|
+
// its relation to 2.4.11 and 2.4.13 are on the Focus foundations page.
|
|
457
|
+
"oprt-focus": "0 0 0 1px var(--oprt-border-focus)"
|
|
458
|
+
};
|
|
459
|
+
var CONTAINER_WIDTHS = { "oprt-sm": "320px", "oprt-md": "480px", "oprt-lg": "640px" };
|
|
460
|
+
var operatorPlugin = plugin(
|
|
461
|
+
({ addBase, addVariant, addUtilities, matchUtilities }) => {
|
|
462
|
+
addBase({
|
|
463
|
+
"*, ::after, ::before, ::backdrop, ::file-selector-button": {
|
|
464
|
+
"border-color": "var(--oprt-border)"
|
|
465
|
+
},
|
|
466
|
+
'button:not(:disabled), [role="button"]:not(:disabled)': { cursor: "pointer" }
|
|
467
|
+
});
|
|
468
|
+
addVariant("theme-bone", '[data-theme="bone"] &');
|
|
469
|
+
addUtilities(motionUtilities);
|
|
470
|
+
addBase(cutProperties);
|
|
471
|
+
addBase(cutDefaults);
|
|
472
|
+
addUtilities(cutUtilities);
|
|
473
|
+
matchUtilities({ "oprt-motion-slide": slideMotion }, { values: { DEFAULT: HATCH_REPEAT } });
|
|
474
|
+
addUtilities({ ".oprt-wrap-anywhere": { "overflow-wrap": "anywhere" } });
|
|
475
|
+
for (const [name, width] of Object.entries(CONTAINER_WIDTHS))
|
|
476
|
+
addVariant(`@${name}`, `@container (min-width: ${width})`);
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
theme: {
|
|
480
|
+
borderRadius: BORDER_RADIUS,
|
|
481
|
+
extend: {
|
|
482
|
+
keyframes: slideKeyframes,
|
|
483
|
+
spacing: SPACING,
|
|
484
|
+
height: HEIGHT,
|
|
485
|
+
// Same control-size scale exposed on width, so square controls
|
|
486
|
+
// (Avatar, icon-only Button) can pin both axes to one token. Without
|
|
487
|
+
// this, `w-oprt-*` silently resolves to nothing: Tailwind derives
|
|
488
|
+
// `width` from `spacing`, which carries only the `Nu` char-grid keys.
|
|
489
|
+
width: HEIGHT,
|
|
490
|
+
// The same holds for the four min/max properties: they derive from `spacing` plus
|
|
491
|
+
// keywords, so `min-h-oprt-md` compiled to nothing until it was registered here.
|
|
492
|
+
minHeight: HEIGHT,
|
|
493
|
+
minWidth: HEIGHT,
|
|
494
|
+
maxHeight: HEIGHT,
|
|
495
|
+
maxWidth: HEIGHT,
|
|
496
|
+
fontSize: FONT_SIZE,
|
|
497
|
+
fontFamily: {
|
|
498
|
+
mono: ["var(--oprt-font-mono)"],
|
|
499
|
+
sans: ["var(--oprt-font-sans)"]
|
|
500
|
+
},
|
|
501
|
+
// Plain values: Tailwind 4 mixes an opacity modifier such as `/40` into any color
|
|
502
|
+
// itself, toward transparent, so the token keeps its hue and only its alpha falls.
|
|
503
|
+
colors: {
|
|
504
|
+
oprt: COLORS
|
|
505
|
+
},
|
|
506
|
+
transitionDuration: TRANSITION_DURATION,
|
|
507
|
+
transitionTimingFunction: TRANSITION_TIMING,
|
|
508
|
+
letterSpacing: LETTER_SPACING,
|
|
509
|
+
boxShadow: BOX_SHADOW
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
);
|
|
514
|
+
var index_default = operatorPlugin;
|
|
515
|
+
export {
|
|
516
|
+
index_default as default
|
|
517
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oprt/tailwind",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OPERATOR design system plugin for Tailwind CSS 4: token-backed colors, spacing, control sizes, type, motion and container-query utilities. Install it with @oprt/tokens, which defines the custom properties it emits.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"design-system",
|
|
7
|
+
"tailwindcss",
|
|
8
|
+
"tailwindcss-plugin",
|
|
9
|
+
"design-tokens"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://oprt.dev/docs",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.cjs",
|
|
14
|
+
"module": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"default": "./dist/index.cjs"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"tailwindcss": ">=4.3.3 <5"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@tailwindcss/node": "^4.3.3",
|
|
36
|
+
"postcss": "^8.4.47",
|
|
37
|
+
"tailwindcss": "^4.3.3",
|
|
38
|
+
"tsup": "^8.3.0",
|
|
39
|
+
"typescript": "^5.6.3",
|
|
40
|
+
"vitest": "^2.1.3"
|
|
41
|
+
},
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean && node scripts/finalize-cjs.mjs",
|
|
48
|
+
"test": "vitest run",
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"lint": "eslint src scripts"
|
|
51
|
+
}
|
|
6
52
|
}
|