layout

package
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

templ: version: v0.3.1020

templ: version: v0.3.1020

templ: version: v0.3.1020

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func App added in v0.1.1

func App(data AppLayoutData, actions templ.Component) templ.Component

func Public added in v0.1.1

func Public(title string, isDemo bool) templ.Component
func Sidebar(data AppLayoutData) templ.Component

Types

type AppLayoutData

type AppLayoutData struct {
	Version        string
	User           CurrentUser
	CurrentPath    string // used by sidebar for active-state highlight
	PageTitle      string
	Subtitle       string // optional topbar subtitle
	Breadcrumbs    []Crumb
	BasePath       string        // "/@handle" for company-scoped pages; "" on setup/auth
	Company        *CompanyInfo  // nil on setup/auth pages
	OwnerCompanies []CompanyInfo // non-empty for owners with multiple companies

	// OpenSessionURL links to the current user's own open POS session, if
	// any — drives the persistent "Continue POS" topbar button. Empty means
	// the user has no open session right now.
	OpenSessionURL string

	SidebarCollapsed bool // mirrors the sidebar_state cookie, for SSR with no flash-of-wrong-state

	IsDemo bool // true on public demo deployments — shows a persistent reset-notice banner
}

AppLayoutData is passed to every authenticated page layout.

func (*AppLayoutData) MoneyLabel

func (d *AppLayoutData) MoneyLabel(base string) string

MoneyLabel returns the base label with the currency code appended if configured. e.g. MoneyLabel("Price") → "Price (IDR)" or just "Price" when no currency is set.

type CompanyInfo

type CompanyInfo struct {
	ID         uuid.UUID
	Name       string
	Handle     string
	Currency   string // ISO 4217, e.g. "IDR", "USD"; empty means not configured
	LogoFileID *uuid.UUID
}

CompanyInfo is a lightweight company reference for layout templates.

func (*CompanyInfo) CurrencyLabel

func (c *CompanyInfo) CurrencyLabel() string

Currency returns the company's ISO 4217 currency code, or an empty string if not set.

func (*CompanyInfo) LogoURL

func (c *CompanyInfo) LogoURL(basePath string) string

LogoURL returns the URL for this company's logo, or "" if it has none. The file ID is appended as a cache-busting query param — the route itself is a fixed "/company/logo" regardless of which file is currently set, so without this the browser's long-lived cache (see the logo route's Cache-Control) would keep serving a replaced/removed logo's old bytes.

type Crumb

type Crumb struct {
	Label string
	Href  string // empty = current page (non-linked)
}

Crumb is a single breadcrumb entry. Href should be empty for the current (last) page — rendered as plain text.

type CurrentUser

type CurrentUser struct {
	ID        uuid.UUID
	Name      string
	Role      string     // "owner" | "manager" | "cashier"
	CompanyID *uuid.UUID // nil for owners
}

CurrentUser holds the authenticated user's identity extracted from JWT claims.

func (CurrentUser) IsAtLeastManager

func (u CurrentUser) IsAtLeastManager() bool

IsAtLeastManager reports whether the current user is a manager or owner.

func (CurrentUser) IsOwner

func (u CurrentUser) IsOwner() bool

IsOwner reports whether the current user has the owner role.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL