Skip to content

Commit 85e1bdf

Browse files
committed
ui(home): optimize the top effect of posts
1 parent 7323de5 commit 85e1bdf

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

languages/zh-CN.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ archives: 归档
2424
about: 关于
2525
links: 友链
2626
link: 友链
27-
top: 顶置
27+
top: 置顶
2828
read_more: 阅读全文
2929
wordcount:
3030
min2read: 分钟

layout/home-content.ejs

+9-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@
77
<div class="home-article-item-top border-box"
88
style="height: <%= post?.cover_height ? post?.cover_height + 'px' : '8rem' %>"
99
>
10+
<% if (post.sticky) { %>
11+
<div class="post-sticky-box cover">
12+
<i class="fas fa-thumbtack"></i>&nbsp;<%- __('top') %>
13+
</div>
14+
<% } %>
1015
<img class="cover-img" src="<%= post.cover %>" alt="<%= post.title %>">
1116
</div>
1217
<% } %>
1318
1419
<div class="home-article-item-bottom border-box">
15-
<% if (post.sticky) { %>
16-
<i class="fas fa-thumbtack sticky-icon"></i>
20+
<% if (post.sticky && !post?.cover) { %>
21+
<div class="post-sticky-box">
22+
<i class="fas fa-thumbtack"></i>&nbsp;<%- __('top') %>
23+
</div>
1724
<% } %>
1825
<h3 class="home-article-title border-box">
1926
<a href="<%- url_for(post.path) %>">

source/css/layout/home-content.styl

+27-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,31 @@
1010

1111
keep-container(var(--home-post-hover-scale), 0, 2.8rem)
1212

13+
.post-sticky-box {
14+
position absolute
15+
top 0.8rem
16+
right 0.8rem
17+
z-index $z-index-1
18+
display flex
19+
align-items center
20+
box-sizing border-box
21+
padding 0.1rem 0.4rem
22+
color var(--text-color-4)
23+
font-size 12px
24+
letter-spacing 1px
25+
background var(--background-color-3)
26+
border-radius 0.3rem
27+
transform scale(0.88)
28+
cursor default
29+
disable-user-select()
30+
31+
&.cover {
32+
top 0.6rem
33+
right 0.6rem
34+
}
35+
}
36+
37+
1338
.home-article-item-top {
1439
width 100%
1540
overflow hidden
@@ -28,10 +53,10 @@
2853
height 100%
2954
object-fit cover
3055
transform-origin center center
31-
transition-t("transform", "0.2", "1", "linear")
56+
transition-t("transform", "0.1", "1", "linear")
3257

3358
&:hover {
34-
transform scale(1.04)
59+
transform scale(1.03)
3560
}
3661
}
3762
}

0 commit comments

Comments
 (0)