@pantheon-systems/pds-toolkit-react 2.0.0-alpha.6 → 2.0.0-alpha.8
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/components/buttons/CloseButton/CloseButton.d.ts +2 -2
- package/dist/components/cards/Card/Card.d.ts +1 -1
- package/dist/components/notifications/Banner/Banner.d.ts +6 -2
- package/dist/components/notifications/SectionMessage/SectionMessage.d.ts +6 -2
- package/dist/components/notifications/Toaster/Toaster.d.ts +2 -2
- package/dist/css/component-css/pds-banner.css +1 -1
- package/dist/css/component-css/pds-card.css +1 -1
- package/dist/css/component-css/pds-index.css +2 -2
- package/dist/css/component-css/pds-section-message.css +1 -1
- package/dist/css/component-css/pds-toaster.css +1 -1
- package/dist/css/pds-components.css +2 -2
- package/dist/css/pds-core.css +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1203 -1179
- package/dist/index.js.map +1 -1
- package/dist/libs/types/custom-types.d.ts +1 -0
- package/package.json +15 -11
- package/tailwind/README.md +211 -0
- package/tailwind/TESTING.md +457 -0
- package/tailwind/v3/preset.cjs +238 -0
- package/tailwind/v4/theme.css +211 -0
|
@@ -5,6 +5,7 @@ export type ButtonSize = 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
|
5
5
|
export type ButtonType = 'button' | 'submit' | 'reset';
|
|
6
6
|
export type ButtonVariant = 'primary' | 'secondary' | 'subtle' | 'brand' | 'accent' | 'reverse' | 'reverse-secondary' | 'critical' | 'critical-secondary' | 'navbar' | 'inline';
|
|
7
7
|
export type ContainerWidth = 'narrow' | 'standard' | 'wide' | 'x-wide' | 'full';
|
|
8
|
+
export type DataContext = 'product' | 'marketing';
|
|
8
9
|
export type Display = 'block' | 'inline' | 'inline-block' | 'flex' | 'inline-flex' | 'grid' | 'inline-grid' | 'flow-root' | 'none' | 'contents' | 'table' | 'table-row' | 'table-cell' | 'table-caption' | 'table-column' | 'table-column-group' | 'table-footer-group' | 'table-header-group' | 'table-row-group' | 'list-item' | 'inherit' | 'initial' | 'revert' | 'unset';
|
|
9
10
|
export type StatusType = 'info' | 'success' | 'warning' | 'critical' | 'discovery';
|
|
10
11
|
export type StatusTypeExtended = StatusType | 'neutral' | 'working';
|
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.
|
|
4
|
+
"version": "2.0.0-alpha.8",
|
|
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.
|
|
103
|
-
"@storybook/addon-docs": "^10.
|
|
104
|
-
"@storybook/addon-links": "^10.
|
|
105
|
-
"@storybook/addon-mcp": "^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.
|
|
108
|
-
"@storybook/react-webpack5": "^10.
|
|
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.
|
|
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
|
-
"
|
|
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-
|
|
179
|
+
"react-hotkeys-hook": "^4.5.1",
|
|
176
180
|
"react-toastify": "^9.0.3"
|
|
177
181
|
},
|
|
178
182
|
"optionalDependencies": {
|
|
@@ -0,0 +1,211 @@
|
|
|
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
|
+
### Opacity modifiers are not supported
|
|
182
|
+
|
|
183
|
+
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.
|
|
184
|
+
|
|
185
|
+
### Apply Tailwind utilities to your own elements, not PDS components
|
|
186
|
+
|
|
187
|
+
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.
|
|
188
|
+
|
|
189
|
+
```jsx
|
|
190
|
+
// ✅ Tailwind for your layout, PDS for the component
|
|
191
|
+
<div class="flex gap-m items-center">
|
|
192
|
+
<Button label="Save" variant="primary" />
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
// ❌ Don't override PDS component internals with Tailwind
|
|
196
|
+
<Button label="Save" className="text-red-500 bg-blue-200" />
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Import order matters
|
|
200
|
+
|
|
201
|
+
`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.
|
|
202
|
+
|
|
203
|
+
### Scanning for class names (`@source` in v4)
|
|
204
|
+
|
|
205
|
+
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:
|
|
206
|
+
|
|
207
|
+
```css
|
|
208
|
+
@source './src/**/*.{js,ts,jsx,tsx}';
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
This is your project's responsibility — the PDS package does not need to be scanned (PDS components do not use Tailwind class names internally).
|