Skip to content

Added small fade on tabs when scrollable #187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 51 additions & 24 deletions assets/css/v2/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -937,47 +937,74 @@ blockquote.side-callout {
.tabs-container {
/* border-bottom: 1px solid black; */
white-space: nowrap;
position: relative;

/* Lines extend 1rem into gutter on both sides */
width: calc(100% + 2rem);
margin-left: -1rem;

display: flex;
flex-direction: row;
align-items: end;

* {
flex-grow: 0;
}

& > :last-child {
/* Extend the last child */
flex-grow: 1;
&::after {
content: "";
position: absolute;
display: block;
border-bottom: 1px solid black;
bottom: 0;
right: 0;
width: 2rem;
}
}

.tabs-line {
display: block;
background-color: white;
border-bottom: 1px solid black;
width: 2rem;
}

.nav-tabs {
overflow-x: scroll;
overflow-y: hidden;
height: calc(100% + 1px);
height: 100%;
scrollbar-width: none;

list-style: none;
display: flex;
justify-content: start;
margin: 0;
padding: 0;
padding: 0 2rem;
position: relative;

> :not(:last-child) {
border-right: none;
}

&::before {
content: "";
position: absolute;
display: block;
border-bottom: 1px solid black;
bottom: 0;
left: 0;
width: 2rem;
}

&::after {
content: "";
position: relative;
display: block;
border-bottom: 1px solid black;
bottom: 0;
left: 0;
width: 100%;
}

--scrollbar-width: 1px;
--mask-height: 32px;
--mask-image-content: linear-gradient(
to right,
transparent,
black var(--mask-height),
black calc(100% - var(--mask-height)),
transparent
);

--mask-size-content: 100% calc(100% - var(--scrollbar-width));

--mask-image-scrollbar: linear-gradient(black, black);
--mask-size-scrollbar: 100% var(--scrollbar-width);
mask-image: var(--mask-image-content), var(--mask-image-scrollbar);
mask-size: var(--mask-size-content), var(--mask-size-scrollbar);
mask-position: 0 0, 0 100%;
mask-repeat: no-repeat, no-repeat;
}

.nav-item {
Expand Down
2 changes: 0 additions & 2 deletions layouts/shortcodes/tabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
{{- $tabs := .Scratch.Get "tabs" -}}
{{- if .Inner -}}{{- /* We don't use the inner content, but Hugo will complain if we don't reference it. */ -}}{{- end -}}
<div class="tabs-container">
<span class="tabs-line"></span>
<ul class="nav nav-tabs" id="{{ $tab_set_id }}" role="tablist">
{{- range $i, $e := $tabs -}}
{{- $id := printf "%s-%d" $tab_set_id $i -}}
Expand All @@ -14,7 +13,6 @@
{{- end -}}
{{- end -}}
</ul>
<span class="tabs-line"></span>
</div>
<div class="tab-content" id="{{ $tab_set_id }}">
{{- range $i, $e := $tabs -}}
Expand Down
Loading