platformd

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: MIT Imports: 11 Imported by: 0

README

tinywasm/layout/platformd

Shell layout with hash-based routing, nav rail, header, and notifications.

Usage

p := &platformd.Platform{
    AppName: "My App",
    Modules: []platformd.Module{
        {
            ID:      "home",
            Label:   "Home",
            Default: true,
            Icon:    svg.Icon("icon-home", "pd-nav-icon"),
            View:    &MyView{},
        },
    },
}
dom.Append("body", p)

Icons

Icons are SVG sprite references. Register them in your consumer's svg.go:

//go:build !wasm
package main

import "github.com/tinywasm/svg"
// or consume Platform's built-in icons (icon-home, icon-products, icon-info)

The platform registers icon-home, icon-products, icon-info by default via Platform.IconSvg().

CSS Tokens

See platformd/tokens.go for the full list of CSS custom properties. All visual customization should go through these tokens.

Documentation

Index

Constants

View Source
const (
	IconHome     = svg.Icon("home")
	IconProducts = svg.Icon("products")
	IconInfo     = svg.Icon("info")
)
View Source
const NamePlatform widget.Name = "pd"

Variables

View Source
var (
	ClsNavIcon = NamePlatform.Class("nav-icon")
)

Functions

This section is empty.

Types

type Platform

type Platform struct {
	Element

	// AppName appears in the header (left side, near UserBlock).
	AppName string

	// UserBlock slot — the logged-in user (name/avatar), shown at the header LEFT.
	UserBlock Component

	// HeaderActions slot — shown at the header RIGHT, next to the work-area name
	// (e.g. the light/dark theme toggle). Optional.
	HeaderActions Component

	// Modules registered in order — appearance order in the nav rail.
	Modules []UIModule

	// CanView filters which modules the shell presents. nil = show all.
	CanView func(resource string) bool

	// DefaultID is the ModelName() of the module to show initially.
	// If empty, the first module is used.
	DefaultID string
	// contains filtered or unexported fields
}

Platform is the typed skeleton root.

func (*Platform) Activate

func (p *Platform) Activate(moduleID string)

Activate programmatically switches to a module by ID (also updates window.location.hash on wasm builds).

func (*Platform) IconSvg added in v0.0.5

func (p *Platform) IconSvg() *sprite.Sprite

IconSvg registers the default platform navigation icons. The full page sprite is the MERGE of every module's IconSvg() (platformd + crudview + components), assembled by tinywasm/ssr and injected inline in <body>.

func (*Platform) Init added in v0.0.6

func (p *Platform) Init(ctx Ctx)

Init initializes the platform state and routing.

func (*Platform) Notify

func (p *Platform) Notify(t MessageType, msg string, durationMs int)

Notify queues a typed notification in the proper viewport slot. Any non-zero durationMs → schedule dismissal; duration 0 → persistent message.

func (*Platform) Render

func (p *Platform) Render() *Element

Render builds the DOM tree (implements ViewRenderer).

func (*Platform) RenderCSS

func (p *Platform) RenderCSS() *css.Stylesheet

RenderCSS implements the visual contract for platformd using the style DSL.

func (*Platform) RenderSheet added in v0.1.0

func (p *Platform) RenderSheet() *style.Sheet

RenderSheet returns the style Sheet containing the rules for platformd.

func (*Platform) WidgetKind added in v0.0.23

func (p *Platform) WidgetKind() widget.Kind

func (*Platform) WidgetName added in v0.0.23

func (p *Platform) WidgetName() widget.Name

type UIModule added in v0.0.7

type UIModule interface {
	layout.Module    // identity: ModelName() → used as ID
	Label() string   // text in the nav rail
	Icon() svg.Icon  // chassis renders via the sprite
	View() Component // module content (often a *rightpanel.RightPanel)
}

UIModule is a module that provides its UI to the platform chassis. The chassis takes id/hash/route from ModelName() and the rest of the presentation from these methods.

func NewUIModule added in v0.0.9

func NewUIModule(id, label string, icon svg.Icon, view Component) UIModule

NewUIModule returns a private implementation of UIModule.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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