Skip to content

Commit 4fb2e54

Browse files
committed
feat(components): top bar component
1 parent 3018547 commit 4fb2e54

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import {gecutButton, type ButtonContent} from '../button/button.js';
2-
import {iconButton} from '../icon-button/icon-button.js';
1+
import {gecutButton} from '../button/button.js';
2+
import {gecutIconButton} from '../icon-button/icon-button.js';
33

4-
import type {IconButtonContent} from '../icon-button/icon-button.js';
4+
import type {EndIconType} from './_type.js';
55

6-
export const endIconListTemplate = (_list?: (IconButtonContent | ButtonContent)[]) => {
6+
export const endIconListTemplate = (_list?: EndIconType[]) => {
77
return _list?.map((content) => {
8-
if ('type' in content) {
9-
return gecutButton(content);
8+
if (content.element === 'icon-button') {
9+
return gecutIconButton(content);
1010
}
1111

12-
return iconButton(content);
12+
return gecutButton(content);
1313
});
1414
};
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import type {ButtonContent} from '../button/button.js';
22
import type {IconButtonContent} from '../icon-button/icon-button.js';
33

4+
export type EndIconType = (IconButtonContent & {element: 'icon-button'}) | (ButtonContent & {element: 'button'});
5+
46
export interface TopBarContent {
57
title: string;
68

79
startIcon?: IconButtonContent;
8-
endIconList?: (IconButtonContent | ButtonContent)[];
10+
endIconList?: EndIconType[];
911
}

packages/components/src/top-bar/center-top-bar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {classMap} from 'lit/directives/class-map.js';
22
import {html, nothing} from 'lit/html.js';
33

44
import {endIconListTemplate} from './_end-icon-list.js';
5-
import {iconButton} from '../icon-button/icon-button.js';
5+
import {gecutIconButton} from '../icon-button/icon-button.js';
66

77
import type {TopBarContent} from './_type.js';
88

@@ -11,7 +11,7 @@ export const gecutCenterTopBar = (content: TopBarContent, scroll = false) =>
1111
class="z-sticky flex h-16 shrink-0 grow-0 select-none items-center
1212
bg-surface [&.scroll]:bg-surfaceContainer ${classMap({scroll})}"
1313
>
14-
${content.startIcon ? iconButton(content.startIcon) : nothing}
14+
${content.startIcon ? gecutIconButton(content.startIcon) : nothing}
1515
1616
<div class="lead grow overflow-clip whitespace-nowrap px-1 text-center text-titleLarge text-onSurface">
1717
${content.title}

packages/components/src/top-bar/small-top-bar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {classMap} from 'lit/directives/class-map.js';
22
import {html, nothing} from 'lit/html.js';
33

44
import {endIconListTemplate} from './_end-icon-list.js';
5-
import {iconButton} from '../icon-button/icon-button.js';
5+
import {gecutIconButton} from '../icon-button/icon-button.js';
66

77
import type {TopBarContent} from './_type.js';
88

@@ -11,7 +11,7 @@ export const gecutSmallTopBar = (content: TopBarContent, scroll = false) =>
1111
class="z-sticky flex h-16 shrink-0 grow-0 select-none items-center
1212
bg-surface [&.scroll]:bg-surfaceContainer ${classMap({scroll})}"
1313
>
14-
${content.startIcon ? iconButton(content.startIcon) : nothing}
14+
${content.startIcon ? gecutIconButton(content.startIcon) : nothing}
1515
1616
<div class="lead me-auto overflow-clip whitespace-nowrap px-1 text-center text-titleLarge text-onSurface">
1717
${content.title}

0 commit comments

Comments
 (0)