Skip to content

Commit 1ab319f

Browse files
committed
refactor!: separate CSS into modular theme and base styles (#185)
- Split monolithic index.css into modular structure - Introduced src/styles/theme.css for improved modularity - Move base styles to src/styles/index.css BREAKING CHANGE: CSS file structure has been reorganized
1 parent 969dba1 commit 1ab319f

4 files changed

Lines changed: 85 additions & 84 deletions

File tree

components.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"tsx": true,
66
"tailwind": {
77
"config": "",
8-
"css": "src/index.css",
8+
"css": "src/styles/index.css",
99
"baseColor": "slate",
1010
"cssVariables": true,
1111
"prefix": ""
@@ -18,4 +18,4 @@
1818
"hooks": "@/hooks"
1919
},
2020
"iconLibrary": "lucide"
21-
}
21+
}

src/main.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import { handleServerError } from '@/utils/handle-server-error'
1313
import { DirectionProvider } from './context/direction-context'
1414
import { FontProvider } from './context/font-context'
1515
import { ThemeProvider } from './context/theme-context'
16-
import './index.css'
1716
// Generated Routes
1817
import { routeTree } from './routeTree.gen'
18+
// Styles
19+
import './styles/index.css'
1920

2021
const queryClient = new QueryClient({
2122
defaultOptions: {

src/styles/index.css

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
@import 'tailwindcss';
2+
@import 'tw-animate-css';
3+
@import './theme.css';
4+
5+
@custom-variant dark (&:is(.dark *));
6+
7+
@layer base {
8+
* {
9+
@apply border-border outline-ring/50;
10+
scrollbar-width: thin;
11+
scrollbar-color: var(--border) transparent;
12+
}
13+
html {
14+
@apply overflow-x-hidden;
15+
}
16+
body {
17+
@apply bg-background text-foreground min-h-svh w-full;
18+
}
19+
20+
button:not(:disabled),
21+
[role='button']:not(:disabled) {
22+
cursor: pointer;
23+
}
24+
25+
/* Prevent focus zoom on mobile devices */
26+
@media screen and (max-width: 767px) {
27+
input,
28+
select,
29+
textarea {
30+
font-size: 16px !important;
31+
}
32+
}
33+
}
34+
35+
@utility container {
36+
margin-inline: auto;
37+
padding-inline: 2rem;
38+
}
39+
40+
@utility no-scrollbar {
41+
/* Hide scrollbar for Chrome, Safari and Opera */
42+
&::-webkit-scrollbar {
43+
display: none;
44+
}
45+
/* Hide scrollbar for IE, Edge and Firefox */
46+
-ms-overflow-style: none; /* IE and Edge */
47+
scrollbar-width: none; /* Firefox */
48+
}
49+
50+
@utility faded-bottom {
51+
@apply after:pointer-events-none after:absolute after:start-0 after:bottom-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_var(--background)_70%)] md:after:block;
52+
}
53+
54+
/* styles.css */
55+
.CollapsibleContent {
56+
overflow: hidden;
57+
}
58+
.CollapsibleContent[data-state='open'] {
59+
animation: slideDown 300ms ease-out;
60+
}
61+
.CollapsibleContent[data-state='closed'] {
62+
animation: slideUp 300ms ease-out;
63+
}
64+
65+
@keyframes slideDown {
66+
from {
67+
height: 0;
68+
}
69+
to {
70+
height: var(--radix-collapsible-content-height);
71+
}
72+
}
73+
74+
@keyframes slideUp {
75+
from {
76+
height: var(--radix-collapsible-content-height);
77+
}
78+
to {
79+
height: 0;
80+
}
81+
}

src/index.css renamed to src/styles/theme.css

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
@import 'tailwindcss';
2-
@import 'tw-animate-css';
3-
4-
@custom-variant dark (&:is(.dark *));
5-
61
:root {
72
--radius: 0.625rem;
83
--background: oklch(1 0 0);
@@ -105,79 +100,3 @@
105100
--color-sidebar-border: var(--sidebar-border);
106101
--color-sidebar-ring: var(--sidebar-ring);
107102
}
108-
109-
@layer base {
110-
* {
111-
@apply border-border outline-ring/50;
112-
scrollbar-width: thin;
113-
scrollbar-color: var(--border) transparent;
114-
}
115-
html {
116-
@apply overflow-x-hidden;
117-
}
118-
body {
119-
@apply bg-background text-foreground min-h-svh w-full;
120-
}
121-
122-
button:not(:disabled),
123-
[role='button']:not(:disabled) {
124-
cursor: pointer;
125-
}
126-
127-
/* Prevent focus zoom on mobile devices */
128-
@media screen and (max-width: 767px) {
129-
input,
130-
select,
131-
textarea {
132-
font-size: 16px !important;
133-
}
134-
}
135-
}
136-
137-
@utility container {
138-
margin-inline: auto;
139-
padding-inline: 2rem;
140-
}
141-
142-
@utility no-scrollbar {
143-
/* Hide scrollbar for Chrome, Safari and Opera */
144-
&::-webkit-scrollbar {
145-
display: none;
146-
}
147-
/* Hide scrollbar for IE, Edge and Firefox */
148-
-ms-overflow-style: none; /* IE and Edge */
149-
scrollbar-width: none; /* Firefox */
150-
}
151-
152-
@utility faded-bottom {
153-
@apply after:pointer-events-none after:absolute after:start-0 after:bottom-0 after:hidden after:h-32 after:w-full after:bg-[linear-gradient(180deg,_transparent_10%,_var(--background)_70%)] md:after:block;
154-
}
155-
156-
/* styles.css */
157-
.CollapsibleContent {
158-
overflow: hidden;
159-
}
160-
.CollapsibleContent[data-state='open'] {
161-
animation: slideDown 300ms ease-out;
162-
}
163-
.CollapsibleContent[data-state='closed'] {
164-
animation: slideUp 300ms ease-out;
165-
}
166-
167-
@keyframes slideDown {
168-
from {
169-
height: 0;
170-
}
171-
to {
172-
height: var(--radix-collapsible-content-height);
173-
}
174-
}
175-
176-
@keyframes slideUp {
177-
from {
178-
height: var(--radix-collapsible-content-height);
179-
}
180-
to {
181-
height: 0;
182-
}
183-
}

0 commit comments

Comments
 (0)