Add ability to include navigation bar items outside of the collapsible menu.#786
Add ability to include navigation bar items outside of the collapsible menu.#786JPToroDev wants to merge 10 commits intotwostraws:mainfrom JPToroDev:grid
Conversation
#Conflicts: # Sources/Ignite/Elements/NavigationBar.swift # Sources/Ignite/Framework/ElementTypes/HTML.swift
|
Thank you for your patience! I'm back from vacation now, and getting through emails/PRs across various projects. Rather than a second trailing closure, I wonder whether a modifier on items might work better? I'm thinking something like this: NavigationBar(logo: "My Awesome Site") {
Link("Tables", target: TableExamples())
.navigationBarVisibility(.always)
}The default would be I'm not saying one option is better than the other; just looking for alternatives! |
|
I hope you had a great vacation, Paul—I know it was well deserved! We’re on the same wavelength here. When I first closed the PR it was to experiment with a modifier-based approach. There was something in the implementation at the time that made it clunky, but that obstacle’s since been removed. So perhaps something like:
with options like I’ve conformed What do you think? |
|
Actually, with the introduction of |
My thinking is that at rendering time, we filter the items array twice, once to look for always placements, and one to look for automatic placements, then effectively recreate the second array of items at that point. How would
I'm not sure either of those really tell me what the behavior is. Are there two behaviors here, or three?
"Call to action" isn't giving me "this will always be visible" vibes, and "primary" feels like "most important" rather than "this will be hidden when collapsed." |
For sure—the technical side is straightforward either way.
Agreed, mirroring SwiftUI isn't best here. If we went with a modifier-based approach, perhaps this would be better?
Just two behaviors:
These two images showcase these behaviors: The nav bar above is made from code like this: NavigationBar {
Link(“Home”, target: “/“)
} actions: {
Link(“Download”, target: “/“)
.linkStyle(.button)
Spacer()
}A modifier-based approach would look like this: NavigationBar {
Link(“Home”, target: “/“)
Spacer()
.navigationItemBehavior(.permanent)
Link(“Download”, target: “/“)
.linkStyle(.button)
.navigationItemBehavior(.permanent)
}But users could also write that code other ways, like the following, which might lead to things getting muddied: NavigationBar {
Spacer()
.navigationItemBehavior(.permanent)
Link(“Home”, target: “/“)
Link(“Download”, target: “/“)
.linkStyle(.button)
.navigationItemBehavior(.permanent)
} |
|
This just isn't working for me. When I see "navigation item behavior permanent," my brain immediately tries to figure out what permanent behavior means – what behavior is being made permanent? To me this is a question of visibility. Is there a reason why |
|
Besides the modifier approach's obfuscating readability, I think this has the potential to be confusing: Link(“Home”, target: “/“)
.navigationBarVisibility(.always)
.hidden(small: true) // sets ‘display: none’ at different breakpointsBut if you don’t think so, I’m fine with it. |
|
Well, it's that or something like However, if someone says "make it always visible, but hidden when in small mode," I'm not sure that's strictly a problem? |
|
I think either With the modifier approach, I think it'd be nice to add a Does that sound like a good path forward? |
|
Okay, let's go with |


This PR adds the ability to include trailing items to a navigation bar that will not be included in the hamburger menu on small screen sizes—perfect for controls like
FormandButton.