@pantheon-systems/pds-toolkit-react 2.0.0-alpha.7 → 2.0.0-alpha.9

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pantheon-systems/pds-toolkit-react",
3
3
  "technology": "React",
4
- "version": "2.0.0-alpha.7",
4
+ "version": "2.0.0-alpha.9",
5
5
  "description": "PDS toolkit built using the React framework",
6
6
  "publishConfig": {
7
7
  "access": "public",
@@ -27,10 +27,13 @@
27
27
  "types": "./dist/index.d.ts",
28
28
  "import": "./dist/index.js"
29
29
  },
30
+ "./tailwind/v3/preset": "./tailwind/v3/preset.cjs",
31
+ "./tailwind/v4/theme.css": "./tailwind/v4/theme.css",
30
32
  "./*": "./dist/*"
31
33
  },
32
34
  "files": [
33
- "dist"
35
+ "dist",
36
+ "tailwind"
34
37
  ],
35
38
  "sideEffects": [
36
39
  "*.css"
@@ -99,13 +102,13 @@
99
102
  "@csstools/postcss-design-tokens": "^2.0.4",
100
103
  "@csstools/postcss-global-data": "^1.0.3",
101
104
  "@playwright/test": "^1.36.2",
102
- "@storybook/addon-a11y": "^10.2.3",
103
- "@storybook/addon-docs": "^10.2.3",
104
- "@storybook/addon-links": "^10.2.3",
105
- "@storybook/addon-mcp": "^0.2.0",
105
+ "@storybook/addon-a11y": "^10.3.0",
106
+ "@storybook/addon-docs": "^10.3.0",
107
+ "@storybook/addon-links": "^10.3.0",
108
+ "@storybook/addon-mcp": "^0.5.0",
106
109
  "@storybook/addon-webpack5-compiler-swc": "^4.0.2",
107
- "@storybook/react-vite": "^10.2.3",
108
- "@storybook/react-webpack5": "^10.2.3",
110
+ "@storybook/react-vite": "^10.3.0",
111
+ "@storybook/react-webpack5": "^10.3.0",
109
112
  "@types/prismjs": "^1.26.5",
110
113
  "@types/react": "^19.2.2",
111
114
  "@typescript-eslint/eslint-plugin": "^8.47.0",
@@ -124,7 +127,7 @@
124
127
  "eslint-plugin-react": "^7.32.2",
125
128
  "eslint-plugin-simple-import-sort": "^12.1.1",
126
129
  "eslint-plugin-sort-destructure-keys": "^2.0.0",
127
- "eslint-plugin-storybook": "^10.2.3",
130
+ "eslint-plugin-storybook": "^10.3.0",
128
131
  "eslint-plugin-typescript-sort-keys": "^3.3.0",
129
132
  "fast-glob": "^3.3.2",
130
133
  "husky": "^8.0.3",
@@ -142,7 +145,8 @@
142
145
  "prettier-plugin-css-order": "^2.1.2",
143
146
  "react": "^18.2.0",
144
147
  "react-dom": "^18.2.0",
145
- "storybook": "^10.2.3",
148
+ "react-router-dom": "^6.13.0",
149
+ "storybook": "^10.3.0",
146
150
  "tsc-alias": "^1.8.16",
147
151
  "typescript": "^5.4.5",
148
152
  "vite": "^7.2.2",
@@ -172,7 +176,7 @@
172
176
  "react-code-block": "^1.1.1",
173
177
  "react-day-picker": "^9.11.1",
174
178
  "react-device-detect": "^2.2.3",
175
- "react-router-dom": "^6.13.0",
179
+ "react-hotkeys-hook": "^4.5.1",
176
180
  "react-toastify": "^9.0.3"
177
181
  },
