Skip to content

Commit 01bae3d

Browse files
committed
style: 添加全局样式和CSS变量
1 parent e5b0fb7 commit 01bae3d

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

src/styles/global.css

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
@import './variables.css';
2+
3+
* {
4+
margin: 0;
5+
padding: 0;
6+
box-sizing: border-box;
7+
}
8+
9+
html, body, #root {
10+
height: 100%;
11+
width: 100%;
12+
overflow: hidden;
13+
}
14+
15+
body {
16+
font-family: var(--font-sans);
17+
background-color: var(--bg-secondary);
18+
color: var(--text-primary);
19+
line-height: 1.5;
20+
}
21+
22+
button {
23+
cursor: pointer;
24+
border: none;
25+
background: none;
26+
font-family: inherit;
27+
font-size: inherit;
28+
}
29+
30+
input, select {
31+
font-family: inherit;
32+
font-size: inherit;
33+
}
34+
35+
a {
36+
color: var(--primary-color);
37+
text-decoration: none;
38+
}
39+
40+
a:hover {
41+
text-decoration: underline;
42+
}
43+
44+
/* 滚动条样式 */
45+
::-webkit-scrollbar {
46+
width: 8px;
47+
height: 8px;
48+
}
49+
50+
::-webkit-scrollbar-track {
51+
background: var(--bg-tertiary);
52+
border-radius: 4px;
53+
}
54+
55+
::-webkit-scrollbar-thumb {
56+
background: var(--text-muted);
57+
border-radius: 4px;
58+
}
59+
60+
::-webkit-scrollbar-thumb:hover {
61+
background: var(--text-secondary);
62+
}
63+
64+
/* 工具提示 */
65+
[data-tooltip] {
66+
position: relative;
67+
}
68+
69+
[data-tooltip]::after {
70+
content: attr(data-tooltip);
71+
position: absolute;
72+
bottom: 100%;
73+
left: 50%;
74+
transform: translateX(-50%);
75+
padding: 6px 12px;
76+
background: var(--bg-dark);
77+
color: var(--text-light);
78+
font-size: 12px;
79+
border-radius: var(--border-radius);
80+
white-space: nowrap;
81+
opacity: 0;
82+
visibility: hidden;
83+
transition: var(--transition-fast);
84+
z-index: 1000;
85+
}
86+
87+
[data-tooltip]:hover::after {
88+
opacity: 1;
89+
visibility: visible;
90+
}

src/styles/variables.css

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
:root {
2+
/* 主色调 - 避免紫色 */
3+
--primary-color: #2563eb;
4+
--primary-hover: #1d4ed8;
5+
--secondary-color: #10b981;
6+
--accent-color: #f59e0b;
7+
--danger-color: #ef4444;
8+
9+
/* 背景色 */
10+
--bg-primary: #ffffff;
11+
--bg-secondary: #f8fafc;
12+
--bg-tertiary: #f1f5f9;
13+
--bg-dark: #1e293b;
14+
15+
/* 文字颜色 */
16+
--text-primary: #1e293b;
17+
--text-secondary: #64748b;
18+
--text-muted: #94a3b8;
19+
--text-light: #ffffff;
20+
21+
/* 边框 */
22+
--border-color: #e2e8f0;
23+
--border-radius: 8px;
24+
--border-radius-lg: 12px;
25+
26+
/* 阴影 */
27+
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
28+
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
29+
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
30+
31+
/* 间距 */
32+
--spacing-xs: 4px;
33+
--spacing-sm: 8px;
34+
--spacing-md: 16px;
35+
--spacing-lg: 24px;
36+
--spacing-xl: 32px;
37+
38+
/* 字体 */
39+
--font-mono: 'Fira Code', 'Consolas', 'Monaco', monospace;
40+
--font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
41+
42+
/* 动画 */
43+
--transition-fast: 150ms ease;
44+
--transition-normal: 250ms ease;
45+
--transition-slow: 350ms ease;
46+
47+
/* 高亮颜色 */
48+
--highlight-current: #fef3c7;
49+
--highlight-compare: #dbeafe;
50+
--highlight-update: #d1fae5;
51+
--highlight-result: #10b981;
52+
53+
/* 代码高亮 */
54+
--code-bg: #1e293b;
55+
--code-line-highlight: rgba(37, 99, 235, 0.2);
56+
--code-line-number: #64748b;
57+
}

0 commit comments

Comments
 (0)