Class TopNavBuilder

java.lang.Object
io.mindspice.simplypages.builders.TopNavBuilder

public class TopNavBuilder extends Object
Builds a top-level navigation component with primary and utility regions.

Contract: generated link entries include HTMX navigation attributes (`hx-get`, `hx-target`, `hx-push-url`) targeting #content-area by default.

Mutability and thread-safety: mutable and not thread-safe. Intended for single request or setup flow use; do not share a builder instance across threads.

  • Method Details

    • create

      public static TopNavBuilder create()
      Creates a new builder instance.
    • withBrand

      public TopNavBuilder withBrand(String brand)
      Sets optional navigation brand text.
    • withClass

      public TopNavBuilder withClass(String className)
      Adds a custom class to the rendered top-nav container.
    • withHtmxNavigation

      public TopNavBuilder withHtmxNavigation(boolean enabled)
      Enables or disables HTMX navigation attributes for generated links.

      When disabled, generated links are standard anchors and trigger full-page navigation.

    • addPrimaryLink

      public TopNavBuilder addPrimaryLink(String text, String href)
      Adds a non-active primary link with an application-controlled or separately validated navigation/HTMX destination. No Link scheme policy is applied.
    • addPrimaryLink

      public TopNavBuilder addPrimaryLink(String text, String href, boolean active)
      Adds a primary link with explicit active state and a trusted/context-validated href. The same URL supplies hx-get when enabled; encoding is not destination validation.
    • addPrimaryComponent

      public TopNavBuilder addPrimaryComponent(Component component)
      Adds a custom primary component.
    • addPrimaryDropdown

      public TopNavBuilder addPrimaryDropdown(String triggerText, Consumer<Dropdown> dropdownConfig)
      Adds a primary dropdown (left-aligned menu).
    • addUtilityLink

      public TopNavBuilder addUtilityLink(String text, String href)
      Adds a utility link with an application-controlled or separately navigation/endpoint-validated href, without Link's scheme policy.
    • addUtilityLink

      public TopNavBuilder addUtilityLink(String text, String href, boolean active)
      Adds a utility link with explicit active state and a trusted/context-validated href. The URL also supplies hx-get when enabled; no destination policy is enforced.
    • addUtilityDropdown

      public TopNavBuilder addUtilityDropdown(String triggerText, Consumer<Dropdown> dropdownConfig)
      Adds a utility dropdown (right-aligned menu).
    • addUtilityComponent

      public TopNavBuilder addUtilityComponent(Component component)
      Adds a custom utility component.
    • withGuestAccountWidget

      public TopNavBuilder withGuestAccountWidget()
      Adds a guest account widget to the utility region.
    • withAuthenticatedAccountWidget

      public TopNavBuilder withAuthenticatedAccountWidget(String username)
      Adds an authenticated account widget to the utility region.
    • withDynamicAccountWidget

      public TopNavBuilder withDynamicAccountWidget(String endpoint)
      Adds an HTMX-loaded account widget using an application-controlled or separately endpoint-validated URL. Encoding does not authorize requests.
    • withAccountWidget

      public TopNavBuilder withAccountWidget(Component widget)
      Adds a custom account widget component to the utility region.
    • addPortal

      @Deprecated public TopNavBuilder addPortal(String name, String path)
      Deprecated.
      Legacy alias for a non-active primary link; path has the application-controlled or separately navigation/endpoint-validated contract of addPrimaryLink(String, String).
    • addPortal

      @Deprecated public TopNavBuilder addPortal(String name, String path, boolean active)
      Deprecated.
      Legacy alias for a primary link with active state; path has the trusted/context-validated contract of addPrimaryLink(String, String, boolean), not Link's scheme policy.
    • withContentTarget

      public TopNavBuilder withContentTarget(String target)
      Sets the HTMX target used for generated links.
    • build

      public NavBar build()
      Builds a new NavBar snapshot from current builder state.