178
182
  "optionalDependencies": {
@@ -0,0 +1,220 @@
1
+ # PDS Tailwind Configuration
2
+
3
+ Tailwind CSS configs that map Pantheon Design System tokens to Tailwind utilities. Available for both Tailwind v3 and v4.
4
+
5
+ > **Note:** Using Tailwind CSS alongside PDS is not the recommended approach. PDS components handle their own styling. This configuration is provided so that UI built outside the scope of PDS components uses correct design system values rather than arbitrary ones.
6
+
7
+ ---
8
+
9
+ ## Prerequisites
10
+
11
+ Both configs require `pds-core.css` to be loaded globally in your app. This provides the `--pds-*` CSS custom properties that the Tailwind utilities reference at runtime.
12
+
13
+ Import it as a JavaScript import in your app's root layout — this ensures reliable module resolution via the package `exports` map:
14
+
15
+ ```ts
16
+ import '@pantheon-systems/pds-toolkit-react/css/pds-core.css';
17
+ ```
18
+
19
+ > **Note:** Use `css/pds-core.css`, not `dist/css/pds-core.css`. The package exports map handles the `dist/` prefix automatically. Using a CSS `@import` instead of a JS import can cause resolution failures in some bundlers (including Next.js with Turbopack).
20
+
21
+ ---
22
+
23
+ ## Tailwind v4
24
+
25
+ **Recommended for new projects.**
26
+
27
+ ### Setup
28
+
29
+ In `app/layout.tsx` (or your root layout):
30
+
31
+ ```ts
32
+ import '@pantheon-systems/pds-toolkit-react/css/pds-core.css';
33
+ import './globals.css';
34
+ ```
35
+
36
+ In `app/globals.css`:
37
+
38
+ ```css
39
+ /* Tailwind layers — imported separately to exclude preflight */
40
+ @import 'tailwindcss/theme' layer(theme);
41
+ @import 'tailwindcss/utilities' layer(utilities);
42
+
43
+ /* PDS theme overrides */
44
+ @import '@pantheon-systems/pds-toolkit-react/tailwind/v4/theme.css';
45
+ ```
46
+
47
+ > **Why not `@import "tailwindcss"`?**
48
+ > The single `@import "tailwindcss"` shorthand includes Tailwind's preflight CSS reset, which conflicts with PDS base styles. Importing the layers individually lets you skip preflight.
49
+
50
+ No `tailwind.config.js` is needed.
51
+
52
+ ---
53
+
54
+ ## Tailwind v3
55
+
56
+ ### Setup
57
+
58
+ ```bash
59
+ npm install tailwindcss@3
60
+ ```
61
+
62
+ `tailwind.config.js`:
63
+
64
+ ```js
65
+ /** @type {import('tailwindcss').Config} */
66
+ module.exports = {
67
+ presets: [require('@pantheon-systems/pds-toolkit-react/tailwind/v3/preset')],
68
+ content: ['./src/**/*.{js,ts,jsx,tsx}'],
69
+ };
70
+ ```
71
+
72
+ In `app/layout.tsx` (or your root layout):
73
+
74
+ ```ts
75
+ import '@pantheon-systems/pds-toolkit-react/css/pds-core.css';
76
+ import './globals.css';
77
+ ```
78
+
79
+ `app/globals.css`:
80
+
81
+ ```css
82
+ /* Tailwind directives */
83
+ @tailwind base;
84
+ @tailwind components;
85
+ @tailwind utilities;
86
+ ```
87
+
88
+ Preflight is disabled automatically by the preset.
89
+
90
+ ---
91
+
92
+ ## What's included
93
+
94
+ ### Colors
95
+
96
+ All values reference PDS CSS custom properties — dark mode works automatically.
97
+
98
+ | Group | Example utility | PDS token |
99
+ | ------------------- | ------------------------------ | --------------------------------------- |
100
+ | `bg-*` | `bg-bg-default` | `--pds-color-bg-default` |
101
+ | `fg-*` | `text-fg-default` | `--pds-color-fg-default` |
102
+ | `text-*` | `text-text-secondary` | `--pds-color-text-default-secondary` |
103
+ | `border-*` | `border-border-input` | `--pds-color-border-input` |
104
+ | `interactive-*` | `text-interactive-link` | `--pds-color-interactive-link-default` |
105
+ | `status-{type}-*` | `bg-status-success-background` | `--pds-color-status-success-background` |
106
+ | `brand-primary-*` | `bg-brand-primary-400` | `--pds-color-brand-primary-400` |
107
+ | `brand-secondary-*` | `bg-brand-secondary` | `--pds-color-brand-secondary-default` |
108
+ | `brand-accent-*` | `text-brand-accent` | `--pds-color-brand-accent-default` |
109
+
110
+ ### Spacing
111
+
112
+ The PDS named scale replaces Tailwind's default numeric scale. Use semantic keys like `p-m`, `gap-xl`, `mt-2xl`.
113
+
114
+ ```html
115
+ <div class="p-m gap-xl mt-2xl">...</div>
116
+ ```
117
+
118
+ Common Tailwind numeric values are also aliased to their nearest PDS equivalent, so `p-4` still works and stays in sync with the token:
119
+
120
+ | Tailwind | PDS key | Value |
121
+ | -------- | ------- | ------- |
122
+ | `p-1` | `p-4xs` | 0.25rem |
123
+ | `p-2` | `p-2xs` | 0.5rem |
124
+ | `p-3` | `p-s` | 0.75rem |
125
+ | `p-4` | `p-m` | 1rem |
126
+ | `p-5` | `p-l` | 1.25rem |
127
+ | `p-6` | `p-xl` | 1.5rem |
128
+ | `p-8` | `p-2xl` | 2rem |
129
+ | `p-10` | `p-3xl` | 2.5rem |
130
+ | `p-12` | `p-4xl` | 3rem |
131
+ | `p-16` | `p-5xl` | 4rem |
132
+
133
+ Values like `p-7`, `p-9`, `p-11` (which don't have a clean PDS equivalent) are not aliased and will not generate any CSS.
134
+
135
+ > **Numeric aliases use CSS variable references**, not hardcoded values. If a PDS spacing token ever changes, `p-4` will automatically reflect the new value — no config update needed.
136
+
137
+ ### Typography
138
+
139
+ ```html
140
+ <p class="font-sans text-m font-normal leading-m">Body text</p>
141
+ <h2 class="font-sans text-2xl font-semibold leading-s">Heading</h2>
142
+ ```
143
+
144
+ | Scale | Font size | Font family | Font weight | Line height | Letter spacing |
145
+ | ----- | ------------ | ----------------------- | ----------------------------------------------- | ------------------- | ------------------- |
146
+ | Keys | `xs` – `9xl` | `sans`, `serif`, `mono` | `light`, `normal`, `medium`, `semibold`, `bold` | `s`, `m`, `l`, `xl` | `s`, `m`, `l`, `xl` |
147
+
148
+ ### Border radius
149
+
150
+ ```html
151
+ <div class="rounded-container">Card</div>
152
+ <button class="rounded-button">Button</button>
153
+ <input class="rounded-input" />
154
+ ```
155
+
156
+ Keys: `none`, `DEFAULT` (`rounded`), `button`, `input`, `container`, `bar`, `full`
157
+
158
+ ### Z-index
159
+
160
+ ```html
161
+ <div class="z-modal">Modal</div>
162
+ <nav class="z-navigation">Nav</nav>
163
+ ```
164
+
165
+ Keys: `navigation`, `dropdown`, `notifications`, `overlay`, `modal`, `max`
166
+
167
+ ### Max width
168
+
169
+ Matches PDS `Container` component breakpoints. Use when building layout sections outside PDS container components.
170
+
171
+ ```html
172
+ <div class="max-w-standard mx-auto px-m">...</div>
173
+ ```
174
+
175
+ Keys: `narrow` (1024px), `standard` (1200px), `wide` (1440px), `x-wide` (1600px)
176
+
177
+ ---
178
+
179
+ ## Important caveats
180
+
181
+ ### Borders require an explicit border-style
182
+
183
+ The PDS preset resets `border-style` to `none` on all elements so that borders are fully opt-in. This prevents phantom borders on elements that pick up a non-zero `border-width` from PDS components, inheritance, or browser defaults. When adding borders with Tailwind, always include a border-style class (`border-solid`, `border-dashed`, or `border-dotted`):
184
+
185
+ ```html
186
+ <div class="border border-solid border-border-default">...</div>
187
+ <div class="border-b border-solid border-border-separator">Divider</div>
188
+ ```
189
+
190
+ ### Opacity modifiers are not supported
191
+
192
+ Tailwind's opacity modifier syntax (`bg-bg-default/50`) does not work with CSS variable color references. This is a known Tailwind limitation — the compiler cannot decompose a CSS variable into RGB channels. Avoid using opacity modifiers with PDS colors.
193
+
194
+ ### Apply Tailwind utilities to your own elements, not PDS components
195
+
196
+ PDS components are styled with scoped BEM classes. Do not use Tailwind utilities to override PDS component styles — use component props and the `className` prop for layout adjustments only. Applying Tailwind utility classes to PDS component internals will lead to unpredictable results.
197
+
198
+ ```jsx
199
+ // ✅ Tailwind for your layout, PDS for the component
200
+ <div class="flex gap-m items-center">
201
+ <Button label="Save" variant="primary" />
202
+ </div>
203
+
204
+ // ❌ Don't override PDS component internals with Tailwind
205
+ <Button label="Save" className="text-red-500 bg-blue-200" />
206
+ ```
207
+
208
+ ### Import order matters
209
+
210
+ `pds-core.css` must be imported before Tailwind. If Tailwind's utilities load before PDS variables are defined, the CSS custom property references will resolve to empty values.
211
+
212
+ ### Scanning for class names (`@source` in v4)
213
+
214
+ Tailwind v4 automatically scans your project files for class names. If your source files are outside the default scan path (common in monorepos), add a `@source` directive to your CSS entry point:
215
+
216
+ ```css
217
+ @source './src/**/*.{js,ts,jsx,tsx}';
218
+ ```
219
+
220
+ This is your project's responsibility — the PDS package does not need to be scanned (PDS components do not use Tailwind class names internally).