LedgerUI.Components.AppShell (LedgerUI v0.2.0)

Copy Markdown View Source

The application shell: the page frame, the main sidebar (the icon rail), the sidebar panel with its collapsible groups, the minimized panel, the sideblock, the horizontal navigation, the header, the right sidebar, the framed menu, the page header and the mode toggles.

<.app_shell id="shell" sidebar_open={@sidebar_open} on_toggle="sidebar">
  <:sidebar>
    <.main_sidebar current={@current_path}>
      <:logo navigate={~p"/"}><.icon name="grid" /></:logo>
      <:item navigate={~p"/dashboards"} label="Dashboards"><.icon name="home" /></:item>
    </.main_sidebar>
    <.sidebar_panel title="Layouts">
      <.sidebar_nav>
        <.sidebar_nav_link navigate={~p"/orders"} current={@current_path}>Orders</.sidebar_nav_link>
      </.sidebar_nav>
    </.sidebar_panel>
  </:sidebar>
  <:header><.header /></:header>
  <.page_header title="Avatar">
    <:crumb navigate={~p"/elements"}>Elements</:crumb>
    <:crumb>Avatar</:crumb>
  </.page_header>
</.app_shell>

The state kept in <body> classes by other kits lives on the shell root: is-sidebar-open (mirrored by the class open, so LedgerUI.open/close/toggle(socket_or_js, "shell") drive it), has-min-sidebar, navigation:sideblock, navigation:horizontal, is-header-blur and is-header-not-sticky.

Hooks used: LedgerUI.AppShell, LedgerUI.Sidebar (framed menu), LedgerUI.RightSidebar, LedgerUI.Clock and LedgerUI.MonochromeToggle; dark mode is theme_toggle/1 and theme_script/1 of LedgerUI.Components.ThemeSwitch.

Written for the lu-* stylesheet: where it has no class (the right sidebar, the framed rail, the phone tab bar) the rules live in priv/static/ledger_ui.css, loaded after ledger.css.

Summary

Functions

The menu of the framed shell: the brand, an optional workspace and search, the navigation (rail_link/1, rail_module/1) and the bottom items. It collapses to a rail of icons (anything with the class rail-label goes away, badges become dots) and the choice is kept in localStorage. Below 768px it is a top bar with a hamburger.

The header: the animated sidebar toggle, the search bar, the dark mode and monochrome toggles, the notifications, the right sidebar toggle and a profile slot. With a :nav slot it is the horizontal navigation header: the :brand and the navigation row below.

The line between the links of a horizontal navigation box.

A link of a horizontal navigation box. A click closes the box.

A dropdown of the horizontal navigation: an icon and a label, and a box of links.

Same as main_sidebar/1 (same attributes and slots), under the name the design vitrine uses.

The main sidebar: the icon rail with the logo, the section links and the bottom links.

One icon link of the main sidebar.

The monochrome mode: the palette button of the header or a switch. It toggles is-monochrome on <body>.

The title of a page. variant="inline" is the row: title (with the breadcrumb above it), a description and the :actions at the right, then the :tabs. variant="page" is the framed shell's title block: a top row (the :leading slot, the crumbs, the clock and the bell) or a back link, the badge, the title with a context line and the actions, and the tabs.

A small uppercase title over a group of rail_link/1s; hidden in the rail.

A page of the framed menu: the icon, the label, an optional badge and a tooltip for the rail.

A module of the framed menu: a button that opens the pages under it.

A button that collapses and expands the framed_sidebar/1 with that id, from anywhere.

The person at the bottom of the framed menu: their picture and, outside the rail, their name.

The workspace switcher under the brand of the framed menu. It is a button: phx-click opens your list.

A drawer from the right with an overlay, a top row (:title and the close button), the content and a :footer. Opened with open, right_sidebar_toggle/1 or LedgerUI.open/close/toggle(id); Esc, the overlay and the close button close it.

The header button that toggles a right_sidebar/1.

Same as app_shell/1 (same attributes and slots), under the name the design vitrine uses.

