Skip to content

Add an optional wrapper to tabs #11897

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 1 commit into from
Apr 11, 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
4 changes: 2 additions & 2 deletions src/_11ty/shortcodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ function _setupTabs(eleventyConfig: UserConfig) {
let currentTabWrapperId = 0;
let currentTabPaneId = 0;

eleventyConfig.addPairedShortcode('tabs', function (content: string, saveKey: string) {
eleventyConfig.addPairedShortcode('tabs', function (content: string, saveKey: string, wrapped: boolean = false) {
const tabWrapperId = currentTabWrapperId++;
let tabMarkup = `<div id="${tabWrapperId}" class="tabs-wrapper" ${saveKey ? `data-tab-save-key="${slugify(saveKey)}"` : ''}><ul class="nav-tabs" role="tablist">`;
let tabMarkup = `<div id="${tabWrapperId}" class="tabs-wrapper${wrapped ? " wrapped" : ""}" ${saveKey ? `data-tab-save-key="${slugify(saveKey)}"` : ''}><ul class="nav-tabs" role="tablist">`;

// Only select child tab panes that don't already have a parent wrapper.
const tabPanes = selectAll('.tab-pane[data-tab-wrapper-id="undefined"]', fromHtml(content));
Expand Down
6 changes: 4 additions & 2 deletions src/_sass/base/_root.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ body {
--site-base-fgColor-alt: #6a6f71;

--site-raised-bgColor: #e9ecef;
--site-raised-bgColor-translucent: #{color.change(#e9ecef, $alpha: 0.2)};

--site-primary-color: #{$base_primary_color};
--site-accent-color: #833ef2;
Expand All @@ -56,8 +57,8 @@ body {
--site-onPrimary-color-lighter: #{color.mix(#fff, #B8EAFE, 50%)};
--site-onPrimary-color-lightest: #{color.mix(#fff, #B8EAFE, 75%)};

--site-inset-bgColor: #F8F9FA;
--site-inset-bgColor-translucent: rgba(248, 249, 250, 0.8);
--site-inset-bgColor: #F6F7F8;
--site-inset-bgColor-translucent: rgba(237, 240, 242, 0.8);
--site-inset-fgColor: var(--site-base-fgColor);
--site-inset-borderColor: #DADCE0;

Expand Down Expand Up @@ -109,6 +110,7 @@ body {
--site-base-fgColor-alt: #a8acad;

--site-raised-bgColor: #1c1e27;
--site-raised-bgColor-translucent: #{color.change(#1c1e27, $alpha: 0.4)};

--site-primary-color: #{$base_primary_color};
--site-accent-color: #b07fff;
Expand Down
6 changes: 5 additions & 1 deletion src/_sass/components/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
min-width: 8rem;
max-width: 960px;
min-height: calc(100vh - var(--site-header-height) - var(--site-subheader-height));
padding: 2rem;
padding: 1.5rem;

@media (min-width: 576px) {
padding: 2rem;
}

img {
object-fit: contain;
Expand Down
1 change: 1 addition & 0 deletions src/_sass/components/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
border-right: 0.1rem solid var(--site-outline-variant);
padding: 0.75rem 0.75rem 2.25rem;
position: sticky;
height: calc(100vh - var(--site-header-height));
top: var(--site-header-height);
overscroll-behavior: auto;
width: 16rem;
Expand Down
31 changes: 29 additions & 2 deletions src/_sass/components/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@
}
}

$wrapper-padding: 0.375rem;
$wrapper-radius: 0.125rem;

ul.nav-tabs {
list-style: none;

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

padding: 0.375rem;
border-radius: 0.125rem;
padding: $wrapper-padding;
border-radius: $wrapper-radius;
background-color: var(--site-raised-bgColor);
gap: 0.5rem;
overflow-x: scroll;
Expand Down Expand Up @@ -57,3 +60,27 @@ ul.nav-tabs {
}
}
}

.tabs-wrapper.wrapped {
.nav-tabs {
margin-bottom: 0;
}

.tab-content {
padding: 1rem 1rem 0;
background-color: var(--site-raised-bgColor-translucent);

border: $wrapper-padding solid var(--site-raised-bgColor);
border-top: none;
border-bottom-left-radius: $wrapper-radius;
border-bottom-right-radius: $wrapper-radius;

ul {
padding-left: 1rem;
}

.tab-pane > :first-child {
margin-block-start: 0;
}
}
}
53 changes: 35 additions & 18 deletions src/content/ui/layout/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ displays the widget.
<a id="material-apps" aria-hidden="true"></a>
<a id="cupertino-apps" aria-hidden="true"></a>

{% tabs "app-type-tabs" %}
{% tabs "app-type-tabs", true %}

{% tab "Standard apps" %}

Expand Down Expand Up @@ -772,41 +772,58 @@ only Material apps can use the Material Components library.
<a id="standard-widgets" aria-hidden="true"></a>
<a id="materials-widgets" aria-hidden="true"></a>

{% tabs "os-archive-tabs" %}
{% tabs "widget-types-tabs", true %}

{% tab "Standard widgets" %}

* [`Container`](#container): Adds padding, margins, borders,
[`Container`](#container)
: Adds padding, margins, borders,
background color, or other decorations to a widget.
* [`GridView`](#gridview): Lays widgets out as a scrollable grid.
* [`ListView`](#listview): Lays widgets out as a scrollable list.
* [`Stack`](#stack): Overlaps a widget on top of another.

[`GridView`](#gridview)
: Lays widgets out as a scrollable grid.

[`ListView`](#listview)
: Lays widgets out as a scrollable list.

[`Stack`](#stack)
: Overlaps a widget on top of another.

{% endtab %}

{% tab "Material widgets" %}

* [`Scaffold`][]: Provides a structured layout framework
[`Scaffold`][]
: Provides a structured layout framework
with slots for common Material Design app elements.
* [`AppBar`][]: Creates a horizontal bar that's typically

[`AppBar`][]
: Creates a horizontal bar that's typically
displayed at the top of a screen.
* [`Card`](#card): Organizes related info into a box with

[`Card`](#card)
: Organizes related info into a box with
rounded corners and a drop shadow.
* [`ListTile`](#listtile): Organizes up to 3 lines of text,

[`ListTile`](#listtile)
: Organizes up to 3 lines of text,
and optional leading and trailing icons, into a row.

{% endtab %}

{% tab "Cupertino widgets" %}

* [`CupertinoPageScaffold`][]: Provides the basic layout
structure for an iOS-style page.  
* [`CupertinoNavigationBar`][]: Creates an iOS-style
navigation bar at the top of the screen.  
* [`CupertinoSegmentedControl`][]: Creates a segmented
control for selecting.  
* [`CupertinoTabBar`][] and [`CupertinoTabScaffold`][]:
Creates the characteristic iOS bottom tab bar.
[`CupertinoPageScaffold`][]
: Provides the basic layout structure for an iOS-style page.

[`CupertinoNavigationBar`][]
: Creates an iOS-style navigation bar at the top of the screen.

[`CupertinoSegmentedControl`][]
: Creates a segmented control for selecting.

[`CupertinoTabBar`][] and [`CupertinoTabScaffold`][]
: Creates the characteristic iOS bottom tab bar.

{% endtab %}

Expand Down