Documentation
ΒΆ
Index ΒΆ
- Variables
- func Append(parentID string, component Component) error
- func GetHash() string
- func Log(v ...any)
- func OnHashChange(handler func(hash string))
- func Render(parentID string, component Component) error
- func SetHash(hash string)
- func SetLog(log func(v ...any))
- func Update(component Component) error
- type CSSProvider
- type Component
- type CssVars
- type DOM
- type Element
- func A(href string, children ...any) *Element
- func Article(children ...any) *Element
- func Aside(children ...any) *Element
- func Br() *Element
- func Button(children ...any) *Element
- func Canvas(children ...any) *Element
- func Code(children ...any) *Element
- func Details(children ...any) *Element
- func Dialog(children ...any) *Element
- func Div(children ...any) *Element
- func Em(children ...any) *Element
- func Fieldset(children ...any) *Element
- func Figcaption(children ...any) *Element
- func Figure(children ...any) *Element
- func Footer(children ...any) *Element
- func H1(children ...any) *Element
- func H2(children ...any) *Element
- func H3(children ...any) *Element
- func H4(children ...any) *Element
- func H5(children ...any) *Element
- func H6(children ...any) *Element
- func Header(children ...any) *Element
- func Hr() *Element
- func Img(src, alt string) *Element
- func Label(children ...any) *Element
- func Legend(children ...any) *Element
- func Li(children ...any) *Element
- func Main(children ...any) *Element
- func Mark(children ...any) *Element
- func Nav(children ...any) *Element
- func Ol(children ...any) *Element
- func Option(value, text string) *Element
- func P(children ...any) *Element
- func Pre(children ...any) *Element
- func Script(children ...any) *Element
- func Section(children ...any) *Element
- func SelectedOption(value, text string) *Element
- func Small(children ...any) *Element
- func Span(children ...any) *Element
- func Strong(children ...any) *Element
- func Style(children ...any) *Element
- func Summary(children ...any) *Element
- func Svg(children ...any) *Element
- func Table(children ...any) *Element
- func Tbody(children ...any) *Element
- func Td(children ...any) *Element
- func Tfoot(children ...any) *Element
- func Th(children ...any) *Element
- func Thead(children ...any) *Element
- func Tr(children ...any) *Element
- func Ul(children ...any) *Element
- func Use(children ...any) *Element
- func (b *Element) Add(children ...any) *Element
- func (b *Element) Attr(key, val string) *Element
- func (b *Element) Children() []Component
- func (b *Element) Class(class ...string) *Element
- func (b *Element) GetID() string
- func (b *Element) ID(id string) *Element
- func (b *Element) On(t string, h func(Event)) *Element
- func (b *Element) Render(parentID string) error
- func (b *Element) RenderHTML() string
- func (b *Element) SetID(id string)
- func (b *Element) Text(text string) *Element
- func (b *Element) Update() error
- type Event
- type IconSvgProvider
- type JSProvider
- type Mountable
- type Reference
- type Unmountable
- type Updatable
- type ViewRenderer
Constants ΒΆ
This section is empty.
Variables ΒΆ
var ThemeCSS string
Functions ΒΆ
func Append ΒΆ added in v0.2.0
Append injects a component AFTER the last child of the parent element.
func OnHashChange ΒΆ added in v0.0.11
func OnHashChange(handler func(hash string))
OnHashChange registers a hash change listener.
Types ΒΆ
type CSSProvider ΒΆ added in v0.0.13
type CSSProvider interface {
RenderCSS() string
}
CSSProvider is an optional capability: components that provide raw CSS for SSR asset collection (collected by tinywasm/site during static build).
type Component ΒΆ
type Component interface {
GetID() string
SetID(id string)
RenderHTML() string
Children() []Component
}
Component is the minimal interface for components. All components must implement this for both SSR (backend) and WASM (frontend).
type CssVars ΒΆ added in v0.7.0
type CssVars struct {
Primary string `css:"--color-primary"`
Secondary string `css:"--color-secondary"`
Tertiary string `css:"--color-tertiary"`
Quaternary string `css:"--color-quaternary"`
Gray string `css:"--color-gray"`
Selection string `css:"--color-selection"`
Hover string `css:"--color-hover"`
Success string `css:"--color-success"`
Error string `css:"--color-error"`
MenuWidthCollapsed string `css:"--menu-width-collapsed"`
MenuWidthExpanded string `css:"--menu-width-expanded"`
TitleHeight string `css:"--title-height"`
ContentHeight string `css:"--content-height"`
ControlsHeight string `css:"--controls-height"`
SpacingPrimary string `css:"--mag-pri"`
SpacingSecondary string `css:"--mag-sec"`
SpacingQuaternary string `css:"--mag-cua"`
}
CssVars defines the design token set for a tinywasm project. Each field maps to a CSS custom property via the `css` struct tag. Use Render() to generate the :root { } block for SSR injection.
func DefaultCssVars ΒΆ added in v0.7.0
func DefaultCssVars() CssVars
DefaultCssVars returns the default theme token set. Colors are inspired by the official palettes of Go, WebAssembly, JavaScript and HTML5.
This is a FALLBACK theme. Apps override it by calling CssVars.Render() with their own values and injecting the result into <head> before theme.css β CSS cascade ensures the app values win.
type DOM ΒΆ
type DOM interface {
// Render injecta un componente en un elemento padre.
// 1. Llama a componente.Render() (si es ViewRenderer) o componente.RenderHTML()
// 2. Establece el contenido del elemento padre (buscado por parentID)
// 3. Llama a componente.OnMount() para enlazar eventos
Render(parentID string, component Component) error
// Append injecta un componente DESPUΓS del ΓΊltimo hijo del elemento padre.
// Γtil para listas dinΓ‘micas.
Append(parentID string, component Component) error
// OnHashChange registra un listener para cambios en el hash de la URL.
OnHashChange(handler func(hash string))
// GetHash devuelve el hash actual de la URL (ej. "#help").
GetHash() string
// SetHash actualiza el hash de la URL.
SetHash(hash string)
// Update re-renderiza el componente en su posiciΓ³n actual en el DOM.
Update(component Component) error
// Get retrieves an element by ID.
Get(id string) (Reference, bool)
// Log provides logging functionality using the log function passed to New.
Log(v ...any)
}
DOM is the main entry point for interacting with the browser. It is designed to be injected into your components.
type Element ΒΆ
type Element struct {
// contains filtered or unexported fields
}
Element represents a DOM element in the fluent Element API.
func Figcaption ΒΆ added in v0.4.2
func SelectedOption ΒΆ added in v0.4.2
func (*Element) Add ΒΆ added in v0.2.3
Add adds one or more children to the element. Children can be *Element, Node, Component, or string.
func (*Element) Children ΒΆ added in v0.2.3
Children returns the component's children (components only).
func (*Element) Render ΒΆ added in v0.2.3
Render renders the element to the parent. This is a terminal operation.
func (*Element) RenderHTML ΒΆ added in v0.2.3
RenderHTML renders the element to HTML string.
type Event ΒΆ
type Event interface {
// PreventDefault prevents the default action of the event.
PreventDefault()
// StopPropagation stops the event from bubbling up the DOM tree.
StopPropagation()
// TargetValue returns the value of the event's target element.
// Useful for input, textarea, and select elements.
TargetValue() string
// TargetID returns the ID of the event's target element.
TargetID() string
// TargetChecked returns the checked status of the event's target element.
// Useful for checkbox and radio input elements.
TargetChecked() bool
}
Event represents a DOM event.
type IconSvgProvider ΒΆ added in v0.0.13
IconSvgProvider is an optional capability: components that expose SVG icons for the global sprite sheet injected during SSR build.
type JSProvider ΒΆ added in v0.0.13
type JSProvider interface {
RenderJS() string
}
JSProvider is an optional capability: components that provide raw JS for SSR asset collection.
type Mountable ΒΆ added in v0.2.0
type Mountable interface {
OnMount()
}
Mountable is an optional interface for components that need initialization logic.
type Reference ΒΆ added in v0.2.3
type Reference interface {
// GetAttr retrieves an attribute value.
GetAttr(key string) string
// Value returns the current value of an input/textarea/select.
Value() string
// Checked returns the current checked state of a checkbox or radio button.
Checked() bool
// On registers a generic event handler (e.g., "click", "change", "input", "keydown").
On(eventType string, handler func(event Event))
// Focus sets focus to the element.
Focus()
}
Reference represents a reference to a DOM node. It provides methods for reading and interaction.
type Unmountable ΒΆ added in v0.2.0
type Unmountable interface {
OnUnmount()
}
Unmountable is an optional interface for components that need cleanup logic.
type Updatable ΒΆ added in v0.2.0
type Updatable interface {
OnUpdate()
}
Updatable is an optional interface for components that need update logic.
type ViewRenderer ΒΆ added in v0.2.0
type ViewRenderer interface {
Render() *Element
}
ViewRenderer returns a Node tree for declarative UI.