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

Question: Can we share the same <header> element across pages? #283

Open
hanvari opened this issue Feb 12, 2018 · 1 comment
Open

Question: Can we share the same <header> element across pages? #283

hanvari opened this issue Feb 12, 2018 · 1 comment

Comments

@hanvari
Copy link

hanvari commented Feb 12, 2018

Is there anyway not to repeat the above <header> code in every single page template and define it only once? all the pages in my app share the same header row with the buttons to side-panel and settings, and I may only want to change the <h1> title.

@hanvari hanvari changed the title Question: Can we share the same <header> element across pages? Question: Can we share the same <header> element across pages? Feb 12, 2018
@qathom
Copy link
Contributor

qathom commented Feb 13, 2018

Hello @hanvari,

It is not possible. You need to register your navbar as a component with React, Angular, Vue etc.
If you want to stay standalone, you can add a simple configuration where you store your navbar such as:

utils.js

function buildInnerNavbar(title) {
  return '' +
          '<a class="btn pull-left">Button</a>' +
            '<div class="center">' +
              '<h1 class="title">' + title + '</h1>' +
            '</div>' +
            '<a class="btn pull-right">Button</a>';
}

const navbar = document.createElement('header');
navbar.classList.add('header-bar');
navbar.innerHTML = buildInnerNavbar('Hello World');

document.querySelector('#myPage').firstChild = navbar;

I coded this example directly here on Github, maybe something is not working.

@qathom qathom added the v1 label Jul 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants