diff --git a/tabs/demo/stories.ts b/tabs/demo/stories.ts index d74413d6b..ae8d47103 100644 --- a/tabs/demo/stories.ts +++ b/tabs/demo/stories.ts @@ -82,23 +82,22 @@ const secondary: MaterialStoryInit = { styles, render(knobs) { const tabContent = getTabContentGenerator(knobs); - const inlineIcon = knobs.inlineIcon; return html` - + ${tabContent('flight', 'Travel')} - + ${tabContent('hotel', 'Hotel')} - + ${tabContent('hiking', 'Activities')} - + ${tabContent('restaurant', 'Food')} `; diff --git a/tabs/internal/_primary-tab.scss b/tabs/internal/_primary-tab.scss index 9ed25468b..4c60b0f81 100644 --- a/tabs/internal/_primary-tab.scss +++ b/tabs/internal/_primary-tab.scss @@ -58,4 +58,13 @@ var(--_container-shape) ); } + + .content.stacked { + flex-direction: column; + gap: 2px; + } + + .content.stacked.has-icon.has-label { + height: var(--_with-icon-and-label-text-container-height); + } } diff --git a/tabs/internal/_secondary-tab.scss b/tabs/internal/_secondary-tab.scss index 97cfa94c0..3ee319402 100644 --- a/tabs/internal/_secondary-tab.scss +++ b/tabs/internal/_secondary-tab.scss @@ -57,8 +57,5 @@ --md-secondary-tab-container-shape-end-start, var(--_container-shape) ); - - // TODO(b/293503309): remove once secondary tabs only use inline icons - --_with-icon-and-label-text-container-height: 64px; } } diff --git a/tabs/internal/_tab.scss b/tabs/internal/_tab.scss index 2a339ed50..0dc54af5a 100644 --- a/tabs/internal/_tab.scss +++ b/tabs/internal/_tab.scss @@ -89,19 +89,10 @@ position: relative; box-sizing: border-box; display: inline-flex; - flex-direction: column; + flex-direction: row; align-items: center; justify-content: center; height: var(--_container-height); - gap: 2px; - } - - .content.has-icon.has-label:not(.inline-icon) { - height: var(--_with-icon-and-label-text-container-height); - } - - .content.inline-icon { - flex-direction: row; gap: 8px; } diff --git a/tabs/internal/primary-tab.ts b/tabs/internal/primary-tab.ts index 259c06b6d..f4ddb536b 100644 --- a/tabs/internal/primary-tab.ts +++ b/tabs/internal/primary-tab.ts @@ -4,9 +4,23 @@ * SPDX-License-Identifier: Apache-2.0 */ +import {property} from 'lit/decorators.js'; + import {Tab} from './tab.js'; /** * A primary tab component. */ -export class PrimaryTab extends Tab {} +export class PrimaryTab extends Tab { + /** + * Whether or not the icon renders inline with label or stacked vertically. + */ + @property({type: Boolean, attribute: 'inline-icon'}) inlineIcon = false; + + protected override getContentClasses() { + return { + ...super.getContentClasses(), + 'stacked': !this.inlineIcon, + }; + } +} diff --git a/tabs/internal/tab.ts b/tabs/internal/tab.ts index 41b44a4f0..3ba318880 100644 --- a/tabs/internal/tab.ts +++ b/tabs/internal/tab.ts @@ -51,11 +51,6 @@ export class Tab extends LitElement { */ @property({type: Boolean}) focusable = false; - /** - * Whether or not the icon renders inline with label or stacked vertically. - */ - @property({type: Boolean, attribute: 'inline-icon'}) inlineIcon = false; - /** * In SSR, set this to true when an icon is present. */ @@ -93,12 +88,6 @@ export class Tab extends LitElement { } protected override render() { - const contentClasses = { - 'inline-icon': this.inlineIcon, - 'has-icon': this.hasIcon, - 'has-label': !this.iconOnly, - }; - const indicator = html`
`; // Needed for closure conformance const {ariaLabel} = this as ARIAMixinStrict; @@ -113,7 +102,7 @@ export class Tab extends LitElement { -
+
${this.fullWidthIndicator ? nothing : indicator} @@ -122,6 +111,13 @@ export class Tab extends LitElement { `; } + protected getContentClasses() { + return { + 'has-icon': this.hasIcon, + 'has-label': !this.iconOnly, + }; + } + protected override updated(changed: PropertyValues) { if (changed.has('selected')) { this.animateSelected();