Skip to content

Commit

Permalink
feat(ui-library): tab bar - use slots for tab bar item (#1136)
Browse files Browse the repository at this point in the history
Co-authored-by: Barkley <[email protected]>
  • Loading branch information
angsherpa456 and bar-tay authored Jul 13, 2024
1 parent 23aeaa4 commit 8de1f59
Show file tree
Hide file tree
Showing 10 changed files with 495 additions and 410 deletions.
8 changes: 0 additions & 8 deletions packages/js-example-app/src/index.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,6 @@ function init() {
addLog('blr-toggleswitch changed: ' + e.detail.checkedState);
});

blrTabBar.addEventListener('blrFocus', () => {
addLog('blr-tab-bar focused');
});

blrTabBar.addEventListener('blrBlur', () => {
addLog('blr-tab-bar blurred');
});

blrTabBar.addEventListener('blrChange', (e) => {
addLog('blr-tab-bar changed: ' + e.detail.changedValue);
});
Expand Down
22 changes: 11 additions & 11 deletions packages/js-example-app/src/index.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,17 @@ export function* renderIndex() {
tab-content="labelAndIcon"
icon-position="leading"
alignment="left"
><p disabled label="Tab 1" icon="blr360">Tab 1</p>
<p label="Tab 2" icon="blr360">Tab 2</p>
<p label="Tab 3" icon="blr360">Tab 3</p>
<p label="Tab 4" icon="blr360">Tab 4</p>
<p label="Tab 5" icon="blr360">Tab 5</p>
<p label="Tab 6" icon="blr360">Tab 6</p>
<p label="Tab 7" icon="blr360">Tab 7</p>
<p label="Tab 8" icon="blr360">Tab 8</p>
<p label="Tab 9" icon="blr360">Tab 9</p>
<p label="Tab 10" icon="blr360">Tab 10</p>
<p label="Tab 11" icon="blr360">Tab 11</p>
><blr-tab-bar-item disabled="true" label="Tab 1" icon="blr360">Tab 1</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 2" icon="blr360">Tab 2</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 3" icon="blr360">Tab 3</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 4" icon="blr360">Tab 4</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 5" icon="blr360">Tab 5</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 6" icon="blr360">Tab 6</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 7" icon="blr360">Tab 7</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 8" icon="blr360">Tab 8</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 9" icon="blr360">Tab 9</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 10" icon="blr360">Tab 10</blr-tab-bar-item>
<blr-tab-bar-item label="Tab 11" icon="blr360">Tab 11</blr-tab-bar-item>
</blr-tab-bar>
</div>
Expand Down
5 changes: 2 additions & 3 deletions packages/ui-library/src/components/radio-group/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropertyValues, html, nothing } from 'lit';
import { html, nothing } from 'lit';
import { classMap } from 'lit/directives/class-map.js';
import { property } from '../../utils/lit/decorators.js';
import { staticStyles as componentSpecificStaticStyles } from './index.css.js';
Expand Down Expand Up @@ -77,8 +77,7 @@ export class BlrRadioGroup extends LitElementCustom {
}
};

