platformd

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 9 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")
)

Variables

View Source
var (
	ClsNavIcon Class = "pd-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 — usually an avatar/name/logout link. Optional.
	UserBlock 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.

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() *Stylesheet

RenderCSS implements CSSProvider.

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