Skip to content

Commit c1bd9eb

Browse files
committed
refactor: reduce duplicate scss
1 parent 6f46113 commit c1bd9eb

File tree

6 files changed

+45
-38
lines changed

6 files changed

+45
-38
lines changed

_sass/addon/commons.scss

+10-12
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ i {
251251

252252
> p {
253253
margin-left: 0.25em;
254-
margin-top: 0;
255-
margin-bottom: 0;
254+
255+
@include mt-mb(0);
256256
}
257257
}
258258
}
@@ -769,8 +769,8 @@ $btn-mb: 0.5rem;
769769
li.nav-item {
770770
opacity: 0.9;
771771
width: 100%;
772-
padding-left: 1.5rem;
773-
padding-right: 1.5rem;
772+
773+
@include pl-pr(1.5rem);
774774

775775
a.nav-link {
776776
@include pt-pb(0.6rem);
@@ -1043,7 +1043,7 @@ search {
10431043

10441044
a {
10451045
font-size: 1.4rem;
1046-
line-height: 2.5rem;
1046+
line-height: 1.5rem;
10471047

10481048
&:hover {
10491049
@extend %link-hover;
@@ -1069,8 +1069,9 @@ search {
10691069
}
10701070

10711071
> p {
1072-
overflow: hidden;
1073-
text-overflow: ellipsis;
1072+
@extend %text-ellipsis;
1073+
1074+
white-space: break-spaces;
10741075
display: -webkit-box;
10751076
-webkit-line-clamp: 3;
10761077
-webkit-box-orient: vertical;
@@ -1086,10 +1087,7 @@ search {
10861087
color: var(--topbar-text-color);
10871088
text-align: center;
10881089
width: 70%;
1089-
overflow: hidden;
1090-
text-overflow: ellipsis;
10911090
word-break: keep-all;
1092-
white-space: nowrap;
10931091
}
10941092

10951093
#mask {
@@ -1492,8 +1490,8 @@ search {
14921490

14931491
#main-wrapper > .container {
14941492
max-width: $main-content-max-width;
1495-
padding-left: 1.75rem !important;
1496-
padding-right: 1.75rem !important;
1493+
1494+
@include pl-pr(1.75rem, true);
14971495
}
14981496

14991497
main.col-12,

_sass/addon/module.scss

+18-3
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@
112112
-webkit-box-orient: vertical;
113113
}
114114

115+
@mixin text-ellipsis {
116+
overflow: hidden;
117+
text-overflow: ellipsis;
118+
white-space: nowrap;
119+
}
120+
121+
%text-ellipsis {
122+
@include text-ellipsis;
123+
}
124+
115125
%text-highlight {
116126
color: var(--text-muted-highlight-color);
117127
font-weight: 600;
@@ -158,9 +168,14 @@
158168
padding-bottom: $val;
159169
}
160170

161-
@mixin pl-pr($val) {
162-
padding-left: $val;
163-
padding-right: $val;
171+
@mixin pl-pr($val, $important: false) {
172+
@if $important {
173+
padding-left: $val !important;
174+
padding-right: $val !important;
175+
} @else {
176+
padding-left: $val;
177+
padding-right: $val;
178+
}
164179
}
165180

166181
@mixin placeholder {

_sass/layout/archives.scss

+2-3
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@
5858
li {
5959
font-size: 1.1rem;
6060
line-height: 3rem;
61-
white-space: nowrap;
62-
overflow: hidden;
63-
text-overflow: ellipsis;
61+
62+
@extend %text-ellipsis;
6463

6564
&:nth-child(odd) {
6665
background-color: var(--main-bg, #ffffff);

_sass/layout/category-tag.scss

+1-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@
6363
}
6464

6565
> a {
66-
white-space: nowrap;
67-
overflow: hidden;
68-
text-overflow: ellipsis;
66+
@include text-ellipsis;
6967
}
7068
}
7169
}

_sass/layout/home.scss

+2-3
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@
7474

7575
> div:first-child {
7676
display: block;
77-
white-space: nowrap;
78-
overflow: hidden;
79-
text-overflow: ellipsis;
77+
78+
@extend %text-ellipsis;
8079
}
8180
}
8281
}

_sass/layout/post.scss

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*
2-
Post-specific style
3-
*/
1+
/**
2+
* Post-specific styles
3+
*/
44

55
%btn-post-nav {
66
width: 50%;
@@ -97,7 +97,7 @@ header {
9797

9898
&:hover {
9999
i {
100-
@extend %btn-share-hovor;
100+
@extend %btn-share-hover;
101101
}
102102
}
103103
}
@@ -258,9 +258,8 @@ header {
258258

259259
.toc-link {
260260
display: block;
261-
white-space: nowrap;
262-
overflow: hidden;
263-
text-overflow: ellipsis;
261+
262+
@extend %text-ellipsis;
264263

265264
&:hover {
266265
color: var(--toc-highlight);
@@ -509,10 +508,11 @@ header {
509508
}
510509

511510
p {
511+
@extend %text-ellipsis;
512+
512513
font-size: 0.9rem;
513514
margin-bottom: 0.5rem;
514-
overflow: hidden;
515-
text-overflow: ellipsis;
515+
white-space: break-spaces;
516516
display: -webkit-box;
517517
-webkit-line-clamp: 2;
518518
-webkit-box-orient: vertical;
@@ -534,7 +534,7 @@ header {
534534
max-width: 100%;
535535
}
536536

537-
%btn-share-hovor {
537+
%btn-share-hover {
538538
color: var(--btn-share-hover-color) !important;
539539
}
540540

@@ -566,10 +566,8 @@ header {
566566
/* Hide SideBar and TOC */
567567
@media all and (max-width: 849px) {
568568
.post-navigation {
569-
padding-left: 0;
570-
padding-right: 0;
571-
margin-left: -0.5rem;
572-
margin-right: -0.5rem;
569+
@include pl-pr(0);
570+
@include ml-mr(-0.5rem);
573571
}
574572
}
575573

0 commit comments

Comments
 (0)