Skip to content

Commit

Permalink
New mixin toggle-arrow & toggle-close
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Aug 3, 2020
1 parent 1d2f057 commit 6b9b175
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 76 deletions.
4 changes: 2 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -610,15 +610,15 @@ valine:
appKey: # Your leancloud application appkey
placeholder: Just go go # Comment box placeholder
avatar: mm # Gravatar style
meta: [nick, mail, link] # Custom comment header
meta: [] # Custom comment header: [nick, mail, link]
pageSize: 10 # Pagination size
language: # Language, available values: en, zh-cn
visitor: false # Article reading statistic
comment_count: true # If false, comment count will only be displayed in post page, not in home page
recordIP: false # Whether to record the commenter IP
serverURLs: # When the custom domain name is enabled, fill it in here (it will be detected automatically by default, no need to fill in)
enableQQ: false # Whether to enable the Nickname box to automatically get QQ Nickname and QQ Avatar
requiredFields: [] # Set required fields: ['nick'] | ['nick','mail']
requiredFields: [] # Set required fields: [nick] | [nick, mail]
#post_meta_order: 0

# LiveRe comments system
Expand Down
4 changes: 3 additions & 1 deletion source/css/_common/components/post/post-collapse.styl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.posts-collapse {
margin-bottom: $posts-collapse-margin;
margin-left: $posts-collapse-margin;
position: relative;

Expand Down Expand Up @@ -40,7 +41,7 @@

.collection-header {
display: block;
margin: 0 0 0 20px;
margin-left: 20px;

small {
color: $grey;
Expand Down Expand Up @@ -101,6 +102,7 @@
height: 100%;
margin-left: -2px;
position: absolute;
// 1.25em is inaccurate when .collection-title has line breaks on mobile
top: 1.25em;
width: 4px;
}
Expand Down
12 changes: 9 additions & 3 deletions source/css/_common/outline/sidebar/sidebar-toggle.styl
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@
background: $sidebar-highlight;
}

body:not(.sidebar-active) .sidebar-toggle:hover {
@extend .toggle.toggle-arrow;
// Fix issue #75
// @extends does not seem to work inside @media
// So we use a mixin here
// https://github.com/stylus/stylus/issues/609
@media (any-hover: hover) {
body:not(.sidebar-active) .sidebar-toggle:hover {
toggle-arrow(hexo-config('sidebar.position'));
}
}

.sidebar-active .sidebar-toggle {
@extend .toggle.toggle-close;
toggle-close(hexo-config('sidebar.position'));
}
75 changes: 5 additions & 70 deletions source/css/_common/scaffolding/toggles.styl
Original file line number Diff line number Diff line change
Expand Up @@ -17,75 +17,10 @@
}
}

if (hexo-config('sidebar.position') == 'right') {
.toggle.toggle-arrow {
.toggle-line:first-child {
top: 2px;
transform: rotate(-45deg);
width: 50%;
}

.toggle-line:nth-child(2) {
width: 90%;
}

.toggle-line:last-child {
top: -2px;
transform: rotate(45deg);
width: 50%;
}
}

.toggle.toggle-close {
.toggle-line:first-child {
top: 5px;
transform: rotate(-45deg);
}

.toggle-line:nth-child(2) {
opacity: 0;
}

.toggle-line:last-child {
top: -5px;
transform: rotate(45deg);
}
}
} else {
.toggle.toggle-arrow {
.toggle-line:first-child {
left: 50%;
top: 2px;
transform: rotate(45deg);
width: 50%;
}

.toggle-line:nth-child(2) {
left: 2px;
width: 90%;
}

.toggle-line:last-child {
left: 50%;
top: -2px;
transform: rotate(-45deg);
width: 50%;
}
}

.toggle.toggle-close {
.toggle-line:first-child {
transform: rotate(-45deg);
top: 5px;
}

.toggle-line:nth-child(2) {
opacity: 0;
}
.toggle.toggle-arrow {
toggle-arrow(hexo-config('sidebar.position'));
}

.toggle-line:last-child {
transform: rotate(45deg);
top: -5px;
}
}
.toggle.toggle-close {
toggle-close(hexo-config('sidebar.position'));
}
58 changes: 58 additions & 0 deletions source/css/_mixins.styl
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,61 @@ round-icon($diameter) {
height: $diameter;
width: $diameter;
}

toggle-arrow($position) {
if ($position == 'right') {
.toggle-line:first-child {
top: 2px;
transform: rotate(-45deg);
width: 50%;
}

.toggle-line:last-child {
top: -2px;
transform: rotate(45deg);
width: 50%;
}
} else {
.toggle-line:first-child {
left: 50%;
top: 2px;
transform: rotate(45deg);
width: 50%;
}

.toggle-line:last-child {
left: 50%;
top: -2px;
transform: rotate(-45deg);
width: 50%;
}
}
}

toggle-close($position) {
.toggle-line:nth-child(2) {
opacity: 0;
}

if ($position == 'right') {
.toggle-line:first-child {
top: 5px;
transform: rotate(-45deg);
}

.toggle-line:last-child {
top: -5px;
transform: rotate(45deg);
}
} else {
.toggle-line:first-child {
top: 5px;
transform: rotate(45deg);
}

.toggle-line:last-child {
top: -5px;
transform: rotate(-45deg);
}
}
}

0 comments on commit 6b9b175

Please sign in to comment.