Skip to content

Commit 921da09

Browse files
committed
Update to Tailwind 3; support normal tailwind usage without twin.macro
1 parent 21ca91a commit 921da09

File tree

9 files changed

+1261
-466
lines changed

9 files changed

+1261
-466
lines changed

.babel-plugin-macrosrc.js

Lines changed: 0 additions & 11 deletions
This file was deleted.

package.json

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"@fortawesome/fontawesome-svg-core": "^1.2.32",
55
"@fortawesome/free-solid-svg-icons": "^5.15.1",
66
"@fortawesome/react-fontawesome": "^0.1.11",
7-
"@tailwindcss/forms": "^0.2.1",
7+
"@tailwindcss/forms": "^0.5.2",
88
"axios": "^0.21.1",
99
"chart.js": "^2.8.0",
1010
"codemirror": "^5.57.0",
@@ -34,7 +34,7 @@
3434
"styled-components": "^5.2.1",
3535
"styled-components-breakpoint": "^3.0.0-preview.20",
3636
"swr": "^0.2.3",
37-
"tailwindcss": "^2.0.2",
37+
"tailwindcss": "^3.0.24",
3838
"uuid": "^3.3.2",
3939
"xterm": "^4.15.0",
4040
"xterm-addon-attach": "^0.6.0",
@@ -78,11 +78,11 @@
7878
"@types/yup": "^0.29.3",
7979
"@typescript-eslint/eslint-plugin": "^4.25.0",
8080
"@typescript-eslint/parser": "^4.25.0",
81-
"autoprefixer": "^10.1.0",
82-
"babel-loader": "^8.0.6",
83-
"babel-plugin-styled-components": "^1.12.0",
81+
"autoprefixer": "^10.4.7",
82+
"babel-loader": "^8.2.5",
83+
"babel-plugin-styled-components": "^2.0.7",
8484
"cross-env": "^7.0.2",
85-
"css-loader": "^3.2.1",
85+
"css-loader": "^5.2.7",
8686
"eslint": "^7.27.0",
8787
"eslint-config-standard": "^16.0.3",
8888
"eslint-plugin-import": "^2.23.3",
@@ -91,14 +91,18 @@
9191
"eslint-plugin-react": "^7.23.2",
9292
"eslint-plugin-react-hooks": "^4.2.0",
9393
"fork-ts-checker-webpack-plugin": "^6.2.10",
94-
"postcss": "^8.2.1",
94+
"postcss": "^8.4.14",
95+
"postcss-import": "^14.1.0",
96+
"postcss-loader": "^4.0.0",
97+
"postcss-nesting": "^10.1.8",
98+
"postcss-preset-env": "^7.7.1",
9599
"redux-devtools-extension": "^2.13.8",
96-
"source-map-loader": "^1.0.1",
97-
"style-loader": "^1.2.1",
98-
"svg-url-loader": "^6.0.0",
99-
"terser-webpack-plugin": "^3.0.6",
100+
"source-map-loader": "^1.1.3",
101+
"style-loader": "^2.0.0",
102+
"svg-url-loader": "^7.1.1",
103+
"terser-webpack-plugin": "^4.2.3",
100104
"ts-essentials": "^9.1.2",
101-
"twin.macro": "^2.0.7",
105+
"twin.macro": "^2.8.2",
102106
"typescript": "^4.2.4",
103107
"webpack": "^4.43.0",
104108
"webpack-assets-manifest": "^3.1.1",
@@ -120,5 +124,15 @@
120124
"last 2 versions",
121125
"firefox esr",
122126
"not dead"
123-
]
127+
],
128+
"babelMacros": {
129+
"twin": {
130+
"preset": "styled-components"
131+
},
132+
"styledComponents": {
133+
"pure": true,
134+
"displayName": true,
135+
"fileName": true
136+
}
137+
}
124138
}