The line between the lists of the minimized panel.

A list of icon links of the minimized panel.

An icon link of the minimized panel. Active links are accent soft, the others take color.

A list of the sidebar panel (or the sideblock).

The line between the lists of the sidebar panel.

A collapsible group of the sidebar panel. It opens when one of its items is active (or with open).

A plain link of the sidebar panel, active with active or when its path is current.

The sidebar panel next to the main sidebar: its title and the scrolling body.

The minimized sidebar panel (layout="minimal"): a header, the icon links and a footer.

The avatar at the bottom of the main sidebar and the profile box it opens on its right.

The animated hamburger: three bars that turn into an arrow while the sidebar is open.

The sideblock (layout="sideblock"): one wide sidebar with the logo and the navigation.

The sub navigation next to the icon rail: a title and groups of links that open and close.

A phone's bottom bar of tabs: one icon per section, the current one in the accent color.

Functions

app_shell(assigns)

Attributes

  • id (:string) - Defaults to "app-shell".
  • layout (:string) - Defaults to "sidebar". Must be one of "sidebar", "minimal", "sideblock", "horizontal", or "framed".
  • sidebar_open (:boolean) - Defaults to nil.
  • full (:boolean) - Full-screen app (lu-app full): no frame, border, radius or shadow, min-height: 100vh. Without it the non-framed layouts carry the same reset inline. Defaults to false.
  • header_blur (:boolean) - Defaults to true.
  • header_sticky (:boolean) - Defaults to true.
  • persist (:boolean) - Defaults to true.
  • preloader (:boolean) - Defaults to false.
  • on_toggle (:any) - Defaults to nil.
  • target (:any) - Defaults to nil.
  • main_class (:any) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • aside - Fixed parts: the right sidebar, drawers.
  • header - The header/1.
  • inner_block
  • sidebar - The main sidebar and its panel, or the sideblock.
  • tab_bar - A bottom bar of tabs for phones (layout="framed"): a tab_bar/1.

framed_sidebar(assigns)

The menu of the framed shell: the brand, an optional workspace and search, the navigation (rail_link/1, rail_module/1) and the bottom items. It collapses to a rail of icons (anything with the class rail-label goes away, badges become dots) and the choice is kept in localStorage. Below 768px it is a top bar with a hamburger.

Attributes

  • id (:string) (required)
  • collapsed (:boolean) - Defaults to false.
  • persist (:boolean) - Defaults to true.
  • on_collapse (:string) - Defaults to nil.
  • shortcut (:string) - Defaults to "b".
  • target (:any) - Defaults to nil.
  • label (:string) - Defaults to "Main menu".
  • mobile_label (:string) - Defaults to "Menu".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • bottom
  • brand
  • inner_block (required)
  • search - Accepts attributes:
    • id (:string)
    • class (:string)
    • title (:string)
    • aria-label (:string)
    • phx-click (:any)
    • phx-target (:any)
  • wordmark
  • workspace

header(assigns)

The header: the animated sidebar toggle, the search bar, the dark mode and monochrome toggles, the notifications, the right sidebar toggle and a profile slot. With a :nav slot it is the horizontal navigation header: the :brand and the navigation row below.

