Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExampleApp: Allow the header links and name to be passed in as optional params to createApp #1939

Merged
merged 2 commits into from
Jun 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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