postcss.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module.exports = {
2+
plugins: [
3+
require('postcss-import'),
4+
// We want to make use of nesting following the CSS Nesting spec, and not the
5+
// SASS style nesting.
6+
//
7+
// @see https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting
8+
require('tailwindcss/nesting')(require('postcss-nesting')),
9+
require('tailwindcss'),
10+
require('autoprefixer'),
11+
require('postcss-preset-env')({
12+
features: {
13+
'nesting-rules': false,
14+
},
15+
}),
16+
],
17+
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

resources/scripts/components/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import AuthenticationRouter from '@/routers/AuthenticationRouter';
99
import { SiteSettings } from '@/state/settings';
1010
import ProgressBar from '@/components/elements/ProgressBar';
1111
import { NotFound } from '@/components/elements/ScreenBlock';
12-
import tw, { GlobalStyles as TailwindGlobalStyles } from 'twin.macro';
12+
import tw from 'twin.macro';
1313
import GlobalStylesheet from '@/assets/css/GlobalStylesheet';
1414
import { history } from '@/components/history';
1515
import { setupInterceptors } from '@/api/interceptors';
1616
import AuthenticatedRoute from '@/components/elements/AuthenticatedRoute';
1717
import { ServerContext } from '@/state/server';
18+
import '@/assets/tailwind.css';
1819

1920
interface ExtendedWindow extends Window {
2021
SiteConfiguration?: SiteSettings;
@@ -56,7 +57,6 @@ const App = () => {
5657
return (
5758
<>
5859
<GlobalStylesheet/>
59-
<TailwindGlobalStyles/>
6060
<StoreProvider store={store}>
6161
<ProgressBar/>
6262
<div css={tw`mx-auto w-auto`}>

resources/scripts/index.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import App from '@/components/App';
44
import './i18n';
55
import { setConfig } from 'react-hot-loader';
66

7-
import 'tailwindcss/dist/base.min.css';
8-
97
// Prevents page reloads while making component changes which
108
// also avoids triggering constant loading indicators all over
119
// the place in development.

tailwind.config.js

Lines changed: 33 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,36 @@
1+
const colors = require('tailwindcss/colors');
2+
3+
const gray = {
4+
50: 'hsl(216, 33%, 97%)',
5+
100: 'hsl(214, 15%, 91%)',
6+
200: 'hsl(210, 16%, 82%)',
7+
300: 'hsl(211, 13%, 65%)',
8+
400: 'hsl(211, 10%, 53%)',
9+
500: 'hsl(211, 12%, 43%)',
10+
600: 'hsl(209, 14%, 37%)',
11+
700: 'hsl(209, 18%, 30%)',
12+
800: 'hsl(209, 20%, 25%)',
13+
900: 'hsl(210, 24%, 16%)',
14+
};
15+
116
module.exports = {
17+
content: [
18+
'./resources/scripts/**/*.{js,ts,tsx}',
19+
],
220
theme: {
3-
fontFamily: {
4-
sans: [ 'Rubik', '-apple-system', 'BlinkMacSystemFont', '"Helvetica Neue"', '"Roboto"', 'system-ui', 'sans-serif' ],
5-
header: [ '"IBM Plex Sans"', '"Roboto"', 'system-ui', 'sans-serif' ],
6-
mono: [ '"IBM Plex Mono"', '"Source Code Pro"', 'SourceCodePro', 'Menlo', 'Monaco', 'Consolas', 'monospace' ],
7-
},
8-
colors: {
9-
transparent: 'transparent',
10-
black: 'hsl(210, 27%, 10%)',
11-
white: '#ffffff',
12-
primary: {
13-
50: 'hsl(202, 100%, 95%)', // lightest
14-
100: 'hsl(204, 100%, 86%)', // lighter
15-
200: 'hsl(206, 93%, 73%)',
16-
300: 'hsl(208, 88%, 62%)',
17-
400: 'hsl(210, 83%, 53%)', // light
18-
500: 'hsl(212, 92%, 43%)', // base
19-
600: 'hsl(214, 95%, 36%)', // dark
20-
700: 'hsl(215, 96%, 32%)',
21-
800: 'hsl(216, 98%, 25%)', // darker
22-
900: 'hsl(218, 100%, 17%)', // darkest
23-
},
24-
neutral: {
25-
50: 'hsl(216, 33%, 97%)',
26-
100: 'hsl(214, 15%, 91%)',
27-
200: 'hsl(210, 16%, 82%)',
28-
300: 'hsl(211, 13%, 65%)',
29-
400: 'hsl(211, 10%, 53%)',
30-
500: 'hsl(211, 12%, 43%)',
31-
600: 'hsl(209, 14%, 37%)',
32-
700: 'hsl(209, 18%, 30%)',
33-
800: 'hsl(209, 20%, 25%)',
34-
900: 'hsl(210, 24%, 16%)',
35-
},
36-
red: {
37-
50: 'hsl(360, 100%, 95%)',
38-
100: 'hsl(360, 100%, 87%)',
39-
200: 'hsl(360, 100%, 80%)',
40-
300: 'hsl(360, 91%, 69%)',
41-
400: 'hsl(360, 83%, 62%)',
42-
500: 'hsl(356, 75%, 53%)',
43-
600: 'hsl(354, 85%, 44%)',
44-
700: 'hsl(352, 90%, 35%)',
45-
800: 'hsl(350, 94%, 28%)',
46-
900: 'hsl(348, 94%, 20%)',
47-
},
48-
yellow: {
49-
50: 'hsl(49, 100%, 96%)',
50-
100: 'hsl(48, 100%, 88%)',
51-
200: 'hsl(48, 95%, 76%)',
52-
300: 'hsl(48, 94%, 68%)',
53-
400: 'hsl(44, 92%, 63%)',
54-
500: 'hsl(42, 87%, 55%)',
55-
600: 'hsl(36, 77%, 49%)',
56-
700: 'hsl(29, 80%, 44%)',
57-
800: 'hsl(22, 82%, 39%)',
58-
900: 'hsl(15, 86%, 30%)',
59-
},
60-
cyan: {
61-
50: 'hsl(171, 82%, 94%)',
62-
100: 'hsl(172, 97%, 88%)',
63-
200: 'hsl(174, 96%, 78%)',
64-
300: 'hsl(176, 87%, 67%)',
65-
400: 'hsl(178, 78%, 57%)',
66-
500: 'hsl(180, 77%, 47%)',
67-
600: 'hsl(182, 85%, 39%)',
68-
700: 'hsl(184, 90%, 34%)',
69-
800: 'hsl(186, 91%, 29%)',
70-
900: 'hsl(188, 91%, 23%)',
71-
},
72-
green: {
73-
50: 'hsl(125, 65%, 93%)',
74-
100: 'hsl(127, 65%, 85%)',
75-
200: 'hsl(124, 63%, 74%)',
76-
300: 'hsl(123, 53%, 55%)',
77-
400: 'hsl(123, 57%, 45%)',
78-
500: 'hsl(122, 73%, 35%)',
79-
600: 'hsl(122, 80%, 29%)',
80-
700: 'hsl(125, 79%, 26%)',
81-
800: 'hsl(125, 86%, 20%)',
82-
900: 'hsl(125, 97%, 14%)',
83-
},
84-
},
8521
extend: {
22+
fontFamily: {
23+
header: ['"IBM Plex Sans"', '"Roboto"', 'system-ui', 'sans-serif'],
24+
},
25+
colors: {
26+
black: '#131a20',
27+
// "primary" and "neutral" are deprecated, prefer the use of "blue" and "gray"
28+
// in new code.
29+
primary: colors.blue,
30+
gray: gray,
31+
neutral: gray,
32+
cyan: colors.cyan,
33+
},
8634
fontSize: {
8735
'2xs': '0.625rem',
8836
},
@@ -95,6 +43,8 @@ module.exports = {
9543
},
9644
},
9745
plugins: [
98-
require('@tailwindcss/forms'),
46+
require('@tailwindcss/forms')({
47+
strategy: 'class',
48+
}),
9949
]
10050
};

webpack.config.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,30 @@ module.exports = {
2626
rules: [
2727
{
2828
test: /\.tsx?$/,
29-
exclude: /node_modules/,
29+
exclude: /node_modules|\.spec\.tsx?$/,
3030
loader: 'babel-loader',
3131
},
3232
{
3333
test: /\.css$/,
34-
use: [ 'style-loader', 'css-loader' ],
34+
use: [
35+
{ loader: 'style-loader' },
36+
{
37+
loader: 'css-loader',
38+
options: {
39+
modules: {
40+
auto: true,
41+
localIdentName: isProduction ? '[name]_[hash:base64:8]' : '[path][name]__[local]',
42+
localIdentContext: path.join(__dirname, 'resources/scripts/components'),
43+
},
44+
sourceMap: !isProduction,
45+
importLoaders: 1,
46+
},
47+
},
48+
{
49+
loader: 'postcss-loader',
50+
options: { sourceMap: !isProduction },
51+
},
52+
],
3553
},
3654
{
3755
test: /\.(png|jp(e?)g|gif)$/,

0 commit comments

Comments
 (0)