Skip to content

Commit 6d6493e

Browse files
committed
Update tailwind to v4
1 parent 484e14e commit 6d6493e

File tree

27 files changed

+1194
-596
lines changed

27 files changed

+1194
-596
lines changed

assets/js/indexeddb.worker.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/settings/MIGRATION.md

Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# Migration Guide: Tailwind CSS v4 & React Query v5.90.7
2+
3+
## Summary
4+
This package has been successfully migrated from Tailwind CSS v3.4.4 to v4.0.0 and React Query v5.45.0 to v5.90.7.
5+
6+
## Changes Made
7+
8+
### 1. Package Updates
9+
10+
#### Dependencies
11+
- `@tanstack/react-query`: `^5.45.0``^5.90.7`
12+
- `@headlessui/react`: `^2.0.4``^2.2.0`
13+
14+
#### Dev Dependencies
15+
- `tailwindcss`: `3.4.4``^4.0.0`
16+
- `@tailwindcss/postcss`: `^4.0.0` (new dependency)
17+
- `@tanstack/react-query-devtools`: `^5.45.0``^5.90.7`
18+
19+
### 2. Tailwind CSS v4 Migration
20+
21+
#### ⚠️ **MAJOR BREAKING CHANGE: Prefix Format**
22+
Tailwind v4 uses **colon (`:`)** instead of **hyphen (`-`)** for prefixes!
23+
24+
**Base Classes:**
25+
- **Before (v3)**: `wcpos-container`, `wcpos-mx-auto`, `wcpos-bg-white`
26+
- **After (v4)**: `wcpos:container`, `wcpos:mx-auto`, `wcpos:bg-white`
27+
28+
**Variant Classes (IMPORTANT!):**
29+
The prefix comes **BEFORE** the variant in v4:
30+
- **Before (v3)**: `sm:wcpos-text-sm`, `hover:wcpos-bg-gray-100`, `focus:wcpos-border-blue-500`
31+
- **After (v4)**: `wcpos:sm:text-sm`, `wcpos:hover:bg-gray-100`, `wcpos:focus:border-blue-500`
32+
33+
All **226+ occurrences across 19 files** were updated, including proper handling of variants!
34+
35+
#### PostCSS Configuration (`postcss.config.js`)
36+
- **Before**: `tailwindcss: {}`
37+
- **After**: `'@tailwindcss/postcss': {}`
38+
39+
The new Tailwind v4 uses a dedicated PostCSS plugin.
40+
41+
#### CSS Configuration (`src/index.css`)
42+
Migrated from JavaScript config to CSS-based theming with inline prefix:
43+
44+
```css
45+
@import "tailwindcss" prefix(wcpos);
46+
@config "../tailwind.config.js";
47+
48+
@theme {
49+
/* Custom colors for WordPress admin theme */
50+
--color-wp-admin-theme-color: var(--wp-admin-theme-color, #007cba);
51+
--color-wp-admin-theme-color-darker-10: var(--wp-admin-theme-color-darker-10, #006ba1);
52+
--color-wp-admin-theme-color-darker-20: var(--wp-admin-theme-color-darker-20, #005a87);
53+
--color-wp-admin-theme-color-lightest: #e5f1f8;
54+
--color-wp-admin-theme-black: #1d2327;
55+
}
56+
```
57+
58+
**Key Changes:**
59+
- Replaced `@tailwind` directives with `@import "tailwindcss" prefix(wcpos)`
60+
- Prefix is now configured in CSS, not JS config
61+
- Theme customizations now use `@theme` block with CSS variables
62+
- Color definitions follow the format: `--color-{name}: {value}`
63+
- Added `@config` directive to reference JS config for plugins
64+
65+
#### Tailwind Config (`tailwind.config.js`)
66+
Simplified configuration - removed prefix and content (now in CSS):
67+
68+
- Removed `prefix` (now in CSS via `prefix(wcpos)`)
69+
- Removed `content` (not needed in v4)
70+
- Removed `theme.extend.colors` (migrated to `@theme` in CSS)
71+
- Removed `variants` (no longer needed in v4)
72+
- Removed `corePlugins` (preflight is handled differently in v4)
73+
- Kept: `darkMode`, `plugins`
74+
75+
### 3. React Query v5.90.7 Migration
76+
77+
#### Removed Deprecated `suspense` Option (`src/index.tsx`)
78+
The `suspense: true` option in `QueryClient` defaultOptions is deprecated in React Query v5.
79+
80+
**Before:**
81+
```javascript
82+
const queryClient = new QueryClient({
83+
defaultOptions: {
84+
queries: {
85+
suspense: true,
86+
staleTime: 10 * 60 * 1000,
87+
},
88+
},
89+
});
90+
```
91+
92+
**After:**
93+
```javascript
94+
const queryClient = new QueryClient({
95+
defaultOptions: {
96+
queries: {
97+
staleTime: 10 * 60 * 1000,
98+
},
99+
},
100+
});
101+
```
102+
103+
#### Updated to `useSuspenseQuery` (`src/hooks/use-settings-api.tsx`)
104+
For queries that need suspense behavior, use the dedicated `useSuspenseQuery` hook:
105+
106+
**Before:**
107+
```javascript
108+
import { useQuery } from '@tanstack/react-query';
109+
const { data } = useQuery({ ... });
110+
```
111+
112+
**After:**
113+
```javascript
114+
import { useSuspenseQuery } from '@tanstack/react-query';
115+
const { data } = useSuspenseQuery({ ... });
116+
```
117+
118+
**Note:** The `user-select.tsx` component continues to use `useQuery` (not suspense) because it manages its own loading state with `isFetching`.
119+
120+
## Next Steps
121+
122+
1. **Install Dependencies**
123+
```bash
124+
pnpm install
125+
```
126+
127+
2. **Test the Build**
128+
```bash
129+
pnpm build
130+
```
131+
132+
3. **Test Development Mode**
133+
```bash
134+
pnpm start
135+
```
136+
137+
4. **Verify Functionality**
138+
- Check that all Tailwind classes with `wcpos-` prefix work correctly
139+
- Verify WordPress admin theme colors are applied
140+
- Test all settings screens load without errors
141+
- Confirm React Query suspense behavior works as expected
142+
143+
## Breaking Changes to Watch For
144+
145+
### Tailwind CSS v4
146+
- **Class name changes**: Some utility classes may have been renamed or removed
147+
- **Plugin compatibility**: Ensure `@headlessui/tailwindcss` plugin works with v4
148+
- **Custom CSS**: If you have custom CSS that references Tailwind internals, it may need updates
149+
150+
### React Query v5.90.7
151+
- **Suspense behavior**: Components wrapped in `<Suspense>` now need `useSuspenseQuery`
152+
- **Error boundaries**: Make sure error boundaries properly catch query errors
153+
- **Type safety**: TypeScript types have improved; you may see new type errors that were previously silent
154+
155+
## Rollback Instructions
156+
157+
If you need to rollback:
158+
159+
1. Restore `package.json` to previous versions:
160+
- `tailwindcss`: `^4.0.0``3.4.4`
161+
- `@tanstack/react-query`: `^5.90.7``^5.45.0`
162+
- Remove `@tailwindcss/postcss`
163+
2. Restore `postcss.config.js`: change `'@tailwindcss/postcss'` back to `tailwindcss`
164+
3. Restore `src/index.css`: replace `@import "tailwindcss" prefix(wcpos)` with `@tailwind` directives
165+
4. Restore `tailwind.config.js`: add back `prefix: 'wcpos-'`, `content`, `theme.extend.colors`, `corePlugins`
166+
5. **Revert all class names**: Replace `wcpos:` with `wcpos-` across all 19 TSX files (226 occurrences)
167+
6. Restore `src/index.tsx`: add back `suspense: true` in QueryClient config
168+
7. Restore `src/hooks/use-settings-api.tsx`: change `useSuspenseQuery` back to `useQuery`
169+
8. Run `pnpm install`
170+
171+
## Resources
172+
173+
- [Tailwind CSS v4 Documentation](https://tailwindcss.com/docs)
174+
- [Tailwind CSS v4 Upgrade Guide](https://tailwindcss.com/docs/upgrade-guide)
175+
- [TanStack Query v5 Migration Guide](https://tanstack.com/query/latest/docs/framework/react/guides/migrating-to-v5)
176+
- [useSuspenseQuery Documentation](https://tanstack.com/query/latest/docs/framework/react/reference/useSuspenseQuery)
177+

packages/settings/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
"start": "node_modules/.bin/webpack --watch"
66
},
77
"dependencies": {
8-
"@headlessui/react": "^2.0.4",
8+
"@headlessui/react": "^2.2.0",
99
"@headlessui/tailwindcss": "^0.2.1",
10-
"@tanstack/react-query": "^5.45.0",
10+
"@tanstack/react-query": "^5.90.7",
1111
"@transifex/native": "^7.1.1",
1212
"@transifex/react": "^7.1.1",
1313
"@wordpress/api-fetch": "7.0.0",
@@ -29,7 +29,8 @@
2929
"@babel/preset-typescript": "7.24.7",
3030
"@babel/runtime": "7.24.7",
3131
"@svgr/webpack": "8.1.0",
32-
"@tanstack/react-query-devtools": "^5.45.0",
32+
"@tailwindcss/postcss": "^4.0.0",
33+
"@tanstack/react-query-devtools": "^5.90.2",
3334
"@transifex/cli": "^7.1.1",
3435
"@types/jest": "29.5.12",
3536
"@types/lodash": "4.17.5",
@@ -59,7 +60,7 @@
5960
"prettier": "3.3.2",
6061
"sass-loader": "14.2.1",
6162
"style-loader": "4.0.0",
62-
"tailwindcss": "3.4.4",
63+
"tailwindcss": "^4.0.0",
6364
"terser-webpack-plugin": "5.3.10",
6465
"ts-loader": "^9.5.1",
6566
"typescript": "5.4.5",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module.exports = {
22
plugins: {
3-
tailwindcss: {},
3+
'@tailwindcss/postcss': {},
44
autoprefixer: {},
55
},
66
};

0 commit comments

Comments
 (0)