@@ -32,6 +32,10 @@ body {
3232
3333/* --- sidebar layout ---*/
3434
35+ $tab-height : 3.3rem ;
36+ $tab-cursor-height : 1.6rem ;
37+ $tab-count : {{ site.data.tabs | size }};
38+
3539#sidebar {
3640 @include pl-pr (0 );
3741 position : fixed ;
@@ -46,11 +50,9 @@ body {
4650 background : rgb (42 , 30 , 107 );
4751 background : var (--sidebar-bg ,
4852 radial-gradient (circle , rgba (42 , 30 , 107 , 1 ) 0% , rgba (35 , 37 , 46 , 1 ) 100% ));
49-
5053 a {
5154 @include sidebar-icon ;
5255 }
53-
5456 .sidebar-bottom {
5557 .icon-border +a { // the icon behide mode-toggle
5658 margin-left : .1rem ;
6365 letter-spacing : 1px ;
6466 }
6567 .nav-item {
66- height : 20 % ;
68+ height : $tab-height ;
6769 & :hover {
6870 .nav-link {
6971 color : #f8f9facf ;
@@ -75,17 +77,58 @@ body {
7577 }
7678 }
7779 }
78-
7980 ul {
80- height : 16.5 rem ;
81+ height : $tab-height * $tab-count ;
8182 display : -webkit-box ;
8283 display : -ms-flexbox ;
83- }
84+
85+ >li :last-child {
86+ >a {
87+ margin-right : -3px ;
88+ max-width : calc (100% - 3px );
89+ }
90+ & ::after { // the cursor
91+ visibility : hidden ;
92+ content : " " ;
93+ position : relative ;
94+ right : 1px ;
95+ width : 3px ;
96+ height : $tab-cursor-height ;
97+ background-color : var (--nav-cursor , #fcfcfc );
98+ pointer-events : none ;
99+ }
100+ }
101+
102+ @mixin fix-cursor ($top ) {
103+ top : $top ;
104+ visibility : visible ;
105+ }
106+
107+ @for $i from 1 through $tab-count {
108+ $offset : $tab-count - $i ;
109+ $top : - $offset * $tab-height + $tab-cursor-height / 2 ;
110+
111+ @if $i < $tab-count {
112+ >li .active :nth-child (#{$i } ),
113+ >li .nav-item :nth-child (#{$i } ):hover {
114+ ~li :last-child ::after {
115+ @include fix-cursor ($top );
116+ }
117+ }
118+ } @else {
119+ >li .active :nth-child (#{$i } ):last-child ::after ,
120+ >li .nav-item :nth-child (#{$i } ):last-child:hover ::after {
121+ @include fix-cursor ($top );
122+ }
123+ }
124+
125+ } // @for
126+
127+ } // ul
84128
85129 .sidebar-bottom {
86130 font-size : 1.2rem ;
87131 margin : 2rem 2.5rem 1.6rem ;
88-
89132 a {
90133 margin-bottom : .5rem ; // icons may have multi lines
91134 }
@@ -113,61 +156,8 @@ body {
113156 margin-top : .75rem ;
114157 }
115158 }
116-
117159} // #sidebar
118160
119- #sidebar ul > li .active :nth-child (1 ) ~ li :last-child ::after ,
120- #sidebar ul > li .nav-item :nth-child (1 ):hover ~ li :last-child ::after {
121- // top: calc(-400% + (26px / 2));
122- top : -195px ;
123- visibility : visible ;
124- }
125-
126- #sidebar ul > li .active :nth-child (2 ) ~ li :last-child ::after ,
127- #sidebar ul > li .nav-item :nth-child (2 ):hover ~ li :last-child ::after {
128- // top: calc(-300% + (26px / 2));
129- top : -143px ;
130- visibility : visible ;
131- }
132-
133- #sidebar ul > li .active :nth-child (3 ) ~ li :last-child ::after ,
134- #sidebar ul > li .nav-item :nth-child (3 ):hover ~ li :last-child ::after {
135- // top: calc(-200% + (26px / 2));
136- top : -91px ;
137- visibility : visible ;
138- }
139-
140- #sidebar ul > li .active :nth-child (4 ) ~ li :last-child ::after ,
141- #sidebar ul > li .nav-item :nth-child (4 ):hover ~ li :last-child ::after {
142- // top: calc(-100% + (26px / 2));
143- top : -39px ;
144- visibility : visible ;
145- }
146-
147- #sidebar ul > li .active :nth-child (5 ):last-child ::after ,
148- #sidebar ul > li .nav-item :nth-child (5 ):last-child:hover ::after {
149- // top: calc(26px / 2);
150- top : 13px ;
151- visibility : visible ;
152- }
153-
154- #sidebar ul >li :last-child {
155- >a {
156- margin-right : -3px ;
157- max-width : calc (100% - 3px );
158- }
159- & ::after {
160- visibility : hidden ;
161- content : " " ;
162- position : relative ;
163- right : 1px ;
164- width : 3px ;
165- height : 26px ;
166- background-color : var (--nav-cursor , #fcfcfc );
167- pointer-events : none ;
168- }
169- }
170-
171161@media (hover : hover) {
172162 #sidebar ul >li :last-child ::after {
173163 -webkit-transition : top .5s ease ;
@@ -260,7 +250,6 @@ body {
260250 }
261251}
262252
263-
264253/* --- top-bar ---*/
265254
266255#topbar-wrapper {
0 commit comments