Skip to content

Commit d40e92f

Browse files
committed
feat: Setup tailwindcss and use it in Button component.
1 parent c1e22ed commit d40e92f

File tree

8 files changed

+281
-23
lines changed

8 files changed

+281
-23
lines changed

.prettierrc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
"tabWidth": 2,
55
"semi": false,
66
"singleQuote": true,
7-
"jsxBracketSameLine": true
8-
}
7+
"jsxBracketSameLine": true,
8+
"plugins": ["prettier-plugin-tailwindcss"],
9+
"tailwindStylesheet": "./src/assets/index.css"
10+
}

index.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@
77
<meta name="theme-color" content="#000000" />
88
<link rel="apple-touch-icon" href="/logo192.png" />
99
<link rel="preconnect" href="https://hackertab.dev" />
10+
<link href="/src/styles.css" rel="stylesheet" />
1011
<script src="/startup.js"></script>
1112

1213
<% if (isWebBuild) { %>
13-
<title>Hackertab</title>
14-
<link rel="manifest" href="/web_manifest.json" />
14+
<title>Hackertab</title>
15+
<link rel="manifest" href="/web_manifest.json" />
1516
<% } else { %>
16-
<title>New Tab</title>
17+
<title>New Tab</title>
1718
<%}%>
1819
</head>
1920
<body class="preload">
2021
<noscript>You need to enable JavaScript to run this app.</noscript>
2122
<div id="root"></div>
2223
<script type="module" src="/src/index.tsx"></script>
23-
2424
</body>
2525
</html>

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"private": false,
55
"dependencies": {
66
"@amplitude/analytics-browser": "^1.5.5",
7+
"@tailwindcss/vite": "^4.1.5",
78
"@tanstack/query-async-storage-persister": "^5.8.3",
89
"@tanstack/react-query": "^4.13.0",
910
"@tanstack/react-query-persist-client": "^5.8.4",
@@ -33,6 +34,7 @@
3334
"react-spring-bottom-sheet": "^3.4.1",
3435
"react-toggle": "^4.1.1",
3536
"react-tooltip": "^4.2.21",
37+
"tailwindcss": "^4.1.5",
3638
"timeago.js": "^4.0.2",
3739
"type-fest": "^1.2.0",
3840
"vite-plugin-ejs": "^1.6.4",
@@ -87,7 +89,8 @@
8789
"eslint-plugin-prettier": "^4.2.1",
8890
"eslint-plugin-react": "^7.28.0",
8991
"eslint-plugin-react-hooks": "^4.3.0",
90-
"prettier": "^2.7.1",
92+
"prettier": "^3.5.3",
93+
"prettier-plugin-tailwindcss": "^0.6.11",
9194
"terser": "^5.19.2",
9295
"typescript": "^5.1.6",
9396
"vite": "^6.2.4",

src/assets/App.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import 'variables.css';
1+
@import './variables.css';
22

33
html {
44
background: var(--background-color);

src/assets/index.css

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
@import 'variables.css';
1+
@import 'tailwindcss';
2+
@import './variables.css';
23

34
body {
45
margin: 0;
@@ -19,3 +20,12 @@ code {
1920
width: 100vw;
2021
display: flex;
2122
}
23+
24+
@custom-variant dark (&:where(.dark, .dark *));
25+
26+
@theme {
27+
--color-btn-background-color: var(--button-background-color);
28+
--color-btn-hover-background-color: var(--button-hover-background-color);
29+
--color-btn-text-color: var(--button-text-color);
30+
--color-btn-hover-text-color: var(--button-hover-text-color);
31+
}

src/components/Elements/Button/Button.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import clsx from 'clsx'
21
import React from 'react'
32
import { Spinner } from '../Spinner'
43
import './Button.css'
@@ -26,14 +25,8 @@ export const Button = ({
2625
isLoading = false,
2726
}: ButtonProps) => {
2827
return (
29-
<button
30-
className={clsx(
31-
'button',
32-
isLoading && 'loading',
33-
sizes[size],
34-
className,
35-
isLoading && 'disabled'
36-
)}
28+
<button
29+
className="gap-2 px-4 bg-btn-background-color py-2 rounded-full hover:bg-btn-hover-background-color text-btn-text-color hover:text-btn-hover-text-color cursor-pointer justify-center items-center"
3730
onClick={onClick}
3831
disabled={isLoading}>
3932
{isLoading ? <Spinner size="small" /> : startIcon}

vite.config.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import tailwindcss from '@tailwindcss/vite'
12
import react from '@vitejs/plugin-react'
23
import path from 'path'
34
import { defineConfig, loadEnv } from 'vite'
@@ -28,6 +29,7 @@ export default defineConfig(({ mode }) => {
2829
react(),
2930
viteTsconfigPaths(),
3031
svgrPlugin(),
32+
tailwindcss(),
3133
],
3234
define: {
3335
'process.env': {},

0 commit comments

Comments
 (0)