Skip to content

Commit 12d0639

Browse files
committed
feat(components/top-bar): context for title
1 parent 357c226 commit 12d0639

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type {ButtonContent} from '../button/button.js';
22
import type {IconButtonContent} from '../icon-button/icon-button.js';
3+
import type {ContextSignal} from '@gecut/signal';
34

45
export type EndIconType = (IconButtonContent & {element: 'icon-button'}) | (ButtonContent & {element: 'button'});
56

67
export interface TopBarContent {
7-
title: string;
8+
title: string | ContextSignal<string>;
89

910
startIcon?: IconButtonContent;
1011
endIconList?: EndIconType[];

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {gecutContext} from '@gecut/lit-helper/directives/context.js';
12
import {html, nothing} from 'lit/html.js';
23

34
import {endIconListTemplate} from './_end-icon-list.js';
@@ -11,7 +12,7 @@ export const gecutCenterTopBar = (content: TopBarContent) => html`
1112
<div>${content.startIcon ? gecutIconButton(content.startIcon) : nothing}</div>
1213
1314
<div class="gecut-top-bar-title">
14-
<h1>${content.title}</h1>
15+
<h1>${typeof content.title === 'string' ? content.title : gecutContext(content.title)}</h1>
1516
</div>
1617
1718
<div>${endIconListTemplate(content.endIconList)}</div>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const gecutSmallTopBar = (content: TopBarContent) => html`
1111
<div>${content.startIcon ? gecutIconButton(content.startIcon) : nothing}</div>
1212
1313
<div class="gecut-top-bar-title">
14-
<h1>${content.title}</h1>
14+
<h1>${typeof content.title === 'string' ? content.title : gecutContext(content.title)}</h1>
1515
</div>
1616
1717
<div>${endIconListTemplate(content.endIconList)}</div>

0 commit comments

Comments
 (0)