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

fix: li classes cascaded from ul #593

Merged
merged 1 commit into from
Mar 1, 2023

Conversation

jjagielka
Copy link
Contributor

πŸ“‘ Description

Navbar: use the setContext to push classes for NavbarLi from 'NavbarUl`. Eliminates the need to repeat the code when navbar is customized.

βœ… Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • I have checked the page with https://validator.unl.edu/
  • All the tests have passed
  • My pull request is based on the latest commit (not the npm version).

β„Ή Additional Information

@stackblitz
Copy link

stackblitz bot commented Mar 1, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@vercel
Copy link

vercel bot commented Mar 1, 2023

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated
flowbite-svelte βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Mar 1, 2023 at 9:10PM (UTC)
flowbite-svelte-update βœ… Ready (Inspect) Visit Preview πŸ’¬ Add your feedback Mar 1, 2023 at 9:10PM (UTC)

@shinokada
Copy link
Collaborator

Can you explain why this PR eliminates the need to repeat the code when the navbar is customized?

@jjagielka
Copy link
Contributor Author

Previously you needed to make:

...
  <NavUl {hidden}>
    <NavLi activeClass="text-red" nonActiveClass="text-blue" href="/" active={true}>Home</NavLi>
    <NavLi activeClass="text-red" nonActiveClass="text-blue" href="/about">About</NavLi>
    <NavLi activeClass="text-red" nonActiveClass="text-blue" href="/services">Services</NavLi>
    <NavLi activeClass="text-red" nonActiveClass="text-blue" href="/pricing">Pricing</NavLi>
    <NavLi activeClass="text-red" nonActiveClass="text-blue" href="/contact">Contact</NavLi>
  </NavUl>
...

now you can do like:

...
  <NavUl activeClass="text-red" nonActiveClass="text-blue" {hidden}>
    <NavLi href="/" active={true}>Home</NavLi>
    <NavLi href="/about">About</NavLi>
    <NavLi href="/services">Services</NavLi>
    <NavLi href="/pricing">Pricing</NavLi>
    <NavLi href="/contact">Contact</NavLi>
  </NavUl>
...

as using setContext NavUl will push the classes to NavLis

@shinokada shinokada merged commit 90a4c74 into themesberg:main Mar 1, 2023
@shinokada
Copy link
Collaborator

Published in v0.30.6.
Thank you for your PR.

@shinokada
Copy link
Collaborator

And also you can add a custom class to an individual li, if you want:

...
  <NavUl activeClass="text-red" nonActiveClass="text-blue" {hidden}>
    <NavLi href="/" active={true}>Home</NavLi>
    <NavLi href="/about" activeClass="text-blue">About</NavLi>
    <NavLi href="/services">Services</NavLi>
...
  </NavUl>
...

@jjagielka jjagielka deleted the navbar-context branch April 4, 2023 21:24
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

Successfully merging this pull request may close these issues.

None yet

2 participants