platformd

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 7 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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Module

type Module struct {
	ID      string    // hash slug, e.g. "products" → routed via "#products"
	Label   string    // text shown next to icon in expanded rail
	Icon    Component // icon component (usually a tinywasm/icons Symbol)
	View    Component // the module's content (often a *rightpanel.RightPanel)
	Default bool      // if true and no hash set, this module is shown initially
}

Module describes one registered route/page in the shell. Pure data: the consumer creates these and passes them to Platform.

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 []Module
	// 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() *svg.Sprite

IconSvg registers the default platform navigation icons. Consumers can register their own icons via Module.Icon using svg.Icon().

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) OnMount

func (p *Platform) OnMount()

OnMount implements Mountable.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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