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

Multiple nested views #608

Closed
timsim00 opened this issue Dec 11, 2017 · 3 comments
Closed

Multiple nested views #608

timsim00 opened this issue Dec 11, 2017 · 3 comments

Comments

@timsim00
Copy link

Let's say I have an app with multiple tabs, and one tab has a wizard (multiple steps connected via next/back buttons).

Does every view always have to specify the entire page:
return html<id=page> ${header()} ${tabs()} <id=content>some nested view content</content> ${footer()} </page>

Or is there a pattern where a nested view can just returns it's own content?
return html...nested content...

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Dec 11, 2017

AFAICT most people have something like a layout function that you can pass page content to.

function layout (state, content) {
  return html`
    <div id=${state.pageId}>
      ${header()} ${tabs()}
      <div id="content">${content}</div>
      ${footer()}
    </div>
  `
}

function homeView (state, emit) {
  return layout(state, html`
    <h1>Main page content</h1>
  `)
}

app.route('/home', homeView)

you can then use that function anywhere you need the page layout.

@timsim00
Copy link
Author

That makes sense. Thanks, I give it whirl.

@goto-bus-stop
Copy link
Member

there is also a website PR for documentation using a similar approach: choojs/website#43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants