Skip to content

Commit 9b114a0

Browse files
authored
Merge pull request #60 from ut-code/setup-daisyui
DaisyUI の導入と基礎的な色の移行 (細かいコンポネントは確認する手段がないので今後)
2 parents 8abfe01 + b0674aa commit 9b114a0

File tree

16 files changed

+225
-262
lines changed

16 files changed

+225
-262
lines changed

biome.jsonc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"includes": [
1111
"**/*",
1212
"!packages/class_data/data/**",
13-
"!packages/web/src/app/globals.css",
14-
"!packages/web/src/styles/globals.css"
13+
"!packages/web/src/app.css"
1514
]
1615
},
1716
"formatter": {

bun.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"@types/react": "^19.0.5",
3838
"@types/react-dom": "^19.0.5",
3939
"@vitejs/plugin-react": "^4.3.4",
40+
"daisyui": "^5.0.46",
4041
"postcss": "^8.5.6",
4142
"tailwindcss": "^4.1.11",
4243
"typescript": "^5.8.3",
@@ -315,6 +316,8 @@
315316

316317
"csstype": ["[email protected]", "", {}, "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw=="],
317318

319+
"daisyui": ["[email protected]", "", {}, "sha512-vMDZK1tI/bOb2Mc3Mk5WpquBG3ZqBz1YKZ0xDlvpOvey60dOS4/5Qhdowq1HndbQl7PgDLDYysxAjjUjwR7/eQ=="],
320+
318321
"debug": ["[email protected]", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ=="],
319322

320323
"detect-libc": ["[email protected]", "", {}, "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA=="],

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"packages/*"
77
],
88
"scripts": {
9-
"dev": "bun --filter=@packages/web dev",
10-
"dev:mock": "bun --filter=@packages/web dev:mock",
9+
"dev": "cd packages/web && bun dev",
10+
"dev:mock": "cd packages/web && bun dev:mock",
1111
"build": "cd packages/web && bun run build",
1212
"check": "bunx biome check .",
1313
"fix": "bunx biome check . --fix"

packages/web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>シ楽バス</title>
88
</head>
9-
<body>
9+
<body data-theme="light">
1010
<div id="root"></div>
1111
<script type="module" src="/src/main.tsx"></script>
1212
</body>

packages/web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"@types/react": "^19.0.5",
2525
"@types/react-dom": "^19.0.5",
2626
"@vitejs/plugin-react": "^4.3.4",
27+
"daisyui": "^5.0.46",
2728
"postcss": "^8.5.6",
2829
"tailwindcss": "^4.1.11",
2930
"typescript": "^5.8.3",

packages/web/src/App.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from "react";
1+
import { useEffect, useState } from "react";
22
import { BrowserRouter, Route, Routes } from "react-router-dom";
33

44
import { ThemeContext } from "@/app/context";
@@ -26,6 +26,10 @@ export default function App() {
2626
* テーマ管理
2727
*/
2828
const [theme, setTheme] = useState<ThemeType>("light");
29+
// the only proper use of useEffect
30+
useEffect(() => {
31+
document.body.setAttribute("data-theme", theme);
32+
}, [theme]);
2933

3034
const userInstance = new User();
3135
const [user, setUserState] = useState<RegisterType | undefined>(
@@ -45,9 +49,7 @@ export default function App() {
4549
return (
4650
<ThemeContext.Provider value={{ theme, setTheme }}>
4751
<UserContext.Provider value={userContextValue}>
48-
<div
49-
className={`bg-surface-container text-text-default ${theme} min-h-screen`}
50-
>
52+
<div className={`bg-surface-container text-text-default min-h-screen`}>
5153
<BrowserRouter>
5254
<div className="overscroll-none min-width-[300px] pt-12 pb-12">
5355
<Header />

packages/web/src/app.css

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
/*
2+
# メモ
3+
4+
## 過去の色の定義
5+
6+
色の定義はけっこう消えてるので、必要であれば git の履歴から復元すること。
7+
8+
## `--color-primary`, `--color-primary-content` の違い
9+
10+
`--color-primary` は背景色、`--color-primary-content` は文字色に使われる。
11+
12+
例:
13+
<button class="btn btn-primary">Primary</button>
14+
<button style="background-color: var(--color-primary); color: var(--color-primary-content);">Primary</button>
15+
*/
16+
17+
@import "tailwindcss";
18+
19+
@source "../";
20+
21+
@plugin "daisyui" {
22+
themes: "light" --default, "dark" --prefersdark;
23+
}
24+
25+
@plugin "daisyui/theme" {
26+
name: "light";
27+
default: true; /* set as default */
28+
prefersdark: false; /* set as default dark mode (prefers-color-scheme:dark) */
29+
color-scheme: light; /* color of browser-provided UI */
30+
31+
--color-base-100: #f6fbf3; /* ほとんどの背景色 */
32+
--color-base-200: #96d5a6; /* ヘッダーなど */
33+
--color-base-300: #96d5a6; /* フッターなど */
34+
--color-base-content: #181d18;
35+
36+
--color-primary: #2e6a44;
37+
--color-primary-content: #ffffff;
38+
--color-primary-container: #b1f1c1;
39+
40+
--color-secondary: #4f6353;
41+
--color-secondary-content: #ffffff;
42+
--color-secondary-container: #d2e8d4;
43+
44+
--color-tertiary: #3a646f;
45+
--color-tertiary-content: #ffffff;
46+
--color-tertiary-container: #beeaf6;
47+
48+
--color-error: #ba1a1a;
49+
--color-error-content: #ffffff;
50+
--color-error-container: #ffdad6;
51+
52+
--color-background: #f6fbf3;
53+
--color-on-background: #181d18;
54+
--color-surface: #f6fbf3;
55+
--color-on-surface: #181d18;
56+
--color-surface-variant: #dde5db;
57+
--color-on-surface-variant: #414942;
58+
--color-outline: #717971;
59+
--color-outline-variant: #c1c9bf;
60+
--color-shadow: #000000;
61+
--color-scrim: #000000;
62+
--color-inverse-surface: #2c322d;
63+
--color-inverse-on-surface: #edf2eb;
64+
--color-primary-fixed: #b1f1c1;
65+
--color-on-primary-fixed: #00210e;
66+
--color-primary-fixed-dim: #96d5a6;
67+
--color-on-primary-fixed-variant: #12512e;
68+
--color-secondary-fixed: #d2e8d4;
69+
--color-on-secondary-fixed: #0d1f13;
70+
--color-secondary-fixed-dim: #b6ccb8;
71+
--color-on-secondary-fixed-variant: #384b3c;
72+
--color-tertiary-fixed: #beeaf6;
73+
--color-on-tertiary-fixed: #001f26;
74+
--color-tertiary-fixed-dim: #a2ceda;
75+
--color-on-tertiary-fixed-variant: #214c57;
76+
--color-surface-dim: #d7dbd4;
77+
--color-surface-bright: #f6fbf3;
78+
--color-surface-container-lowest: #ffffff;
79+
--color-surface-container-low: #f0f5ed;
80+
--color-surface-container: #eaefe8;
81+
--color-surface-container-high: #e5eae2;
82+
--color-surface-container-highest: #dfe4dc;
83+
--color-text-default: #000000;
84+
}
85+
86+
/* 色の定義(ダークモード) */
87+
@plugin "daisyui/theme" {
88+
name: "dark";
89+
default: false; /* set as default */
90+
prefersdark: true; /* set as default dark mode (prefers-color-scheme:dark) */
91+
color-scheme: dark; /* color of browser-provided UI */
92+
93+
--color-base-100: #181d18; /* ほとんどの背景色 */
94+
--color-base-200: #052920; /* ヘッダーなど */
95+
--color-base-300: #275A3F; /* フッターなど */
96+
--color-base-content: #ffffff;
97+
98+
--color-primary: #96d5a6;
99+
--color-primary-content: #000000;
100+
--color-primary-container: #12512e; /* color-primary との使い分け何?不明だったら消す */
101+
102+
--color-secondary: #b6ccb8;
103+
--color-secondary-content: #223527;
104+
--color-secondary-container: #384b3c; /* 同上 */
105+
106+
--color-tertiary: #a2ceda;
107+
--color-tertiary-content: #023640;
108+
--color-tertiary-container: #214c57; /* 同上 */
109+
110+
--color-error: #ffb4ab;
111+
--color-error-content: #690005;
112+
--color-error-container: #93000a; /* 同上 */
113+
114+
/* ユースケース別の色をテーマで決めるのはアンチパターンなので、そのうち整理する (決して面倒で放置しているわけではない) */
115+
--color-background: #101510;
116+
--color-on-background: #dfe4dc;
117+
--color-surface: #101510;
118+
--color-on-surface: #dfe4dc;
119+
--color-surface-variant: #414942;
120+
--color-on-surface-variant: #c1c9bf;
121+
--color-outline: #8b938a;
122+
--color-outline-variant: #414942;
123+
--color-shadow: 0 0 0;
124+
--color-scrim: 0 0 0;
125+
--color-inverse-surface: #dfe4dc;
126+
--color-inverse-on-surface: #2c322d;
127+
--color-primary-fixed: #b1f1c1;
128+
--color-on-primary-fixed: #00210e;
129+
--color-primary-fixed-dim: #96d5a6;
130+
--color-on-primary-fixed-variant: #12512e;
131+
--color-secondary-fixed: #d2e8d4;
132+
--color-on-secondary-fixed: #0d1f13;
133+
--color-secondary-fixed-dim: #b6ccb8;
134+
--color-on-secondary-fixed-variant: #384b3c;
135+
--color-tertiary-fixed: #beeaf6;
136+
--color-on-tertiary-fixed: #001f26;
137+
--color-tertiary-fixed-dim: #a2ceda;
138+
--color-on-tertiary-fixed-variant: #214c57;
139+
--color-surface-dim: #101510;
140+
--color-surface-bright: #353a35;
141+
--color-surface-container-lowest: #0a0f0b;
142+
--color-surface-container-low: #181d18;
143+
--color-surface-container: #1c211c;
144+
--color-surface-container-high: #262b26;
145+
--color-surface-container-highest: #313631;
146+
--color-text-default: #ffffff;
147+
}
148+
149+
/*
150+
The default border color has changed to `currentcolor` in Tailwind CSS v4,
151+
so we've added these compatibility styles to make sure everything still
152+
looks the same as it did with Tailwind CSS v3.
153+
154+
If we ever want to remove these styles, we need to add an explicit border
155+
color utility to any element that depends on these defaults.
156+
*/
157+
@layer base {
158+
*,
159+
::after,
160+
::before,
161+
::backdrop,
162+
::file-selector-button {
163+
border-color: var(--color-gray-200, currentcolor);
164+
}
165+
}
166+
167+
.btn {
168+
@apply rounded-full p-5;
169+
}
170+
.btn-lg {
171+
@apply h-12 font-bold;
172+
}
173+
174+
/* Example Use Case: フッターのボタン */
175+
.link-btn {
176+
/* ダークモードのときでも bg-white, text-black で問題ない */
177+
@apply hover:bg-white/70 hover:text-black px-2 py-1 rounded-sm transition duration-200;
178+
}

packages/web/src/app/components/FilterUI/UI/FlagButton.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const FlagButton: React.FC<FlagButtonProp> = (prop: FlagButtonProp) => {
4242
className={
4343
`${
4444
prop.isSelected ? "bg-primary/30" : "bg-surface"
45-
} text-text-default px-4 py-2 rounded-full outline-2 outline-primary/30 outline` +
45+
} text-text-default px-4 py-2 rounded-full outline-primary/30 outline` +
4646
" " +
4747
className
4848
}

packages/web/src/app/components/Footer/index.tsx

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,31 @@ import { Link } from "react-router-dom";
66
*/
77
export default function Footer() {
88
return (
9-
<footer
10-
id="global-footer"
11-
className="flex items-center justify-end px-4 py-2 text-white bg-inverse-primary fixed bottom-0 w-full"
12-
>
13-
<div className="flex flex-wrap justify-end space-x-4 bg-gray-800">
9+
<footer className="flex items-center justify-end px-4 py-2 text-base-content bg-base-300 fixed bottom-0 w-full">
10+
<div className="flex flex-wrap justify-end space-x-4">
1411
<a
1512
href="https://forms.gle/stBdKuCsXm8LUdBm8"
16-
className="hover:bg-surface-variant hover:text-white px-2 py-1 rounded-sm transition duration-200 "
13+
className="link link-btn"
1714
target="_blank"
1815
rel="noopener noreferrer"
1916
>
2017
ご意見
2118
</a>
22-
<Link
23-
to="/how-to-use"
24-
className="hover:bg-surface-variant hover:text-white px-2 py-1 rounded-sm transition duration-200"
25-
>
19+
<Link to="/how-to-use" className="link link-btn">
2620
使い方
2721
</Link>
28-
<Link
29-
to="/notion"
30-
className="hover:bg-surface-variant hover:text-white px-2 py-1 rounded-sm transition duration-200"
31-
>
22+
<Link to="/notion" className="link link-btn">
3223
履修上の注意
3324
</Link>
34-
<Link
35-
to="/disclaimer"
36-
className="hover:bg-surface-variant hover:text-white px-2 py-1 rounded-sm transition duration-200"
37-
>
25+
<Link to="/disclaimer" className="link link-btn">
3826
免責事項
3927
</Link>
40-
<Link
41-
to="/aboutus"
42-
className="hover:bg-surface-variant hover:text-white px-2 py-1 rounded-sm transition duration-200"
43-
>
28+
<Link to="/aboutus" className="link link-btn">
4429
About us
4530
</Link>
4631
<a
4732
href="https://utcode.net/"
48-
className="hover:bg-surface-variant hover:text-white px-2 py-1 rounded-sm transition duration-200"
33+
className="link link-btn"
4934
target="_blank"
5035
rel="noopener noreferrer"
5136
>

packages/web/src/app/components/Header/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default function Header() {
1414
return (
1515
<header
1616
id="global-header"
17-
className="flex items-center justify-between px-4 py-2 bg-on-primary shadow-md fixed top-0 w-full z-10"
17+
className="flex items-center justify-between px-4 py-2 bg-base-200 shadow-md fixed top-0 w-full z-10"
1818
>
1919
<div className="flex items-center space-x-2">
2020
<a href="/" id="syllabus-link" className="text-lg">
@@ -26,7 +26,7 @@ export default function Header() {
2626
href="https://utcode.net/"
2727
target="_blank"
2828
id="logo-link"
29-
className="flex items-center space-x-1 text-green-600"
29+
className="flex items-center space-x-1"
3030
rel="noopener"
3131
>
3232
<span>by</span>
@@ -44,17 +44,17 @@ export default function Header() {
4444
<MdOutlineWbSunny
4545
size={24}
4646
onClick={() => setTheme("dark")}
47-
className="text-green-600"
47+
className="text-base-content"
4848
/>
4949
) : (
5050
<MdDarkMode
5151
size={24}
5252
onClick={() => setTheme("light")}
53-
className="text-green-600"
53+
className="text-base-content"
5454
/>
5555
)}
5656
</button>
57-
<button type="button" id="settings" className="text-green-600">
57+
<button type="button" id="settings" className="text-base-content">
5858
<FaCog size={24} />
5959
</button>
6060
</div>

0 commit comments

Comments
 (0)