Skip to content

Commit adf6538

Browse files
refactor(css): 硬编码颜色改为CSS变量,内联样式抽取为复用class
- _placeholders.scss: #B07D62 → var(--link-color), #6d6c6c → var(--text-muted-color) - _categories.scss: #6c757d → var(--text-muted-color) - 新增 _card-grid.scss: friends/tools 页面共享的卡片样式 - friends.md/tools.md: 18处内联style替换为CSS class
1 parent 4b416b7 commit adf6538

6 files changed

Lines changed: 68 additions & 20 deletions

File tree

_sass/abstracts/_placeholders.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@
4545
}
4646

4747
%link-hover {
48-
color: #B07D62 !important;
49-
border-bottom: 1px solid #B07D62;
48+
color: var(--link-color) !important;
49+
border-bottom: 1px solid var(--link-color);
5050
text-decoration: none;
5151
}
5252

@@ -92,7 +92,7 @@
9292
font-style: normal;
9393
font-size: 80%;
9494
padding: 0;
95-
color: #6d6c6c;
95+
color: var(--text-muted-color);
9696
}
9797
}
9898

_sass/pages/_card-grid.scss

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* Shared card grid styles for friends, tools and similar listing pages */
2+
3+
.card-grid {
4+
// Clickable card
5+
.card-clickable {
6+
cursor: pointer;
7+
}
8+
9+
// Dead/inactive card (grayscale + dimmed)
10+
.card-dead {
11+
cursor: pointer;
12+
filter: grayscale(100%);
13+
}
14+
15+
// Card body inner positioning
16+
.card-body-inner {
17+
position: relative;
18+
z-index: 1;
19+
}
20+
21+
// Card title text
22+
.card-title-text {
23+
color: var(--heading-color);
24+
}
25+
26+
// Two-line text clamp
27+
.text-clamp-2 {
28+
display: -webkit-box;
29+
-webkit-line-clamp: 2;
30+
-webkit-box-orient: vertical;
31+
overflow: hidden;
32+
}
33+
34+
// Avatar image
35+
.avatar-cover {
36+
object-fit: cover;
37+
}
38+
39+
// Dimmed section (e.g. dead links)
40+
&--dimmed {
41+
opacity: 0.6;
42+
}
43+
}
44+
45+
.section-subtitle {
46+
font-size: 1.1rem;
47+
}

_sass/pages/_categories.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
height: 1.7rem;
5555
border-radius: 50%;
5656
text-align: center;
57-
color: #6c757d !important;
57+
color: var(--text-muted-color) !important;
5858

5959
i {
6060
position: relative;

_sass/pages/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
@forward 'tags';
66
@forward 'archives';
77
@forward 'category-tag';
8+
@forward 'card-grid';

_tabs/friends.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,21 @@ comments: true
1313
{% assign alive_list = site.data.friends %}
1414
{% endunless %}
1515

16-
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4">
16+
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4 card-grid">
1717
{% for friend in alive_list %}
1818
{% if friend.name and friend.url %}
1919
<div class="col">
20-
<div class="card h-100 post-preview" style="cursor:pointer;" onclick="window.open('{{ friend.url }}','_blank')">
21-
<div class="card-body d-flex align-items-center" style="position:relative;z-index:1;">
20+
<div class="card h-100 post-preview card-clickable" onclick="window.open('{{ friend.url }}','_blank')">
21+
<div class="card-body d-flex align-items-center card-body-inner">
2222
{% if friend.icon and friend.icon != "" %}
23-
<img src="{{ friend.icon }}" alt="{{ friend.name }}" class="rounded-circle me-3 flex-shrink-0" width="48" height="48" style="object-fit:cover;" onerror="this.outerHTML='<i class=\'fas fa-globe fa-2x me-3 text-muted\'></i>';" />
23+
<img src="{{ friend.icon }}" alt="{{ friend.name }}" class="rounded-circle me-3 flex-shrink-0 avatar-cover" width="48" height="48" onerror="this.outerHTML='<i class=\'fas fa-globe fa-2x me-3 text-muted\'></i>';" />
2424
{% else %}
2525
<i class="fas fa-globe fa-2x me-3 text-muted"></i>
2626
{% endif %}
2727
<div>
28-
<span class="fw-bold" style="color:var(--heading-color);">{{ friend.name }}</span>
28+
<span class="fw-bold card-title-text">{{ friend.name }}</span>
2929
{% if friend.description %}
30-
<div class="text-muted small mt-1" style="display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;">{{ friend.description }}</div>
30+
<div class="text-muted small mt-1 text-clamp-2">{{ friend.description }}</div>
3131
{% endif %}
3232
</div>
3333
</div>
@@ -40,22 +40,22 @@ comments: true
4040
{% if dead_list and dead_list.size > 0 %}
4141
<hr class="mt-5 mb-3">
4242

43-
<h3 class="text-muted mb-4" style="font-size:1.1rem;">
43+
<h3 class="text-muted mb-4 section-subtitle">
4444
<i class="fas fa-cross me-2"></i>数字墓园
4545
<span class="text-muted small ms-2">— 那些沉睡的站点</span>
4646
</h3>
4747

48-
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4" style="opacity:0.6;">
48+
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4 card-grid card-grid--dimmed">
4949
{% for friend in dead_list %}
5050
{% if friend.name and friend.url %}
5151
<div class="col">
52-
<div class="card h-100 post-preview" style="cursor:pointer;filter:grayscale(100%);" onclick="window.open('{{ friend.url }}','_blank')">
53-
<div class="card-body d-flex align-items-center" style="position:relative;z-index:1;">
52+
<div class="card h-100 post-preview card-dead" onclick="window.open('{{ friend.url }}','_blank')">
53+
<div class="card-body d-flex align-items-center card-body-inner">
5454
<i class="fas fa-skull fa-2x me-3 text-muted flex-shrink-0"></i>
5555
<div>
56-
<span class="fw-bold" style="color:var(--heading-color);">{{ friend.name }}</span>
56+
<span class="fw-bold card-title-text">{{ friend.name }}</span>
5757
{% if friend.description %}
58-
<div class="text-muted small mt-1" style="display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;">{{ friend.description }}</div>
58+
<div class="text-muted small mt-1 text-clamp-2">{{ friend.description }}</div>
5959
{% endif %}
6060
</div>
6161
</div>

_tabs/tools.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ icon: fas fa-toolbox
44
order: 7
55
---
66

7-
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4">
7+
<div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-4 card-grid">
88
{% for tool in site.data.tools %}
99
{% if tool.name and tool.url %}
1010
<div class="col">
11-
<a href="{{ tool.url }}" class="card h-100 post-preview text-decoration-none card-wrapper">
12-
<div class="card-body d-flex align-items-center" style="position:relative;z-index:1;">
11+
<a href="{{ tool.url }}" class="card h-100 post-preview text-decoration-none card-wrapper card-clickable">
12+
<div class="card-body d-flex align-items-center card-body-inner">
1313
{% if tool.icon %}
1414
<i class="{{ tool.icon }} fa-2x me-3 text-muted"></i>
1515
{% else %}
1616
<i class="fas fa-puzzle-piece fa-2x me-3 text-muted"></i>
1717
{% endif %}
1818
<div>
19-
<span class="fw-bold" style="color:var(--heading-color);">{{ tool.name }}</span>
19+
<span class="fw-bold card-title-text">{{ tool.name }}</span>
2020
{% if tool.description %}
2121
<div class="text-muted small mt-1">{{ tool.description }}</div>
2222
{% endif %}

0 commit comments

Comments
 (0)