@keboola/tailwind-config 0.3.0 → 0.4.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 +33 -0
- package/colors.ts +3 -0
- package/index.js +22 -2
- package/package.json +1 -1
- package/typography.ts +9 -4
package/README.md
CHANGED
|
@@ -32,6 +32,39 @@ export default {
|
|
|
32
32
|
};
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
+
### Class prefix (`tw-`)
|
|
36
|
+
|
|
37
|
+
The default config prefixes every utility with `tw-` (`tw-flex`, `tw-bg-background`, …). `@keboola/design` components ship with those `tw-`-prefixed class names baked into their compiled JS, and those classes only render if a stylesheet the app loads actually **defines** them. How you load that stylesheet decides whether you can drop the prefix:
|
|
38
|
+
|
|
39
|
+
1. **Build-from-source** (the monorepo / `apps/boilerplate` pattern) — the app imports the source stylesheet `@keboola/design/styles` and runs its **own** Tailwind `@tailwind utilities` pass over design's `dist/` plus its own markup. That pass emits the components' classes _using this config's prefix_, so it only produces `tw-*` when the prefix is `tw-`. **If you flip this setup to `prefix: ''`, design components render UNSTYLED** — your build emits `flex`, never `tw-flex`, so the `tw-flex` baked into the components matches nothing. **Keep `tw-` for build-from-source setups.**
|
|
40
|
+
|
|
41
|
+
2. **Precompiled CSS** — the app imports `@keboola/design/styles/compiled` (the shipped `dist/styles.css`, which already contains every `tw-*` utility the components use, prebuilt). Design components are then styled by that stylesheet regardless of your app's own Tailwind prefix, so `createKeboolaConfig({ prefix: '' })` is safe **for your own markup**: `tw-flex` (design's) and `flex` (yours) live in the same cascade without colliding.
|
|
42
|
+
|
|
43
|
+
Prefix-less recipe (consume design precompiled, author your own utilities unprefixed):
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
@import '@keboola/design/styles/compiled'; /* design components, pre-styled with tw-* */
|
|
47
|
+
@tailwind base;
|
|
48
|
+
@tailwind components;
|
|
49
|
+
@tailwind utilities; /* your own unprefixed utilities */
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
**Bottom line: prefix-less is safe only when you consume design via `/styles/compiled`, not when you build design's utilities from source.**
|
|
53
|
+
|
|
54
|
+
Opt out of the prefix (or set a custom one) with the `createKeboolaConfig` factory:
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
import { createKeboolaConfig } from '@keboola/tailwind-config';
|
|
58
|
+
|
|
59
|
+
/** @type {import('tailwindcss').Config} */
|
|
60
|
+
export default {
|
|
61
|
+
...createKeboolaConfig({ prefix: '' }), // unprefixed: `flex`, not `tw-flex`
|
|
62
|
+
content: ['./src/**/*.{ts,tsx,mdx}'],
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Pass any string to `prefix` for a custom prefix (e.g. `createKeboolaConfig({ prefix: 'kbc-' })`). The default export is `createKeboolaConfig()` (i.e. `prefix: 'tw-'`), so existing `import keboolaConfig from '@keboola/tailwind-config'` consumers are unaffected.
|
|
67
|
+
|
|
35
68
|
### Subpath imports
|
|
36
69
|
|
|
37
70
|
If you only need the raw token data:
|
package/colors.ts
CHANGED
|
@@ -66,6 +66,9 @@ export default {
|
|
|
66
66
|
// Focus ring (brand blue).
|
|
67
67
|
ring: 'rgb(var(--color-ring) / <alpha-value>)',
|
|
68
68
|
|
|
69
|
+
// Focus-ring offset gap (the surface color the ring is inset against).
|
|
70
|
+
'ring-offset': 'rgb(var(--color-ring-offset) / <alpha-value>)',
|
|
71
|
+
|
|
69
72
|
// Categorical chart palette (brand-derived).
|
|
70
73
|
chart: {
|
|
71
74
|
1: 'rgb(var(--color-chart-1) / <alpha-value>)',
|
package/index.js
CHANGED
|
@@ -7,9 +7,26 @@ import containerQueriesPlugin from '@tailwindcss/container-queries';
|
|
|
7
7
|
import { typography } from './typography';
|
|
8
8
|
import { scrollFadePlugin } from './scrollFade';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Build the Keboola Tailwind config, optionally overriding the class prefix.
|
|
12
|
+
*
|
|
13
|
+
* `@keboola/design` and the in-monorepo apps are built with the `tw-` prefix
|
|
14
|
+
* (the default), so the design system's compiled CSS assumes it. External
|
|
15
|
+
* consumers that don't extend design's stylesheet — and want unprefixed
|
|
16
|
+
* utilities (`flex`, not `tw-flex`) — can opt out with `createKeboolaConfig({ prefix: '' })`.
|
|
17
|
+
*
|
|
18
|
+
* @param {{ prefix?: string }} [options]
|
|
19
|
+
* @returns {import('tailwindcss').Config}
|
|
20
|
+
*/
|
|
21
|
+
export function createKeboolaConfig({ prefix = 'tw-' } = {}) {
|
|
22
|
+
return {
|
|
23
|
+
...baseConfig,
|
|
24
|
+
prefix,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
10
28
|
/** @type {import('tailwindcss').Config} */
|
|
11
|
-
|
|
12
|
-
prefix: 'tw-',
|
|
29
|
+
const baseConfig = {
|
|
13
30
|
content: ['./src/**/*.{js,jsx,ts,tsx,mdx}', '../../packages/design/src/**/*.{ts,tsx}'],
|
|
14
31
|
corePlugins: {
|
|
15
32
|
preflight: false,
|
|
@@ -178,3 +195,6 @@ export default {
|
|
|
178
195
|
scrollFadePlugin,
|
|
179
196
|
],
|
|
180
197
|
};
|
|
198
|
+
|
|
199
|
+
/** @type {import('tailwindcss').Config} */
|
|
200
|
+
export default createKeboolaConfig();
|
package/package.json
CHANGED
package/typography.ts
CHANGED
|
@@ -32,6 +32,7 @@ export const typography = {
|
|
|
32
32
|
fontSize: '32px',
|
|
33
33
|
lineHeight: '40px',
|
|
34
34
|
fontWeight: '500',
|
|
35
|
+
color: 'rgb(var(--color-foreground))',
|
|
35
36
|
marginTop: 0,
|
|
36
37
|
marginBottom: '10px',
|
|
37
38
|
},
|
|
@@ -42,7 +43,7 @@ export const typography = {
|
|
|
42
43
|
fontSize: '24px',
|
|
43
44
|
lineHeight: '32px',
|
|
44
45
|
fontWeight: '500',
|
|
45
|
-
color:
|
|
46
|
+
color: 'rgb(var(--color-foreground))',
|
|
46
47
|
marginTop: 0,
|
|
47
48
|
marginBottom: '10px',
|
|
48
49
|
},
|
|
@@ -53,21 +54,25 @@ export const typography = {
|
|
|
53
54
|
fontSize: '16px',
|
|
54
55
|
lineHeight: '24px',
|
|
55
56
|
fontWeight: '500',
|
|
56
|
-
color:
|
|
57
|
+
color: 'rgb(var(--color-foreground))',
|
|
57
58
|
margin: 0,
|
|
58
59
|
},
|
|
59
60
|
h4: {
|
|
60
61
|
fontSize: '14px',
|
|
61
62
|
lineHeight: '20px',
|
|
62
63
|
fontWeight: '500',
|
|
63
|
-
color:
|
|
64
|
+
color: 'rgb(var(--color-foreground))',
|
|
64
65
|
margin: 0,
|
|
65
66
|
},
|
|
66
67
|
h5: {
|
|
67
68
|
fontSize: '12px',
|
|
68
69
|
lineHeight: '20px',
|
|
69
70
|
fontWeight: '500',
|
|
70
|
-
color:
|
|
71
|
+
color: 'rgb(var(--color-foreground))',
|
|
72
|
+
margin: 0,
|
|
73
|
+
},
|
|
74
|
+
h6: {
|
|
75
|
+
color: 'rgb(var(--color-foreground))',
|
|
71
76
|
margin: 0,
|
|
72
77
|
},
|
|
73
78
|
'h1 small, h2 small, h3 small, h4 small, h5 small, h6 small': {
|