Skip to content

Commit 66ac5f3

Browse files
committed
Enable Tailwind CSS
1 parent 3f53207 commit 66ac5f3

17 files changed

+1364
-1355
lines changed

.github/workflows/pull-request-jobs.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ name: Node.js CI
55

66
on:
77
pull_request:
8-
branches: [ master ]
8+
branches: ["master", "tailwind"]
99

1010
jobs:
1111
lint-test:

.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20
1+
v20

.stylelintrc

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@
1515
"at-rule-no-vendor-prefix": true,
1616
"selector-no-vendor-prefix": true,
1717
"max-nesting-depth": 3,
18-
"selector-max-compound-selectors": 5
18+
"selector-max-compound-selectors": 5,
19+
"at-rule-no-unknown": [
20+
true,
21+
{
22+
"ignoreAtRules": [
23+
"tailwind"
24+
]
25+
}
26+
]
1927
},
2028
"plugins": [
2129
"stylelint-order"

eslint.config.js

+2
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ import configReactJSXRuntime from 'eslint-plugin-react/configs/jsx-runtime.js';
1313
import pluginReactHooks from 'eslint-plugin-react-hooks';
1414
import {fixupPluginRules} from '@eslint/compat';
1515
import configPrettierRecommended from 'eslint-plugin-prettier/recommended';
16+
import tailwindPlugin from 'eslint-plugin-tailwindcss';
1617

1718
export default [
1819
eslint.configs.recommended,
1920
...eslintTS.configs.recommended,
2021
...eslintTS.configs.stylistic,
22+
...tailwindPlugin.configs['flat/recommended'],
2123
configReactRecommended,
2224
configReactJSXRuntime,
2325
configPrettierRecommended,

generate-react-cli.json

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"withHookTest": true,
1717
"customTemplates": {
1818
"component": "templates/Component/TemplateName.tsx",
19-
"style": "templates/Component/TemplateName.module.css",
2019
"story": "templates/Component/TemplateName.stories.tsx",
2120
"index": "templates/Component/index.ts",
2221
"mdx": "templates/Component/TemplateName.mdx",

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
"eslint-plugin-react-refresh": "0.4.19",
9292
"eslint-plugin-ssr-friendly": "1.3.0",
9393
"eslint-plugin-storybook": "0.11.3",
94+
"eslint-plugin-tailwindcss": "3.17.5",
9495
"generate-react-cli": "8.4.9",
9596
"husky": "9.1.7",
9697
"identity-obj-proxy": "3.0.0",
@@ -110,6 +111,7 @@
110111
"stylelint-config-standard": "36.0.1",
111112
"stylelint-order": "6.0.4",
112113
"stylelint-prettier": "5.0.3",
114+
"tailwindcss": "3.4.17",
113115
"ts-jest": "29.2.6",
114116
"ts-node": "10.9.2",
115117
"typescript": "5.8.2",

pnpm-lock.yaml

+1,309-1,271
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

postcss.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export default {
2+
plugins: {
3+
tailwindcss: {},
4+
'postcss-preset-env': {},
5+
},
6+
};

src/lib/CounterDemo/Counter.module.css

-33
This file was deleted.

src/lib/CounterDemo/Counter.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type {FC} from 'react';
22
import {useEffect} from 'react';
33
import {throttle} from 'lodash';
44

5-
import classes from './Counter.module.css';
65
import useLogic from './useLogic';
76

87
export type Props = {
@@ -21,9 +20,12 @@ export const Counter: FC<Props> = ({initialValue = 0}) => {
2120
}, []);
2221

2322
return (
24-
<div className={classes.counter}>
25-
<h2 className={classes.header}>Counter</h2>
26-
<button className={classes.button} type="button" onClick={incrementCount}>
23+
<div className="w-60 border border-slate-300 p-6 text-center">
24+
<h2 className="mb-3 text-2xl">Counter</h2>
25+
<button
26+
className="mb-6 rounded-lg bg-teal-600 px-6 py-3 text-base text-white drop-shadow-md active:relative active:left-0.5 active:top-0.5 active:drop-shadow-none"
27+
type="button"
28+
onClick={incrementCount}>
2729
Increment by one
2830
</button>
2931
<div>

src/lib/CounterDemo/__snapshots__/Counter.spec.tsx.snap

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@
22

33
exports[`lib > Counter renders without crashing 1`] = `
44
<DocumentFragment>
5-
<div>
6-
<h2>
5+
<div
6+
class="w-60 border border-slate-300 p-6 text-center"
7+
>
8+
<h2
9+
class="mb-3 text-2xl"
10+
>
711
Counter
812
</h2>
913
<button
14+
class="mb-6 rounded-lg bg-teal-600 px-6 py-3 text-base text-white drop-shadow-md active:relative active:left-0.5 active:top-0.5 active:drop-shadow-none"
1015
type="button"
1116
>
1217
Increment by one

src/lib/index.css

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
@tailwind base;
2+
@tailwind components;
3+
@tailwind utilities;

src/lib/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
import './index.css';
2+
13
export {Counter} from './CounterDemo';

tailwind.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// const defaultTheme = require('tailwindcss/defaultTheme');
2+
3+
/** @type {import('tailwindcss').Config} */
4+
export default {
5+
content: ['./index.html', './src/**/*.tsx'],
6+
theme: {
7+
extend: {},
8+
},
9+
plugins: [],
10+
};

templates/Component/TemplateName.module.css

-33
This file was deleted.

templates/Component/TemplateName.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import type {FC} from 'react';
22
import {useEffect} from 'react';
33
import {throttle} from 'lodash';
44

5-
import classes from './TemplateName.module.css';
65
import useLogic from './useLogic';
76

87
export type Props = {
@@ -20,9 +19,12 @@ export const TemplateName: FC<Props> = ({initialValue = 0}) => {
2019
runner();
2120
}, []);
2221
return (
23-
<div className={classes.templateName}>
24-
<h2 className={classes.header}>Counter</h2>
25-
<button className={classes.button} type="button" onClick={incrementCount}>
22+
<div className="w-60 border border-slate-300 p-6 text-center">
23+
<h2 className="mb-3 text-2xl">Counter</h2>
24+
<button
25+
className="mb-6 rounded-lg bg-teal-600 px-6 py-3 text-base text-white drop-shadow-md active:relative active:left-0.5 active:top-0.5 active:drop-shadow-none"
26+
type="button"
27+
onClick={incrementCount}>
2628
Increment by one
2729
</button>
2830
<div>

vite.config.ts

-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import react from '@vitejs/plugin-react';
55
import hq from 'alias-hq';
66
import external from '@yelo/rollup-node-external';
77
import dts from 'vite-plugin-dts';
8-
import postcssPresetEnv from 'postcss-preset-env';
98

109
// https://vitejs.dev/config/
1110
export default defineConfig({
@@ -39,8 +38,5 @@ export default defineConfig({
3938
modules: {
4039
localsConvention: 'camelCase',
4140
},
42-
postcss: {
43-
plugins: [postcssPresetEnv({stage: 1})],
44-
},
4541
},
4642
});

0 commit comments

Comments
 (0)