Documentation
¶
Index ¶
- type Component
- type ComponentBase
- func (c *ComponentBase) AddChild(child Component) *ComponentBase
- func (c *ComponentBase) AddChildren(children ...*VNode) *ComponentBase
- func (c *ComponentBase) On(event string, handler func(event js.Value)) *ComponentBase
- func (c *ComponentBase) Render() *VNode
- func (c *ComponentBase) SetClass(class string) *ComponentBase
- func (c *ComponentBase) SetID(id string) *ComponentBase
- func (c *ComponentBase) SetKey(key string) *ComponentBase
- func (c *ComponentBase) SetText(text string) *ComponentBase
- func (c *ComponentBase) Style(s *style.Style) *ComponentBase
- type StatefulComponentBase
- type VNode
- type VNodeType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ComponentBase ¶
type ComponentBase struct {
// contains filtered or unexported fields
}
ComponentBase contains the data and methods common to all components
func NewComponentBase ¶
func NewComponentBase(tag string) ComponentBase
NewComponentBase creates a new component base
func (*ComponentBase) AddChild ¶
func (c *ComponentBase) AddChild(child Component) *ComponentBase
func (*ComponentBase) AddChildren ¶
func (c *ComponentBase) AddChildren(children ...*VNode) *ComponentBase
func (*ComponentBase) On ¶
func (c *ComponentBase) On(event string, handler func(event js.Value)) *ComponentBase
func (*ComponentBase) Render ¶
func (c *ComponentBase) Render() *VNode
Render return simply the internal vNode
func (*ComponentBase) SetClass ¶
func (c *ComponentBase) SetClass(class string) *ComponentBase
func (*ComponentBase) SetID ¶
func (c *ComponentBase) SetID(id string) *ComponentBase
func (*ComponentBase) SetKey ¶
func (c *ComponentBase) SetKey(key string) *ComponentBase
func (*ComponentBase) SetText ¶
func (c *ComponentBase) SetText(text string) *ComponentBase
func (*ComponentBase) Style ¶
func (c *ComponentBase) Style(s *style.Style) *ComponentBase
type StatefulComponentBase ¶
type StatefulComponentBase[T any] struct { ComponentBase // contains filtered or unexported fields }
StatefulComponent is a base struct for the components that need to manage their own state It uses the generic type T to store the state and it is compatible with any State Struct
func NewStatefulComponent ¶
func NewStatefulComponent[T any](tag string, initialState T, reRender func()) StatefulComponentBase[T]
NewStatefulComponent creates a new stateful component
func (*StatefulComponentBase[T]) SetState ¶
func (c *StatefulComponentBase[T]) SetState(state T)
SetState sets the state of the component
func (*StatefulComponentBase[T]) State ¶
func (c *StatefulComponentBase[T]) State() T
State return the state of the component
func (*StatefulComponentBase[T]) UpdateState ¶
func (c *StatefulComponentBase[T]) UpdateState(mutator func(currentState T) T)
UpdateState is an easy way to update the state of the component It takes the "mutator" that receive the current state and return the new state
type VNode ¶
type VNode struct {
Type VNodeType
Tag string // HTML tag name
Text string // Text content
Props map[string]interface{} // Attributes and properties
Children []*VNode // Child nodes
EventHandlers map[string]func(event js.Value) // Event handlers
Key string // Key for list items
Element js.Value // Stck la référence à l'élément DOM
AppliedStyle *style.Style // the style to apply to this node
}
VNode represents a virtual node in the DOM