// eslint-disable-next-line @typescript-eslint/no-unused-vars
protected firstUpdated(_changedProperties: PropertyValues): void {
protected firstUpdated() {
this.handleSlotChange();
}

Expand Down
231 changes: 231 additions & 0 deletions packages/ui-library/src/components/tab-bar-item/index.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
import { ComponentThemeIterator } from "../../foundation/_tokens-generated/index.pseudo.generated.js";
import { css } from "../../utils/css-in-ts/nested-typesafe-css-literals.js";

export const staticStyles = css`
${ComponentThemeIterator((theme, cmp, typeSafeCss) => {
const { TabBar } = cmp;
return typeSafeCss/* css */ `
.nav-item-container.${theme} {
display: flex;
flex-direction: column;
justify-content: center;
&:focus-within:not(.disabled) {
outline: 2px solid black;
outline-offset: -2px;
border-radius: 4px;
}
.nav-item-underline {
&.selected {
background-color: ${TabBar.Tab.HighlightLine.BackgroundColor.Active.Pressed}
}
}
.nav-item-content-wrapper {
display: flex;
justify-content: center;
&:focus-visible {
outline: none;
}
& > .nav-item {
all: initial;
display: flex;
text-decoration: none;
align-items: center;
flex-shrink: 0;
&.selected {
& > blr-icon {
color: ${TabBar.Tab.Icon.IconColor.Active.Rest};
}
& > label {
color: ${TabBar.Tab.Label.TextColor.Active.Rest};
}
&:focus {
&:not(.disabled) {
& > blr-icon {
color: ${TabBar.Tab.Icon.IconColor.Active.Focus};
}
& > label {
color: ${TabBar.Tab.Label.TextColor.Active.Focus};
}
}
}
&:hover {
&:not(.disabled) {
& > blr-icon {
color: ${TabBar.Tab.Icon.IconColor.Active.Hover};
}
& > label {
color: ${TabBar.Tab.Label.TextColor.Active.Hover};
}
}
}
&:active {
& > blr-icon {
color: ${TabBar.Tab.Icon.IconColor.Active.Pressed};
}
& > label {
color: ${TabBar.Tab.Label.TextColor.Active.Pressed};
}
}
}
&:not(.selected) {
& > blr-icon {
color: ${TabBar.Tab.Icon.IconColor.Inactive.Rest};
}
& > label {
color: ${TabBar.Tab.Label.TextColor.Inactive.Rest};
}
&:focus {
& > blr-icon {
color
: ${TabBar.Tab.Icon.IconColor.Inactive.Focus};
}
& > label {
color: ${TabBar.Tab.Label.TextColor.Inactive.Focus};
}
}
&:hover {
& > blr-icon {
color: ${TabBar.Tab.Icon.IconColor.Inactive.Hover};
}
& > label {
color: ${TabBar.Tab.Label.TextColor.Inactive.Hover};
}
}
&:active {
& > blr-icon {
color: ${TabBar.Tab.Icon.IconColor.Inactive.Pressed};
}
& > label {
color: ${TabBar.Tab.Label.TextColor.Inactive.Pressed};
}
}
&.disabled {
& > blr-icon {
color: ${TabBar.Tab.Icon.IconColor.Inactive.Disabled};
}
& > label {
color: ${TabBar.Tab.Label.TextColor.Inactive.Disabled};
}
}
}
&:focus-visible {
outline: none;
}
&.leading {
flex-direction: row;
}
&.trailing {
flex-direction: row-reverse;
}
}
}
&.sm {
padding-top: ${TabBar.Tab.ContentCol.PaddingTop.SM};
gap: ${TabBar.Tab.ContentCol.ItemSpacing.SM};
.nav-item-content-wrapper {
& > .nav-item {
padding-left: ${TabBar.Tab.ContentRow.Padding_H.SM};
padding-right: ${TabBar.Tab.ContentRow.Padding_H.SM};
gap: ${TabBar.Tab.ContentRow.ItemSpacing.SM};
line-height: ${TabBar.Tab.Label.Typography.SM.lineHeight};
& > blr-icon {
width: ${TabBar.Tab.Icon.IconSize.SM};
height: ${TabBar.Tab.Icon.IconSize.SM};
}
}
}
.nav-item-underline {
height: ${TabBar.Tab.HighlightLine.Height.SM};
}
}
&.md {
padding-top: ${TabBar.Tab.ContentCol.PaddingTop.MD};
gap: ${TabBar.Tab.ContentCol.ItemSpacing.MD};
.nav-item-content-wrapper {
& .nav-item {
padding-left: ${TabBar.Tab.ContentRow.Padding_H.MD};
padding-right: ${TabBar.Tab.ContentRow.Padding_H.MD};
gap: ${TabBar.Tab.ContentRow.ItemSpacing.MD};
line-height: ${TabBar.Tab.Label.Typography.MD.lineHeight};
& blr-icon {
width: ${TabBar.Tab.Icon.IconSize.MD};
height: ${TabBar.Tab.Icon.IconSize.MD};
}
}
}
.nav-item-underline {
height: ${TabBar.Tab.HighlightLine.Height.MD};
}
}
&.lg {
padding-top: ${TabBar.Tab.ContentCol.PaddingTop.LG};
gap: ${TabBar.Tab.ContentCol.ItemSpacing.LG};
.nav-item-content-wrapper {
& > .nav-item {
padding-left: ${TabBar.Tab.ContentRow.Padding_H.LG};
padding-right: ${TabBar.Tab.ContentRow.Padding_H.LG};
gap: ${TabBar.Tab.ContentRow.ItemSpacing.LG};
line-height: ${TabBar.Tab.Label.Typography.LG.lineHeight};
& > blr-icon {
width: ${TabBar.Tab.Icon.IconSize.LG};
height: ${TabBar.Tab.Icon.IconSize.LG};
}
}
}
.nav-item-underline {
height: ${TabBar.Tab.HighlightLine.Height.LG};
}
}
}
`;
})}
`;
Loading

0 comments on commit 8de1f59

Please sign in to comment.