Skip to content

Commit

Permalink
feat(tab): add logical container shape tokens
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 557939187
  • Loading branch information
asyncLiz authored and copybara-github committed Aug 17, 2023
1 parent 379aa61 commit dbed51c
Showing 1 changed file with 63 additions and 5 deletions.
68 changes: 63 additions & 5 deletions tabs/internal/_tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@
// go/keep-sorted end

@mixin theme($tokens) {
$supported-tokens: tokens.$md-comp-tab-supported-tokens;
$supported-tokens: list.join(
tokens.$md-comp-tab-supported-tokens,
(
'primary-tab-container-shape-start-start',
'primary-tab-container-shape-start-end',
'primary-tab-container-shape-end-end',
'primary-tab-container-shape-end-start',
'secondary-tab-container-shape-start-start',
'secondary-tab-container-shape-start-end',
'secondary-tab-container-shape-end-end',
'secondary-tab-container-shape-end-start'
)
);

@each $token, $value in $tokens {
@if list.index($supported-tokens, $token) == null {
Expand All @@ -43,6 +55,24 @@
}
}

// Support logical shape properties
--_container-shape-start-start: var(
--md-primary-tab-container-shape-start-start,
var(--_container-shape)
);
--_container-shape-start-end: var(
--md-primary-tab-container-shape-start-end,
var(--_container-shape)
);
--_container-shape-end-end: var(
--md-primary-tab-container-shape-end-end,
var(--_container-shape)
);
--_container-shape-end-start: var(
--md-primary-tab-container-shape-end-start,
var(--_container-shape)
);

display: inline-flex;
outline: none;
-webkit-tap-highlight-color: transparent;
Expand Down Expand Up @@ -80,15 +110,14 @@
user-select: none;
-webkit-appearance: none;
vertical-align: middle;
background: transparent;
background: none;
text-decoration: none;
width: 100%;
position: relative;
padding: 0;
margin: 0;
z-index: 0; // Ensure this is a stacking context so the indicator displays
font: var(--_label-text-type);
background-color: var(--_container-color);
border-bottom: var(--_divider-thickness) solid var(--_divider-color);
color: var(--_label-text-color);

Expand All @@ -98,9 +127,20 @@
}
}

.button,
.button::before {
background: var(--_container-color);
content: '';
inset: 0;
position: absolute;
z-index: -1;
}

.button::before,
md-ripple {
border-radius: var(--_container-shape);
border-start-start-radius: var(--_container-shape-start-start);
border-start-end-radius: var(--_container-shape-start-end);
border-end-end-radius: var(--_container-shape-end-end);
border-end-start-radius: var(--_container-shape-end-start);
}

.content {
Expand Down Expand Up @@ -243,6 +283,24 @@
--_#{$token}: var(--md-#{$secondary-prefix}#{$token}, #{$value});
}
}

// Support logical shape properties
--_container-shape-start-start: var(
--md-secondary-tab-container-shape-start-start,
var(--_container-shape)
);
--_container-shape-start-end: var(
--md-secondary-tab-container-shape-start-end,
var(--_container-shape)
);
--_container-shape-end-end: var(
--md-secondary-tab-container-shape-end-end,
var(--_container-shape)
);
--_container-shape-end-start: var(
--md-secondary-tab-container-shape-end-start,
var(--_container-shape)
);
}

:host([variant~='secondary']) .content {
Expand Down

0 comments on commit dbed51c

Please sign in to comment.