Skip to content

Commit 49f2577

Browse files
authored
feat: Allow customized Page and TopBar titles (argoproj#164) (argoproj#165)
Signed-off-by: Keith Chong <[email protected]>
1 parent 8152ba7 commit 49f2577

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

src/components/page/page.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ require('./page.scss');
1212
interface PageProps extends React.Props<any> {
1313
title: string;
1414
toolbar?: Toolbar | Observable<Toolbar>;
15+
topBarTitle?: string;
16+
useTitleOnly?: boolean;
1517
}
1618

1719
export interface PageContextProps {
@@ -32,7 +34,7 @@ export const Page = (props: PageProps) => {
3234
<PageContext.Consumer>
3335
{(ctx) => {
3436
let titleParts = [ctx.title];
35-
if (toolbar && toolbar.breadcrumbs && toolbar.breadcrumbs.length > 0) {
37+
if (!props.useTitleOnly && toolbar && toolbar.breadcrumbs && toolbar.breadcrumbs.length > 0) {
3638
titleParts = [toolbar.breadcrumbs.map((item) => item.title).reverse().join(' / ')].concat(titleParts);
3739
} else if (props.title) {
3840
titleParts = [props.title].concat(titleParts);
@@ -45,7 +47,7 @@ export const Page = (props: PageProps) => {
4547
}}
4648
</PageContext.Consumer>
4749
<div className='page__top-bar'>
48-
<TopBar title={props.title} toolbar={toolbar}/>
50+
<TopBar title={props.topBarTitle ? props.topBarTitle : props.title} toolbar={toolbar}/>
4951
</div>
5052
</React.Fragment>
5153
)}

stories/page.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,18 @@ storiesOf('Page', module)
124124
</Route>
125125
</Router>
126126
);
127-
});
127+
}).add('custom top bar title', () => (
128+
<Router history={history}>
129+
<Route path={location.pathname}>
130+
<Layout navItems={navItems}>
131+
<Page title='helmet title' topBarTitle='Top Bar Title' toolbar={{ breadcrumbs: [{title: 'Apps ' , path: '/applications'}, {title: 'app name'}] }}>
132+
<div style={{padding: '1em'}}>
133+
<div className='white-box'>
134+
Test
135+
</div>
136+
</div>
137+
</Page>
138+
</Layout>
139+
</Route>
140+
</Router>
141+
));

0 commit comments

Comments
 (0)