Skip to content

Commit

Permalink
ExampleApp: Allow the header links and name to be passed in as option…
Browse files Browse the repository at this point in the history
…al params to createApp (#1939)

* Add the ability to optionally pass in the app title and header links for createApp

* Rush change
  • Loading branch information
christiango authored and dzearing committed Jun 5, 2017
1 parent cb40744 commit 90b3bd3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/example-app-base",
"comment": "Add the ability to optionally pass in the app title and header links for createApp",
"type": "minor"
}
],
"packageName": "@uifabric/example-app-base",
"email": "[email protected]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "",
"packageName": "@uifabric/utilities",
"type": "none"
}
],
"packageName": "@uifabric/utilities",
"email": "[email protected]"
}
16 changes: 13 additions & 3 deletions packages/example-app-base/src/utilities/createApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
import * as React from 'react';
/* tslint:enable:no-unused-variable */
import * as ReactDOM from 'react-dom';
import { App, IAppDefinition } from '../components/App/App';
import { App, IAppDefinition, IAppLink } from '../components/App/App';
import { Router, Route } from 'office-ui-fabric-react/lib/utilities/router/index';
import { setBaseUrl } from 'office-ui-fabric-react/lib/Utilities';
import { Fabric } from 'office-ui-fabric-react/lib/Fabric';

import { ExampleGroup, IExample } from './examplesOf';

export function createApp(examples: ExampleGroup | ExampleGroup[], hideChrome?: boolean) {
export function createApp(examples: ExampleGroup | ExampleGroup[], hideChrome?: boolean, appTitle?: string, headerLinks?: IAppLink[]) {
let rootElement: HTMLElement | null;
let groups: ExampleGroup[] = !Array.isArray(examples) ? [examples] : examples;

Expand All @@ -28,13 +28,23 @@ export function createApp(examples: ExampleGroup | ExampleGroup[], hideChrome?:
/>
)));

let appDefinition = _getDefinition(groups);

if (appTitle) {
appDefinition.appTitle = appTitle;
}

if (headerLinks) {
appDefinition.headerLinks = headerLinks;
}

ReactDOM.render(
<Fabric>
<Router>
<Route key='minimal' path='?minimal' component={ (props) => <div { ...props } /> }>
{ routes }
</Route>
<Route key={ 'app' } component={ (props) => <App appDefinition={ _getDefinition(groups) } { ...props } /> }>
<Route key={ 'app' } component={ (props) => <App appDefinition={ appDefinition } { ...props } /> }>
{ routes }
</Route>
</Router>
Expand Down

0 comments on commit 90b3bd3

Please sign in to comment.