Skip to content

Commit eca03c7

Browse files
committed
refactor(cssints): replace tailwindcss with vanilla-extract
1 parent 6e45ae4 commit eca03c7

52 files changed

Lines changed: 2478 additions & 567 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/components/checkbox/playground.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button, Checkbox } from '@shilong/react'
1+
import { Button, Checkbox, Label } from '@shilong/react'
22
import { useState } from 'react'
33

44
function App() {
@@ -7,7 +7,10 @@ function App() {
77

88
return (
99
<>
10-
<Checkbox aria-invalid={error} disabled={disabled} />
10+
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
11+
<Checkbox aria-invalid={error} disabled={disabled} id="food" />
12+
<Label htmlFor="food">香蕉</Label>
13+
</div>
1114
<div style={{ marginTop: 20, display: 'flex', gap: 20 }}>
1215
<Button variant="destructive" onClick={() => setError(!error)}>
1316
Toggle Error

package.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
"publishConfig": {
3838
"access": "public"
3939
},
40+
"browserslist": [
41+
"> 0.5%",
42+
"not dead"
43+
],
4044
"scripts": {
4145
"build": "vite build",
4246
"dev": "vite build -w",
@@ -62,9 +66,15 @@
6266
"@types/node": "^22.15.17",
6367
"@types/react": "^19.1.3",
6468
"@types/react-dom": "^19.1.4",
69+
"@vanilla-extract/css": "^1.17.4",
70+
"@vanilla-extract/css-utils": "^0.1.6",
71+
"@vanilla-extract/vite-plugin": "^5.1.1",
6572
"@vitejs/plugin-react": "^4.4.1",
73+
"autoprefixer": "^10.4.21",
6674
"bumpp": "^10.1.0",
6775
"happy-dom": "^17.4.6",
76+
"postcss": "^8.5.6",
77+
"postcss-preset-env": "^10.2.4",
6878
"prettier": "^3.6.2",
6979
"prettier-plugin-tailwindcss": "^0.6.14",
7080
"react": "^19.1.0",

playground/src/App.tsx

Lines changed: 18 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,25 @@
1-
import { DataTable, Form, FormItem, Input } from '../../src'
1+
import { Button, Checkbox, Input, Label } from '../../src'
2+
import { useState } from 'react'
23

3-
export type Payment = {
4-
id: string
5-
amount: number
6-
status: 'pending' | 'processing' | 'success' | 'failed'
7-
email: string
8-
}
9-
10-
const data: Payment[] = [
11-
{
12-
id: 'm5gr84i9',
13-
amount: 316,
14-
status: 'success',
15-
email: 'ken99@example.com',
16-
},
17-
{
18-
id: '3u1reuv4',
19-
amount: 242,
20-
status: 'success',
21-
email: 'Abe45@example.com',
22-
},
23-
{
24-
id: 'derv1ws0',
25-
amount: 837,
26-
status: 'processing',
27-
email: 'Monserrat44@example.com',
28-
},
29-
{
30-
id: '5kma53ae',
31-
amount: 874,
32-
status: 'success',
33-
email: 'Silas22@example.com',
34-
},
35-
{
36-
id: 'bhqecj4p',
37-
amount: 721,
38-
status: 'failed',
39-
email: 'carmella@example.com',
40-
},
41-
]
42-
43-
export const columns: DataTable.ColumnDef<Payment>[] = [
44-
{
45-
accessorKey: 'id',
46-
header: 'ID',
47-
cell: ({ row }) => row.getValue('id'),
48-
},
49-
{
50-
accessorKey: 'status',
51-
header: 'Status',
52-
cell: ({ row }) => (
53-
<div className="capitalize">{row.getValue('status')}</div>
54-
),
55-
},
56-
{
57-
accessorKey: 'email',
58-
header: 'email',
59-
cell: ({ row }) => <div className="lowercase">{row.getValue('email')}</div>,
60-
},
61-
{
62-
accessorKey: 'amount',
63-
header: () => <div className="text-right">Amount</div>,
64-
cell: ({ row }) => {
65-
const amount = parseFloat(row.getValue('amount'))
66-
// Format the amount as a dollar amount
67-
const formatted = new Intl.NumberFormat('en-US', {
68-
style: 'currency',
69-
currency: 'USD',
70-
}).format(amount)
71-
return <div className="text-right font-medium">{formatted}</div>
72-
},
73-
},
74-
]
75-
76-
export function App() {
77-
const table = DataTable.useReactTable({
78-
data,
79-
columns,
80-
getCoreRowModel: DataTable.getCoreRowModel(),
81-
getFilteredRowModel: DataTable.getFilteredRowModel(),
82-
})
83-
84-
const handleSubmit = (v: { email?: string }) => {
85-
console.log(v?.email)
86-
table.getColumn('email')?.setFilterValue(v.email)
87-
}
4+
function App() {
5+
const [error, setError] = useState(false)
6+
const [disabled, setDisabled] = useState(false)
887

898
return (
90-
<div>
91-
<div>
92-
<Form onSubmit={handleSubmit}>
93-
<FormItem name="email" label="Email" render={<Input />} />
94-
</Form>
9+
<>
10+
<div style={{ display: 'flex', alignItems: 'center', gap: 10 }}>
11+
<Checkbox aria-invalid={error} disabled={disabled} id="food" />
12+
<Label htmlFor="food">香蕉</Label>
13+
<Input placeholder="nihao" />
9514
</div>
96-
<div>
97-
<DataTable.Table table={table} />
15+
<div style={{ marginTop: 20, display: 'flex', gap: 20 }}>
16+
<Button variant="destructive" onClick={() => setError(!error)}>
17+
Toggle Error
18+
</Button>
19+
<Button onClick={() => setDisabled(!disabled)}>Toggle disabled</Button>
9820
</div>
99-
</div>
21+
</>
10022
)
10123
}
24+
25+
export default App

playground/src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { StrictMode } from 'react'
22
import { createRoot } from 'react-dom/client'
3-
import { App } from './App'
3+
import App from './App'
4+
import '../../src/components/theme/theme.css'
45
import './style.css'
5-
import '../../src/global.css'
66

77
createRoot(document.querySelector('#app')!).render(
88
<StrictMode>

playground/src/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.testIcon {
2+
width: 20px;
3+
height: 20px;
4+
}
5+
6+
.test {
7+
height: 100px;
8+
}

playground/vite.config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import react from '@vitejs/plugin-react'
22
import { defineConfig } from 'vite'
33
import tailwindcss from '@tailwindcss/vite'
4+
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin'
45

56
export default defineConfig({
67
root: './playground',
7-
plugins: [react(), tailwindcss()],
8+
plugins: [
9+
react(),
10+
vanillaExtractPlugin({
11+
identifiers: ({ hash }) => `sl_${hash}`,
12+
}),
13+
],
814
})

0 commit comments

Comments
 (0)