Skip to content

Commit db3660e

Browse files
authored
Added small fade on tabs when scrollable (#187)
* feat: Added small fade on tabs when scrollable * fix: Inconsistent end line
1 parent 2f4854c commit db3660e

File tree

2 files changed

+51
-26
lines changed

2 files changed

+51
-26
lines changed

assets/css/v2/style.css

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -937,47 +937,74 @@ blockquote.side-callout {
937937
.tabs-container {
938938
/* border-bottom: 1px solid black; */
939939
white-space: nowrap;
940+
position: relative;
940941

941-
/* Lines extend 1rem into gutter on both sides */
942-
width: calc(100% + 2rem);
943-
margin-left: -1rem;
944-
945-
display: flex;
946-
flex-direction: row;
947-
align-items: end;
948-
949-
* {
950-
flex-grow: 0;
951-
}
952-
953-
& > :last-child {
954-
/* Extend the last child */
955-
flex-grow: 1;
942+
&::after {
943+
content: "";
944+
position: absolute;
945+
display: block;
946+
border-bottom: 1px solid black;
947+
bottom: 0;
948+
right: 0;
949+
width: 2rem;
956950
}
957951
}
958952

959-
.tabs-line {
960-
display: block;
961-
background-color: white;
962-
border-bottom: 1px solid black;
963-
width: 2rem;
964-
}
965-
966953
.nav-tabs {
967954
overflow-x: scroll;
968955
overflow-y: hidden;
969-
height: calc(100% + 1px);
956+
height: 100%;
970957
scrollbar-width: none;
971958

972959
list-style: none;
973960
display: flex;
974961
justify-content: start;
975962
margin: 0;
976-
padding: 0;
963+
padding: 0 2rem;
964+
position: relative;
977965

978966
> :not(:last-child) {
979967
border-right: none;
980968
}
969+
970+
&::before {
971+
content: "";
972+
position: absolute;
973+
display: block;
974+
border-bottom: 1px solid black;
975+
bottom: 0;
976+
left: 0;
977+
width: 2rem;
978+
}
979+
980+
&::after {
981+
content: "";
982+
position: relative;
983+
display: block;
984+
border-bottom: 1px solid black;
985+
bottom: 0;
986+
left: 0;
987+
width: 100%;
988+
}
989+
990+
--scrollbar-width: 1px;
991+
--mask-height: 32px;
992+
--mask-image-content: linear-gradient(
993+
to right,
994+
transparent,
995+
black var(--mask-height),
996+
black calc(100% - var(--mask-height)),
997+
transparent
998+
);
999+
1000+
--mask-size-content: 100% calc(100% - var(--scrollbar-width));
1001+
1002+
--mask-image-scrollbar: linear-gradient(black, black);
1003+
--mask-size-scrollbar: 100% var(--scrollbar-width);
1004+
mask-image: var(--mask-image-content), var(--mask-image-scrollbar);
1005+
mask-size: var(--mask-size-content), var(--mask-size-scrollbar);
1006+
mask-position: 0 0, 0 100%;
1007+
mask-repeat: no-repeat, no-repeat;
9811008
}
9821009

9831010
.nav-item {

layouts/shortcodes/tabs.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
{{- $tabs := .Scratch.Get "tabs" -}}
44
{{- if .Inner -}}{{- /* We don't use the inner content, but Hugo will complain if we don't reference it. */ -}}{{- end -}}
55
<div class="tabs-container">
6-
<span class="tabs-line"></span>
76
<ul class="nav nav-tabs" id="{{ $tab_set_id }}" role="tablist">
87
{{- range $i, $e := $tabs -}}
98
{{- $id := printf "%s-%d" $tab_set_id $i -}}
@@ -14,7 +13,6 @@
1413
{{- end -}}
1514
{{- end -}}
1615
</ul>
17-
<span class="tabs-line"></span>
1816
</div>
1917
<div class="tab-content" id="{{ $tab_set_id }}">
2018
{{- range $i, $e := $tabs -}}

0 commit comments

Comments
 (0)