Class ShellBuilder

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

public class ShellBuilder extends Object
Builds a full SimplyPages shell document (head + body) or body-only fragment.

Contract: output shape remains stable for integrators: optional header/account regions, optional side nav, and a main content target container.

Mutability and thread-safety: mutable and not thread-safe. Configure once per render flow and do not share mutable instances across concurrent requests.

  • Method Details

    • create

      public static ShellBuilder create()
      Creates a new builder.
    • withTopBanner

      public ShellBuilder withTopBanner(Component topBanner)
      Set the top banner component.
    • withTopNav

      public ShellBuilder withTopNav(Component topNav)
      Set the top navigation component rendered in the header region.
    • withAccountBar

      @Deprecated public ShellBuilder withAccountBar(Component accountBar)
      Deprecated.
      Legacy alias for top navigation configuration.
    • withSideNav

      public ShellBuilder withSideNav(SideNav sideNav)
      Set the side navigation component.
    • withSideNav

      public ShellBuilder withSideNav(SideNav sideNav, boolean collapsible)
      Set the side navigation with collapsible option.
    • withCollapsibleSideNav

      public ShellBuilder withCollapsibleSideNav(boolean collapsible)
      Enable/disable collapsible side navigation.
    • withContentTarget

      public ShellBuilder withContentTarget(String targetId)
      Set the content area target ID for HTMX swaps.
    • withContentTargetId

      public ShellBuilder withContentTargetId(String targetId)
    • withContentTargetClass

      public ShellBuilder withContentTargetClass(String className)
      Set optional class on the content target div.
    • withContentWrapper

      public ShellBuilder withContentWrapper(Function<Component, Component> wrapper)
      Apply a wrapper around the content target component.
    • withPageTitle

      public ShellBuilder withPageTitle(String title)
      Set the page title.
    • withContent

      public ShellBuilder withContent(Component content)
      Sets initial shell content rendered inside the configured content target.

      When initial content is provided, the content target is rendered without the default HTMX auto-load attributes.

    • withHtmx

      public ShellBuilder withHtmx(boolean include)
      Enable/disable HTMX inclusion.

      Full documents and templates that include HTMX initialize the legacy request-origin, DELETE-body and smooth-scroll defaults before custom scripts. Explicit application HTMX configuration remains authoritative. Body fragments do not initialize assets or defaults; their host owns configuration.

    • withCustomCss

      public ShellBuilder withCustomCss(String cssPath)
      Add custom CSS file path.
    • withCustomCss

      public ShellBuilder withCustomCss(List<String> cssPaths)
      Replace all custom CSS paths with the provided ordered list.
    • addCustomCss

      public ShellBuilder addCustomCss(String cssPath)
      Append an additional custom CSS file path.
    • withCustomJs

      public ShellBuilder withCustomJs(String jsPath)
      Replace all custom JS paths with a single JS path.
    • withCustomJs

      public ShellBuilder withCustomJs(List<String> jsPaths)
      Replace all custom JS paths with the provided ordered list.
    • addCustomJs

      public ShellBuilder addCustomJs(String jsPath)
      Append an additional custom JS file path.
    • withFrameworkCss

      public ShellBuilder withFrameworkCss(boolean include)
      Enable/disable framework CSS inclusion.
    • withFrameworkCssPath

      public ShellBuilder withFrameworkCssPath(String cssPath)
      Set framework CSS path used when framework CSS is enabled.
    • build

      public String build()
      Builds a full HTML document string including doctype.
    • buildBody

      public Component buildBody()
      Builds a shell-body fragment containing navigation and the main content target.

      Omits the document, header/banner/top navigation, assets and inline scripts. The host must load framework CSS/JS once (and HTMX when used). Shared framework JS initializes desktop collapse and the mobile drawer, including fragments inserted later. Desktop persistence uses sidebarCollapsed best effort; denied storage does not disable document-local toggling.

    • buildTemplate

      public ShellTemplate buildTemplate()
      Builds a reusable shell template with a dedicated content slot.

      Template mode always uses explicit content rendering and does not emit shell-level content auto-load attributes on the content target.