Attributes

  • id (:string) - Defaults to "app-header".
  • toggle (:boolean) - Defaults to true.
  • search (:boolean) - Defaults to true.
  • search_placeholder (:string) - Defaults to "Search here...".
  • search_input (:map) - Defaults to %{}.
  • theme_toggle (:boolean) - Defaults to true.
  • monochrome_toggle (:boolean) - Defaults to true.
  • right_sidebar (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • actions
  • mobile_search
  • brand - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • src (:string)
    • label (:string)
  • nav
  • notifications - Accepts attributes:
    • dot (:boolean)
    • label (:string)
  • profile
  • search_results
  • start

horizontal_nav_divider(assigns)

The line between the links of a horizontal navigation box.

Attributes

  • class (:any) - Defaults to nil.

horizontal_nav_link(assigns)

A link of a horizontal navigation box. A click closes the box.

Attributes

  • active (:boolean) - Defaults to false.
  • current (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["href", "navigate", "patch", "method", "replace"].

Slots

  • inner_block (required)

horizontal_nav_menu(assigns)

A dropdown of the horizontal navigation: an icon and a label, and a box of links.

Attributes

  • id (:string) (required)
  • label (:string) (required)
  • active (:boolean) - Defaults to false.
  • current (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • icon
  • inner_block
  • item - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • patch (:string)
    • active (:boolean)

icon_rail(assigns)

Same as main_sidebar/1 (same attributes and slots), under the name the design vitrine uses.

Attributes

  • id (:string) - Defaults to "main-sidebar".
  • current (:any) - The current path (matched against each item's link), or an item's name. Defaults to nil.
  • centered (:boolean) - Defaults to false.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • bottom
  • item - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • patch (:string)
    • label (:string)
    • icon (:string) - The name of the icon the link shows (or put it in the slot).
    • name (:any) - Marks the item as active when current is this name.
    • active (:boolean)
    • class (:any)
    • style (:string)
  • logo - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • patch (:string)
    • src (:string)
    • alt (:string)

main_sidebar(assigns)

The main sidebar: the icon rail with the logo, the section links and the bottom links.

Attributes

  • id (:string) - Defaults to "main-sidebar".
  • current (:any) - The current path (matched against each item's link), or an item's name. Defaults to nil.
  • centered (:boolean) - Defaults to false.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • bottom
  • item - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • patch (:string)
    • label (:string)
    • icon (:string) - The name of the icon the link shows (or put it in the slot).
    • name (:any) - Marks the item as active when current is this name.
    • active (:boolean)
    • class (:any)
    • style (:string)
  • logo - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • patch (:string)
    • src (:string)
    • alt (:string)

main_sidebar_link(assigns)

One icon link of the main sidebar.

Attributes

  • label (:string) - The tooltip and the accessible name. Defaults to nil.
  • active (:boolean) - Defaults to false.
  • current (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["href", "navigate", "patch", "method", "replace"].

Slots

  • inner_block (required)

monochrome_toggle(assigns)

The monochrome mode: the palette button of the header or a switch. It toggles is-monochrome on <body>.

Attributes

  • id (:string) - Defaults to "monochrome-toggle".
  • variant (:string) - Defaults to "button". Must be one of "button", or "switch".
  • on_change (:any) - Defaults to nil.
  • target (:any) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block

page_header(assigns)

The title of a page. variant="inline" is the row: title (with the breadcrumb above it), a description and the :actions at the right, then the :tabs. variant="page" is the framed shell's title block: a top row (the :leading slot, the crumbs, the clock and the bell) or a back link, the badge, the title with a context line and the actions, and the tabs.

Attributes

  • title (:string) - The title text. Or give the :title slot. Defaults to nil.
  • title_class (:any) - Classes of the h1 (the canvas animates it with mo-stg). Defaults to nil.
  • variant (:string) - Defaults to "inline". Must be one of "inline", or "page".
  • description (:string) - Defaults to nil.
  • back (:string) - Defaults to nil.
  • back_label (:string) - Defaults to nil.
  • badge_position (:string) - Defaults to "above". Must be one of "above", or "inline".
  • clock (:boolean) - Defaults to false.
  • locale (:string) - Defaults to nil.
  • bell (:boolean) - Defaults to false.
  • bell_label (:string) - Defaults to "Notifications".
  • on_bell (:any) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • actions
  • badge
  • crumb - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • patch (:string)
  • icon
  • inner_block
  • leading
  • notifications
  • subtitle - A description with markup, instead of description.
  • tabs
  • heading - The content of the h1 with markup, instead of title.

rail_heading(assigns)

A small uppercase title over a group of rail_link/1s; hidden in the rail.

Attributes

  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

rail_link(assigns)

A page of the framed menu: the icon, the label, an optional badge and a tooltip for the rail.

Attributes

  • label (:string) (required)
  • badge (:string) - Defaults to nil.
  • active (:boolean) - Defaults to false.
  • current (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted. Supports all globals plus: ["href", "navigate", "patch", "method", "replace"].

Slots

  • inner_block (required)

rail_module(assigns)

A module of the framed menu: a button that opens the pages under it.

Attributes

  • id (:string) (required)
  • label (:string) (required)
  • badge (:string) - Defaults to nil.
  • open (:boolean) - Defaults to nil.
  • current (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • icon (required)
  • item (required) - Accepts attributes:
    • navigate (:string)
    • patch (:string)
    • href (:string)
    • active (:boolean)

rail_toggle(assigns)

A button that collapses and expands the framed_sidebar/1 with that id, from anywhere.

Attributes

  • for (:string) (required) - The id of the framed_sidebar/1.
  • label (:string) - Defaults to "Collapse menu".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block

rail_user(assigns)

The person at the bottom of the framed menu: their picture and, outside the rail, their name.

Attributes

  • name (:string) (required)
  • subtitle (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)

rail_workspace(assigns)

The workspace switcher under the brand of the framed menu. It is a button: phx-click opens your list.

Attributes

  • name (:string) (required)
  • subtitle (:string) - Defaults to nil.
  • initials (:string) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block

right_sidebar(assigns)

A drawer from the right with an overlay, a top row (:title and the close button), the content and a :footer. Opened with open, right_sidebar_toggle/1 or LedgerUI.open/close/toggle(id); Esc, the overlay and the close button close it.

Attributes

  • id (:string) (required)
  • open (:boolean) - Defaults to false.
  • label (:string) - Defaults to "Sidebar".
  • persist_tab (:boolean) - Defaults to false.
  • on_open (:any) - Defaults to nil.
  • on_close (:any) - Defaults to nil.
  • target (:any) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • footer
  • inner_block
  • title

shell_floating(assigns)

Same as app_shell/1 (same attributes and slots), under the name the design vitrine uses.

Attributes

  • id (:string) - Defaults to "app-shell".
  • layout (:string) - Defaults to "sidebar". Must be one of "sidebar", "minimal", "sideblock", "horizontal", or "framed".
  • sidebar_open (:boolean) - Defaults to nil.
  • full (:boolean) - Full-screen app (lu-app full): no frame, border, radius or shadow, min-height: 100vh. Without it the non-framed layouts carry the same reset inline. Defaults to false.
  • header_blur (:boolean) - Defaults to true.
  • header_sticky (:boolean) - Defaults to true.
  • persist (:boolean) - Defaults to true.
  • preloader (:boolean) - Defaults to false.
  • on_toggle (:any) - Defaults to nil.
  • target (:any) - Defaults to nil.
  • main_class (:any) - Defaults to nil.
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • aside - Fixed parts: the right sidebar, drawers.
  • header - The header/1.
  • inner_block
  • sidebar - The main sidebar and its panel, or the sideblock.
  • tab_bar - A bottom bar of tabs for phones (layout="framed"): a tab_bar/1.

sideblock(assigns)

The sideblock (layout="sideblock"): one wide sidebar with the logo and the navigation.

Attributes

  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • inner_block (required)
  • logo - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • patch (:string)
    • src (:string)
    • alt (:string)

tab_bar(assigns)

A phone's bottom bar of tabs: one icon per section, the current one in the accent color.

Attributes

  • label (:string) - Defaults to "Sections".
  • current (:string) - Defaults to nil.
  • variant (:string) - Defaults to "default". Must be one of "default", or "canvas".
  • match (:string) - Defaults to "exact". Must be one of "exact", or "prefix".
  • class (:any) - Defaults to nil.
  • Global attributes are accepted.

Slots

  • tab (required) - Accepts attributes:
    • href (:string)
    • navigate (:string)
    • patch (:string)
    • label (:string)
    • active (:boolean)
    • class (:string)
    • match (:string)