vunor 0.2.1 → 0.2.2
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/dist/theme.d.mts +1 -1
- package/dist/theme.mjs +37 -7
- package/package.json +1 -1
package/dist/theme.d.mts
CHANGED
|
@@ -16,7 +16,7 @@ interface TVunorUnoPresetOpts {
|
|
|
16
16
|
regular: number;
|
|
17
17
|
dense: number;
|
|
18
18
|
};
|
|
19
|
-
typography?: Record<TTypographyNames, TTypography
|
|
19
|
+
typography?: Partial<Record<TTypographyNames, TTypography>>;
|
|
20
20
|
layers?: {
|
|
21
21
|
reverseDark?: boolean;
|
|
22
22
|
reverseLight?: boolean;
|
package/dist/theme.mjs
CHANGED
|
@@ -232,18 +232,21 @@ const shortcuts = [
|
|
|
232
232
|
];
|
|
233
233
|
//#endregion
|
|
234
234
|
//#region src/theme/shortcuts/btn.ts
|
|
235
|
+
const btnSquare = "size-fingertip px-0";
|
|
236
|
+
const btnRound = "px-fingertip-half rounded-fingertip-half";
|
|
235
237
|
const btn = defineShortcuts({
|
|
236
238
|
"btn": {
|
|
237
239
|
"": "h-fingertip flex items-center justify-center px-$m gap-$xs select-none fw-bold tracking-wide relative",
|
|
238
|
-
"[&.btn-round]:":
|
|
239
|
-
"[&.btn-square]:":
|
|
240
|
+
"[&.btn-round]:": btnRound,
|
|
241
|
+
"[&.btn-square]:": btnSquare,
|
|
240
242
|
"[&.btn-round.btn-square]:": "px-0",
|
|
241
243
|
"disabled:": "opacity-80 cursor-not-allowed",
|
|
242
244
|
"[&>span]:data-[loading]:": "opacity-0 pointer-events-none",
|
|
243
245
|
"[&>div:not(.loading-indicator-wrapper)]:data-[loading]:": "opacity-0 pointer-events-none",
|
|
244
246
|
"[&>.loading-indicator-wrapper]:": "absolute left-0 top-0 right-0 bottom-0 flex items-center justify-center cursor-wait"
|
|
245
247
|
},
|
|
246
|
-
"btn-
|
|
248
|
+
"btn-round": { "": btnRound },
|
|
249
|
+
"btn-square": { "": btnSquare },
|
|
247
250
|
"btn-label": {
|
|
248
251
|
"": "lh-1em ellipsis whitespace-nowrap overflow-x-clip overflow-y-visible",
|
|
249
252
|
"group-[.btn-square]/btn:": "hidden"
|
|
@@ -621,6 +624,7 @@ const componentClasses = {
|
|
|
621
624
|
"btn",
|
|
622
625
|
"btn-icon",
|
|
623
626
|
"btn-label",
|
|
627
|
+
"btn-square",
|
|
624
628
|
"c8-flat",
|
|
625
629
|
"calendar-cell",
|
|
626
630
|
"calendar-grid-row",
|
|
@@ -770,6 +774,7 @@ const componentClasses = {
|
|
|
770
774
|
"btn",
|
|
771
775
|
"btn-icon",
|
|
772
776
|
"btn-label",
|
|
777
|
+
"btn-square",
|
|
773
778
|
"c8-flat",
|
|
774
779
|
"calendar-cell",
|
|
775
780
|
"calendar-grid-row",
|
|
@@ -843,6 +848,7 @@ const componentClasses = {
|
|
|
843
848
|
"btn",
|
|
844
849
|
"btn-icon",
|
|
845
850
|
"btn-label",
|
|
851
|
+
"btn-square",
|
|
846
852
|
"c8-flat",
|
|
847
853
|
"calendar-cell",
|
|
848
854
|
"calendar-grid-row",
|
|
@@ -903,6 +909,7 @@ const componentClasses = {
|
|
|
903
909
|
"btn",
|
|
904
910
|
"btn-icon",
|
|
905
911
|
"btn-label",
|
|
912
|
+
"btn-square",
|
|
906
913
|
"c8-flat",
|
|
907
914
|
"calendar-cell",
|
|
908
915
|
"calendar-grid-row",
|
|
@@ -940,6 +947,7 @@ const componentClasses = {
|
|
|
940
947
|
"btn",
|
|
941
948
|
"btn-icon",
|
|
942
949
|
"btn-label",
|
|
950
|
+
"btn-square",
|
|
943
951
|
"c8-flat",
|
|
944
952
|
"card",
|
|
945
953
|
"checkbox",
|
|
@@ -1251,6 +1259,7 @@ const componentClasses = {
|
|
|
1251
1259
|
Pagination: [
|
|
1252
1260
|
"btn",
|
|
1253
1261
|
"btn-icon",
|
|
1262
|
+
"btn-square",
|
|
1254
1263
|
"c8-flat",
|
|
1255
1264
|
"flex",
|
|
1256
1265
|
"gap-1",
|
|
@@ -2121,7 +2130,22 @@ const defaultTypography = {
|
|
|
2121
2130
|
"caption": font(400, 600, k$1(-.5), k$1(.5), -.007),
|
|
2122
2131
|
"overline": font(400, 600, k$1(-.5), k$1(.5), .0618)
|
|
2123
2132
|
};
|
|
2124
|
-
|
|
2133
|
+
/**
|
|
2134
|
+
* Builds the UnoCSS `fontSize` theme entry for one typography level.
|
|
2135
|
+
*
|
|
2136
|
+
* Takes the whole {@link TTypography} rather than its numeric fields: this
|
|
2137
|
+
* function owns the shape of the emitted tuple, so fields that carry no
|
|
2138
|
+
* geometry (`font`, `css`) reach the output instead of being dropped at a call
|
|
2139
|
+
* site that can only forward numbers.
|
|
2140
|
+
*/
|
|
2141
|
+
function buildFontTheme(t, defaults) {
|
|
2142
|
+
const size = t.size || 1;
|
|
2143
|
+
const w = t.weight || 400;
|
|
2144
|
+
const wBold = t.boldWeight || 700;
|
|
2145
|
+
const lh = t.height || 1;
|
|
2146
|
+
const ls = t.spacing || 0;
|
|
2147
|
+
const actualFontHeightFactor = t.actualHeightFactor || defaults.actualHeightFactor;
|
|
2148
|
+
const actualFontHeightTopBottomRatio = t.actualHeightTopBottomRatio || defaults.actualHeightTopBottomRatio;
|
|
2125
2149
|
const correctedSize = size * actualFontHeightFactor;
|
|
2126
2150
|
const m = (lh * size - correctedSize) / size;
|
|
2127
2151
|
const half = correctedSize / 2;
|
|
@@ -2142,7 +2166,9 @@ function buildFontTheme(size, w, wBold, lh, ls, actualFontHeightFactor = 1, actu
|
|
|
2142
2166
|
"--font-tc": `${-mt}em`,
|
|
2143
2167
|
"font-weight": w,
|
|
2144
2168
|
"line-height": `${lh}em`,
|
|
2145
|
-
"letter-spacing": `${ls}em
|
|
2169
|
+
"letter-spacing": `${ls}em`,
|
|
2170
|
+
...t.font && { "font-family": t.font },
|
|
2171
|
+
...t.css
|
|
2146
2172
|
}]
|
|
2147
2173
|
};
|
|
2148
2174
|
}
|
|
@@ -2246,8 +2272,12 @@ const themeFactory = (opts) => {
|
|
|
2246
2272
|
"line-height": "var(--card-heading-lh)",
|
|
2247
2273
|
"letter-spacing": "var(--card-heading-ls)"
|
|
2248
2274
|
}] };
|
|
2249
|
-
for (const [name, val] of Object.entries(opts.typography))
|
|
2250
|
-
|
|
2275
|
+
for (const [name, val] of Object.entries(opts.typography)) {
|
|
2276
|
+
if (!val) continue;
|
|
2277
|
+
const ft = buildFontTheme(val, {
|
|
2278
|
+
actualHeightFactor: opts.actualFontHeightFactor,
|
|
2279
|
+
actualHeightTopBottomRatio: opts.actualFontHeightTopBottomRatio
|
|
2280
|
+
});
|
|
2251
2281
|
fontSize[name] = ft.theme;
|
|
2252
2282
|
spacing[name] = `${ft.size}em`;
|
|
2253
2283
|
}
|