components

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attributes

type Attributes map[string]string

Attributes represents all html attributes.

type Base

type Base struct {
	Tag string

	Attr Attributes
	// contains filtered or unexported fields
}

Base is the generic representation of all components.

func NewBase

func NewBase(tag string, attr Attributes, children ...Component) *Base

NewBase returns an instance of Component with given values.

func (*Base) AddChild

func (b *Base) AddChild(child Component) Component

AddChild adds a new Component as a children to current Component.

func (*Base) Build

func (b *Base) Build() Component

Build will set all base values for the Component, and then create the element for it.

func (*Base) GetElement

func (b *Base) GetElement() js.Value

GetElement returns the js.Value of the current

func (*Base) GetFather

func (b *Base) GetFather() js.Value

GetFather returns current component's father.

func (*Base) SetFather

func (b *Base) SetFather(father Component) Component

SetFather assigns a given Component as a father of the current Component.

type Button

type Button struct {
	Component
}

Button represents the <button> tag.

type Component

type Component interface {
	// Build builds the components
	Build() Component
	// GetElement returns current Component's element.
	GetElement() js.Value
	// SetFather sets the father of
	// current Component
	SetFather(Component) Component
	// GetFather gets the father of
	// current Component
	GetFather() js.Value
	// AddChildren adds a new Component as a chieldren
	// to current Component.
	AddChild(Component) Component
}

Component contains all base functions for a Component.

func GetIndex

func GetIndex() Component

GetIndex returns a Component instance of the index <div>.

func NewButton

func NewButton(attr Attributes, children ...Component) Component

NewButton returns an instance of Div with given attr

func NewDiv

func NewDiv(attr Attributes, children ...Component) Component

NewDiv returns an instance of Div with given attr

type Div

type Div struct {
	Base
	Component
}

Div represents the <div> tag.

type Node

type Node struct {
	Element  Component
	Father   Component
	Children []Node
}

Node represents the structure to build a page.

func (Node) Build

func (n Node) Build() error

Build starts iterating all Elements and Childrens, and building each one.

Jump to

Keyboard shortcuts

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