Documentation
¶
Index ¶
- Constants
- Variables
- type Brand
- type Identity
- type Platform
- func (p *Platform) Activate(moduleID string)
- func (p *Platform) IconSvg() *sprite.Sprite
- func (p *Platform) Init(ctx Ctx)
- func (p *Platform) Notify(t MessageType, msg string, durationMs int)
- func (p *Platform) Render() *Element
- func (p *Platform) RenderCSS() *css.Stylesheet
- func (p *Platform) RenderSheet() *style.Sheet
- func (p *Platform) WidgetKind() widget.Kind
- func (p *Platform) WidgetName() widget.Name
- type UIModule
Constants ¶
const ( IconUser = svg.Icon("pd-user") IconBrand = svg.Icon("pd-brand") )
const NamePlatform widget.Name = "pd"
Variables ¶
var (
)
Functions ¶
This section is empty.
Types ¶
type Brand ¶ added in v0.1.2
type Brand interface {
// BrandName is shown beside the mark, and is the mark's alt text.
BrandName() string
// BrandMark is a URL or inline SVG data URI. Empty is normal and expected:
// the shell falls back to its own glyph, exactly as UserAvatar does.
BrandMark() string
}
Brand is what the platform calls itself in its own chrome. The shell asks for a mark and a name; how they are drawn, sized and spaced is platformd's business.
It is a READ contract, not a store, mirroring Identity: platformd renders it and never mutates it. The consumer supplies facts, not presentation — a Brand never hands the shell an svg.Icon, because picking the sprite is a rendering decision this package owns (the same reasoning that keeps IconUser out of Identity).
type Identity ¶ added in v0.1.1
type Identity interface {
// UserName is who is logged in.
UserName() string
// UserAvatar is the URL of their picture. Empty is normal and expected.
UserAvatar() string
// UserRoles are display names, not authorization codes. May be empty.
UserRoles() []string
}
Identity is what the platform needs to know about whoever is logged in.
It is a READ contract, not a store: platformd renders it and never mutates it. Whatever owns authentication — github.com/tinywasm/user in a real application — supplies an implementation; the platform neither knows nor cares where the values come from.
It asks for facts, not for presentation. The glyph drawn when there is no avatar is IconUser, which this package owns — an authentication package has no business choosing a sprite, and asking it to would put a rendering decision behind a login.
Roles, plural, because they are plural: a user holds N of them and no ordering exists to say which one matters. Asking for a single "area" forced every implementation to pick arbitrarily, and that decision was invisible.
type Platform ¶
type Platform struct {
Element
// AppName titles the drawer on a phone, where the panel opens wholesale and
// there is room for it. The collapsed rail never shows it: text with no icon
// beside it would have to appear from nowhere when the rail expands.
//
// It is NOT the header brand: AppName belongs to the phone drawer and Brand
// belongs to the desktop header, two surfaces of which only one exists at a
// time. A Brand does not supersede it and it is not a fallback for a missing
// Brand — a platform without a Brand renders no header brand slot at all.
AppName string
// Brand is what the platform calls itself in the header's leading slot:
// the mark and the name at the header's start, mirrored against the user
// menu at its end. Optional — a platform without a logo renders no brand
// slot and the message block stays centred between nothing and the menu.
Brand Brand
// User is the logged-in identity. Required: the header's outer thirds and
// the drawer's first entry are built from it.
User Identity
// UserActions slot — shown at the header RIGHT, next to the work-area name
// (e.g. the light/dark theme toggle). Optional.
// A factory, not a Component: the shell renders one menu per surface and a
// single element cannot have two parents. Passing one instance put the same
// element in both menus, which rendered twice with one id and left the copy
// in the drawer inert.
UserActions func() 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 ¶
Activate programmatically switches to a module by ID (also updates window.location.hash on wasm builds).
func (*Platform) IconSvg ¶ added in v0.0.5
IconSvg registers the default platform chrome glyphs: the identity fallback, the brand fallback and the menu button. The full page sprite is the MERGE of every module's IconSvg() (platformd + crudview + components + the demo modules), assembled by tinywasm/ssr and injected inline in <body>.
Content icons (what a module calls itself) live with their module, in platformd/modules/*: the chassis has no business drawing "home" or "devices".
func (*Platform) Init ¶ added in v0.0.6
func (p *Platform) Init(ctx Ctx)
Init initializes the platform state and routing.
func (*Platform) Notify ¶
Notify queues a typed notification in the proper viewport slot. Any non-zero durationMs → schedule dismissal; duration 0 → persistent message.
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
RenderSheet returns the style Sheet containing the rules for platformd.
func (*Platform) WidgetKind ¶ added in v0.0.23
func (*Platform) WidgetName ¶ added in v0.0.23
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.
Directories
¶
| Path | Synopsis |
|---|---|
|
modules
|
|
|
about
Package about es el módulo demo de una pantalla de información estática.
|
Package about es el módulo demo de una pantalla de información estática. |
|
devices
Package devices es el módulo demo de un CRUD completo: modelo real, backend en memoria y crudview montado sobre él.
|
Package devices es el módulo demo de un CRUD completo: modelo real, backend en memoria y crudview montado sobre él. |
|
home
Package home es el módulo demo más simple: un rightpanel con un artículo y nada más.
|
Package home es el módulo demo más simple: un rightpanel con un artículo y nada más. |