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

Navbar component missing #47

Open
rhanka opened this issue Jan 9, 2020 · 2 comments
Open

Navbar component missing #47

rhanka opened this issue Jan 9, 2020 · 2 comments

Comments

@rhanka
Copy link

rhanka commented Jan 9, 2020

Navbar is a usefull component, which i awlays use it on web sites and even apps : matchid.io, previsecours.fr, ...

Unfortunately, I can't use this promising lib for now because of the Navbar component.
Navbar is quite rich and the only real need of a component is in the "Burger" behavior, needed for responsiveness.

This lib seems very promising. Using a lib with bulma and *.js (vue, react) is always a question for me. And it has a relative big impact on the velocity of coding. This one seem very promising.

@rhanka rhanka changed the title Navbar component Navbar component missing Jan 9, 2020
@jinxmcg
Copy link

jinxmcg commented Jun 9, 2020

I don't know if you really need a component for that, however you can just simply add this functionality just by adding the html and the javascript part straight from the https://bulma.io/documentation/components/navbar/ demo on the bulma.io site

it just works.

nav.svelte

the javascript and html (it is really copy paste from bulma.io demo)


 <script>
        import { onMount,afterUpdate } from 'svelte'
	onMount(() => {
		const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);

		// Check if there are any navbar burgers
		if ($navbarBurgers.length > 0) {
			// Add a click event on each of them
			$navbarBurgers.forEach( el => {
				el.addEventListener('click', () => {
					// Get the target from the "data-target" attribute
					const target = el.dataset.target;
					const $target = document.getElementById(target);
					// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
					el.classList.toggle('is-active');
					$target.classList.toggle('is-active');
				});
			});
		}
	});
       // in case you want to close it after user selects a different menu option
	afterUpdate(() => {
		const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger.is-active,.navbar-menu.is-active'), 0);
		if ($navbarBurgers.length > 0) {
			$navbarBurgers.forEach( el => {
				el.classList.toggle('is-active');
			});
		}
	});	


</script>



<nav class="navbar" role="navigation" aria-label="main navigation">
  <div class="navbar-brand">
    <a class="navbar-item" href="https://bulma.io">
      <img src="https://bulma.io/images/bulma-logo.png" width="112" height="28">
    </a>

    <a role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="navbarBasicExample">
      <span aria-hidden="true"></span>
      <span aria-hidden="true"></span>
      <span aria-hidden="true"></span>
    </a>
  </div>

  <div id="navbarBasicExample" class="navbar-menu">
    <div class="navbar-start">
      <a class="navbar-item">
        Home
      </a>

      <a class="navbar-item">
        Documentation
      </a>

      <div class="navbar-item has-dropdown is-hoverable">
        <a class="navbar-link">
          More
        </a>

        <div class="navbar-dropdown">
          <a class="navbar-item">
            About
          </a>
          <a class="navbar-item">
            Jobs
          </a>
          <a class="navbar-item">
            Contact
          </a>
          <hr class="navbar-divider">
          <a class="navbar-item">
            Report an issue
          </a>
        </div>
      </div>
    </div>

    <div class="navbar-end">
      <div class="navbar-item">
        <div class="buttons">
          <a class="button is-primary">
            <strong>Sign up</strong>
          </a>
          <a class="button is-light">
            Log in
          </a>
        </div>
      </div>
    </div>
  </div>
</nav>

@abbychau
Copy link
Collaborator

I usually uses the native html code for navbar too.

Please comment here if you have any abstraction ideas.

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

3 participants