import './page.css'; import { createHeader } from './Header'; export const createPage = () => { const article = document.createElement('article'); let user = null; let header = null; const rerenderHeader = () => { const wrapper = document.getElementsByTagName('article')[0]; wrapper.replaceChild(createHeaderElement(), wrapper.firstChild); }; const onLogin = () => { user = { name: 'Jane Doe' }; rerenderHeader(); }; const onLogout = () => { user = null; rerenderHeader(); }; const onCreateAccount = () => { user = { name: 'Jane Doe' }; rerenderHeader(); }; const createHeaderElement = () => { return createHeader({ onLogin, onLogout, onCreateAccount, user }); }; header = createHeaderElement(); article.appendChild(header); const section = `

Pages in Storybook

We recommend building UIs with a component-driven process starting with atomic components and ending with pages.

Render pages with mock data. This makes it easy to build and review page states without needing to navigate to them in your app. Here are some handy patterns for managing page data in Storybook:

Get a guided tutorial on component-driven development at Storybook tutorials . Read more in the docs .

Tip Adjust the width of the canvas with the Viewports addon in the toolbar
`; article.insertAdjacentHTML('beforeend', section); return article; };