@webstacks/ui 0.4.3 → 0.4.4
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 +25 -15
- package/dist/index.cjs +129 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +242 -2
- package/dist/index.css.map +1 -1
- package/dist/index.js +129 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/styles/tokens.css +2 -2
package/README.md
CHANGED
|
@@ -27,17 +27,20 @@ This package includes:
|
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
### 1. Add the theme to your CSS
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
import { Button } from "@webstacks/ui";
|
|
32
|
+
In your app's main CSS file (e.g. `index.css`), import Tailwind and the `@webstacks/ui` theme:
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
```css
|
|
35
|
+
@import "tailwindcss";
|
|
36
|
+
@import "@webstacks/ui/theme";
|
|
38
37
|
```
|
|
39
38
|
|
|
40
|
-
|
|
39
|
+
This registers all design tokens, fonts, colors, and component classes with Tailwind v4 at build time. No other CSS imports are needed.
|
|
40
|
+
|
|
41
|
+
### 2. Wrap your app with BaseStyles
|
|
42
|
+
|
|
43
|
+
At the root of your application, wrap your content with `BaseStyles` to activate the design tokens at runtime:
|
|
41
44
|
|
|
42
45
|
```tsx
|
|
43
46
|
import { BaseStyles } from "@webstacks/ui";
|
|
@@ -47,6 +50,21 @@ function RootLayout({ children }) {
|
|
|
47
50
|
}
|
|
48
51
|
```
|
|
49
52
|
|
|
53
|
+
### 3. Use components
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
import { Button, Heading, Section } from "@webstacks/ui";
|
|
57
|
+
|
|
58
|
+
function App() {
|
|
59
|
+
return (
|
|
60
|
+
<Section paddingBlockStart="spacious" paddingBlockEnd="spacious">
|
|
61
|
+
<Heading as="h1" size="display">Hello world</Heading>
|
|
62
|
+
<Button>Get Started</Button>
|
|
63
|
+
</Section>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
50
68
|
### Color mode
|
|
51
69
|
|
|
52
70
|
`BaseStyles` accepts a `colorMode` prop to control light/dark theming:
|
|
@@ -62,14 +80,6 @@ function RootLayout({ children }) {
|
|
|
62
80
|
<BaseStyles colorMode="auto">
|
|
63
81
|
```
|
|
64
82
|
|
|
65
|
-
### Alternative: manual CSS import
|
|
66
|
-
|
|
67
|
-
If you prefer not to use `BaseStyles`, you can import the styles directly in your entry point:
|
|
68
|
-
|
|
69
|
-
```tsx
|
|
70
|
-
import "@webstacks/ui/styles.css";
|
|
71
|
-
```
|
|
72
|
-
|
|
73
83
|
## Components
|
|
74
84
|
|
|
75
85
|
### Layout
|
package/dist/index.cjs
CHANGED
|
@@ -1175,6 +1175,34 @@ var columnMap = {
|
|
|
1175
1175
|
11: "grid-cols-11",
|
|
1176
1176
|
12: "grid-cols-12"
|
|
1177
1177
|
};
|
|
1178
|
+
var mdColumnMap = {
|
|
1179
|
+
1: "md:grid-cols-1",
|
|
1180
|
+
2: "md:grid-cols-2",
|
|
1181
|
+
3: "md:grid-cols-3",
|
|
1182
|
+
4: "md:grid-cols-4",
|
|
1183
|
+
5: "md:grid-cols-5",
|
|
1184
|
+
6: "md:grid-cols-6",
|
|
1185
|
+
7: "md:grid-cols-7",
|
|
1186
|
+
8: "md:grid-cols-8",
|
|
1187
|
+
9: "md:grid-cols-9",
|
|
1188
|
+
10: "md:grid-cols-10",
|
|
1189
|
+
11: "md:grid-cols-11",
|
|
1190
|
+
12: "md:grid-cols-12"
|
|
1191
|
+
};
|
|
1192
|
+
var lgColumnMap = {
|
|
1193
|
+
1: "lg:grid-cols-1",
|
|
1194
|
+
2: "lg:grid-cols-2",
|
|
1195
|
+
3: "lg:grid-cols-3",
|
|
1196
|
+
4: "lg:grid-cols-4",
|
|
1197
|
+
5: "lg:grid-cols-5",
|
|
1198
|
+
6: "lg:grid-cols-6",
|
|
1199
|
+
7: "lg:grid-cols-7",
|
|
1200
|
+
8: "lg:grid-cols-8",
|
|
1201
|
+
9: "lg:grid-cols-9",
|
|
1202
|
+
10: "lg:grid-cols-10",
|
|
1203
|
+
11: "lg:grid-cols-11",
|
|
1204
|
+
12: "lg:grid-cols-12"
|
|
1205
|
+
};
|
|
1178
1206
|
var Grid = React11.forwardRef(
|
|
1179
1207
|
({ as: Comp = "div", className, columns = 12, gap, gapX, gapY, align, justify, ...props }, ref) => {
|
|
1180
1208
|
let columnClasses;
|
|
@@ -1183,8 +1211,8 @@ var Grid = React11.forwardRef(
|
|
|
1183
1211
|
} else {
|
|
1184
1212
|
const classes = [];
|
|
1185
1213
|
if (columns.narrow) classes.push(columnMap[columns.narrow]);
|
|
1186
|
-
if (columns.regular) classes.push(
|
|
1187
|
-
if (columns.wide) classes.push(
|
|
1214
|
+
if (columns.regular) classes.push(mdColumnMap[columns.regular]);
|
|
1215
|
+
if (columns.wide) classes.push(lgColumnMap[columns.wide]);
|
|
1188
1216
|
columnClasses = classes.join(" ");
|
|
1189
1217
|
}
|
|
1190
1218
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
@@ -1249,6 +1277,34 @@ var spanMap = {
|
|
|
1249
1277
|
11: "col-span-11",
|
|
1250
1278
|
12: "col-span-12"
|
|
1251
1279
|
};
|
|
1280
|
+
var mdSpanMap = {
|
|
1281
|
+
1: "md:col-span-1",
|
|
1282
|
+
2: "md:col-span-2",
|
|
1283
|
+
3: "md:col-span-3",
|
|
1284
|
+
4: "md:col-span-4",
|
|
1285
|
+
5: "md:col-span-5",
|
|
1286
|
+
6: "md:col-span-6",
|
|
1287
|
+
7: "md:col-span-7",
|
|
1288
|
+
8: "md:col-span-8",
|
|
1289
|
+
9: "md:col-span-9",
|
|
1290
|
+
10: "md:col-span-10",
|
|
1291
|
+
11: "md:col-span-11",
|
|
1292
|
+
12: "md:col-span-12"
|
|
1293
|
+
};
|
|
1294
|
+
var lgSpanMap = {
|
|
1295
|
+
1: "lg:col-span-1",
|
|
1296
|
+
2: "lg:col-span-2",
|
|
1297
|
+
3: "lg:col-span-3",
|
|
1298
|
+
4: "lg:col-span-4",
|
|
1299
|
+
5: "lg:col-span-5",
|
|
1300
|
+
6: "lg:col-span-6",
|
|
1301
|
+
7: "lg:col-span-7",
|
|
1302
|
+
8: "lg:col-span-8",
|
|
1303
|
+
9: "lg:col-span-9",
|
|
1304
|
+
10: "lg:col-span-10",
|
|
1305
|
+
11: "lg:col-span-11",
|
|
1306
|
+
12: "lg:col-span-12"
|
|
1307
|
+
};
|
|
1252
1308
|
var GridColumn = React11.forwardRef(
|
|
1253
1309
|
({ as: Comp = "div", className, span, start, ...props }, ref) => {
|
|
1254
1310
|
let spanClasses;
|
|
@@ -1257,8 +1313,8 @@ var GridColumn = React11.forwardRef(
|
|
|
1257
1313
|
} else if (span) {
|
|
1258
1314
|
const classes = [];
|
|
1259
1315
|
if (span.narrow) classes.push(spanMap[span.narrow]);
|
|
1260
|
-
if (span.regular) classes.push(
|
|
1261
|
-
if (span.wide) classes.push(
|
|
1316
|
+
if (span.regular) classes.push(mdSpanMap[span.regular]);
|
|
1317
|
+
if (span.wide) classes.push(lgSpanMap[span.wide]);
|
|
1262
1318
|
spanClasses = classes.join(" ");
|
|
1263
1319
|
} else {
|
|
1264
1320
|
spanClasses = "";
|
|
@@ -1707,6 +1763,14 @@ var directionMap = {
|
|
|
1707
1763
|
horizontal: "flex-row",
|
|
1708
1764
|
vertical: "flex-col"
|
|
1709
1765
|
};
|
|
1766
|
+
var mdDirectionMap = {
|
|
1767
|
+
horizontal: "md:flex-row",
|
|
1768
|
+
vertical: "md:flex-col"
|
|
1769
|
+
};
|
|
1770
|
+
var lgDirectionMap = {
|
|
1771
|
+
horizontal: "lg:flex-row",
|
|
1772
|
+
vertical: "lg:flex-col"
|
|
1773
|
+
};
|
|
1710
1774
|
var gapMap = {
|
|
1711
1775
|
none: "gap-0",
|
|
1712
1776
|
condensed: "gap-2",
|
|
@@ -1714,6 +1778,20 @@ var gapMap = {
|
|
|
1714
1778
|
spacious: "gap-6",
|
|
1715
1779
|
"extra-spacious": "gap-8"
|
|
1716
1780
|
};
|
|
1781
|
+
var mdGapMap = {
|
|
1782
|
+
none: "md:gap-0",
|
|
1783
|
+
condensed: "md:gap-2",
|
|
1784
|
+
normal: "md:gap-4",
|
|
1785
|
+
spacious: "md:gap-6",
|
|
1786
|
+
"extra-spacious": "md:gap-8"
|
|
1787
|
+
};
|
|
1788
|
+
var lgGapMap = {
|
|
1789
|
+
none: "lg:gap-0",
|
|
1790
|
+
condensed: "lg:gap-2",
|
|
1791
|
+
normal: "lg:gap-4",
|
|
1792
|
+
spacious: "lg:gap-6",
|
|
1793
|
+
"extra-spacious": "lg:gap-8"
|
|
1794
|
+
};
|
|
1717
1795
|
var alignMap = {
|
|
1718
1796
|
start: "items-start",
|
|
1719
1797
|
center: "items-center",
|
|
@@ -1721,6 +1799,20 @@ var alignMap = {
|
|
|
1721
1799
|
stretch: "items-stretch",
|
|
1722
1800
|
baseline: "items-baseline"
|
|
1723
1801
|
};
|
|
1802
|
+
var mdAlignMap = {
|
|
1803
|
+
start: "md:items-start",
|
|
1804
|
+
center: "md:items-center",
|
|
1805
|
+
end: "md:items-end",
|
|
1806
|
+
stretch: "md:items-stretch",
|
|
1807
|
+
baseline: "md:items-baseline"
|
|
1808
|
+
};
|
|
1809
|
+
var lgAlignMap = {
|
|
1810
|
+
start: "lg:items-start",
|
|
1811
|
+
center: "lg:items-center",
|
|
1812
|
+
end: "lg:items-end",
|
|
1813
|
+
stretch: "lg:items-stretch",
|
|
1814
|
+
baseline: "lg:items-baseline"
|
|
1815
|
+
};
|
|
1724
1816
|
var justifyMap = {
|
|
1725
1817
|
start: "justify-start",
|
|
1726
1818
|
center: "justify-center",
|
|
@@ -1729,16 +1821,37 @@ var justifyMap = {
|
|
|
1729
1821
|
"space-around": "justify-around",
|
|
1730
1822
|
"space-evenly": "justify-evenly"
|
|
1731
1823
|
};
|
|
1732
|
-
|
|
1824
|
+
var mdJustifyMap = {
|
|
1825
|
+
start: "md:justify-start",
|
|
1826
|
+
center: "md:justify-center",
|
|
1827
|
+
end: "md:justify-end",
|
|
1828
|
+
"space-between": "md:justify-between",
|
|
1829
|
+
"space-around": "md:justify-around",
|
|
1830
|
+
"space-evenly": "md:justify-evenly"
|
|
1831
|
+
};
|
|
1832
|
+
var lgJustifyMap = {
|
|
1833
|
+
start: "lg:justify-start",
|
|
1834
|
+
center: "lg:justify-center",
|
|
1835
|
+
end: "lg:justify-end",
|
|
1836
|
+
"space-between": "lg:justify-between",
|
|
1837
|
+
"space-around": "lg:justify-around",
|
|
1838
|
+
"space-evenly": "lg:justify-evenly"
|
|
1839
|
+
};
|
|
1840
|
+
function resolveResponsive3(value, maps) {
|
|
1733
1841
|
if (!value) return [];
|
|
1734
|
-
if (typeof value === "string") return [
|
|
1842
|
+
if (typeof value === "string") return [maps.narrow[value]].filter(Boolean);
|
|
1735
1843
|
const classes = [];
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
if (
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1844
|
+
if (value.narrow) {
|
|
1845
|
+
const cls = maps.narrow[value.narrow];
|
|
1846
|
+
if (cls) classes.push(cls);
|
|
1847
|
+
}
|
|
1848
|
+
if (value.regular) {
|
|
1849
|
+
const cls = maps.regular[value.regular];
|
|
1850
|
+
if (cls) classes.push(cls);
|
|
1851
|
+
}
|
|
1852
|
+
if (value.wide) {
|
|
1853
|
+
const cls = maps.wide[value.wide];
|
|
1854
|
+
if (cls) classes.push(cls);
|
|
1742
1855
|
}
|
|
1743
1856
|
return classes;
|
|
1744
1857
|
}
|
|
@@ -1755,10 +1868,10 @@ var Stack = React15.forwardRef(
|
|
|
1755
1868
|
...props
|
|
1756
1869
|
}, ref) => {
|
|
1757
1870
|
const responsiveClasses = [
|
|
1758
|
-
...resolveResponsive3(direction, directionMap),
|
|
1759
|
-
...resolveResponsive3(gap, gapMap),
|
|
1760
|
-
...resolveResponsive3(align, alignMap),
|
|
1761
|
-
...resolveResponsive3(justify, justifyMap)
|
|
1871
|
+
...resolveResponsive3(direction, { narrow: directionMap, regular: mdDirectionMap, wide: lgDirectionMap }),
|
|
1872
|
+
...resolveResponsive3(gap, { narrow: gapMap, regular: mdGapMap, wide: lgGapMap }),
|
|
1873
|
+
...resolveResponsive3(align, { narrow: alignMap, regular: mdAlignMap, wide: lgAlignMap }),
|
|
1874
|
+
...resolveResponsive3(justify, { narrow: justifyMap, regular: mdJustifyMap, wide: lgJustifyMap })
|
|
1762
1875
|
];
|
|
1763
1876
|
const isResponsiveDirection = typeof direction === "object";
|
|
1764
1877
|
const isResponsiveGap = typeof gap === "object";
|