dom

package
v0.0.0-...-e26fe04 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dom provides basic UX controls in FUSS

Index

Constants

View Source
const FlexNone = -1

FlexNone should be used for a zero grow/shrink

Variables

This section is empty.

Functions

func DataUrl

func DataUrl(data []byte, mimeType string) string

DataUrl converts a binary data into a data url

Types

type AFunc

type AFunc = func(key interface{}, styles Styles, href string, children ...Element) Element

AFunc implements the simplified anchor tag

func NewA

func NewA() (update AFunc, closeAll func())

NewA is the constructor for AFunc

type Background

type Background struct {
	Color string
}

Background configures the background css property

type Border

type Border struct {
	Width Size
	Color string
}

Border represents a single border info

type Borders

type Borders struct {
	Raw                      string
	Radius                   Size
	Width                    Size
	Color                    string
	Style                    string
	Left, Right, Top, Bottom Border
}

Borders represents all borders

type BoxShadow

type BoxShadow struct {
	OffsetX, OffsetY         Size
	BlurRadius, SpreadRadius Size
	Color                    string
}

BoxShadow configures box shadow

func (BoxShadow) String

func (b BoxShadow) String() string

String returns a stringified version of the box shadow

type BoxShadows

type BoxShadows struct {
	B1, B2, B3, B4, B5 BoxShadow
}

BoxShadows implements multiple box shadow elements

func (BoxShadows) String

func (b BoxShadows) String() string

String returns a stringified version of the box shadow

type ButtonFunc

type ButtonFunc = func(key interface{}, styles Styles, onClick *EventHandler, children ...Element) Element

ButtonFunc implements a button control.

func NewButton

func NewButton() (update ButtonFunc, closeAll func())

NewButton is the constructor for ButtonFunc

type CheckboxEditFunc

type CheckboxEditFunc = func(key interface{}, styles Styles, checked *streams.Bool, id string) Element

CheckboxEditFunc represents a checkbox control.

func NewCheckboxEdit

func NewCheckboxEdit() (update CheckboxEditFunc, closeAll func())

NewCheckboxEdit is the constructor for CheckboxEditFunc

type Direction

type Direction int

Direction represents a Row or Column direction

const (
	Row Direction = iota + 1
	Column
	RowReverse
	ColumnReverse
)

All the valid directions

func (Direction) String

func (d Direction) String() string

String returns the string version of Direction

type Driver

type Driver interface {
	NewElement(props Props, children ...Element) Element
}

Driver represents the interface to be implemented by drivers. This allows testing in non-browser environments

func RegisterDriver

func RegisterDriver(d Driver) (old Driver)

RegisterDriver allows drivers to register their concrete implementation

type Element

type Element interface {
	// SetProp updates the prop to the provided value
	SetProp(key string, value interface{})

	// Children returns a readonly slice of children
	Children() []Element

	// RemoveChild remove a child element at the provided index
	RemoveChild(index int)

	// InsertChild inserts a child element at the provided index
	InsertChild(index int, elt Element)

	// Close releases any resources held by this resource
	Close()
}

Element represents a raw DOM element to be implemented by a driver

func NewElement

func NewElement(props Props, children ...Element) Element

NewElement creates a new element using the registered driver.

While the children can be specified here, they can also be modified via AddChild/RemoveChild APIs

type Event

type Event interface {
	// CreatedEpochNano is the time when the event fired in UnixNano
	EpochNano() int64

	// Value is applicable for input/change events only
	// TODO: migrate this to a ChangeEvent interface
	Value() string
}

Event is to be implemennted by the driver

type EventHandler

type EventHandler struct {
	Handle func(Event)
}

EventHandler is struct to hold a callback function

This is needed simply to make Props be comparable (which makes it easier to see if anything has changed)

type FixedFunc

type FixedFunc = func(key interface{}, styles Styles, cells ...Element) Element

FixedFunc represents a non-shrinkable container

func NewFixed

func NewFixed() (update FixedFunc, closeAll func())

NewFixed is the constructor for FixedFunc

type FocusableFunc

type FocusableFunc = func(key interface{}, eh *EventHandler, children ...Element) Element

FocusableFunc defines the shape of a control which can receive focus and be selected by clicks.

This is different from a checbox or input in that there are no specific "values" available and it also does not expose actual keyboard events.

Note that there is no programmatic way to focus this element

func NewFocusable

func NewFocusable() (update FocusableFunc, closeAll func())

NewFocusable is the constructor for FocusableFunc

type Font

type Font struct {
	Family string
	Size   Size
	Weight string
}

Font configures the font related css properties

type ImgFunc

type ImgFunc = func(key interface{}, styles Styles, src string) Element

ImgFunc represents an image

func NewImg

func NewImg() (update ImgFunc, closeAll func())

NewImg is the constructor for ImgFunc

type LabelViewFunc

type LabelViewFunc = func(key interface{}, styles Styles, text, inputID string) Element

LabelViewFunc represents a label control.

func NewLabelView

func NewLabelView() (update LabelViewFunc, closeAll func())

NewLabelView is the constructor for LabelViewFunc

type LiveTextEditFunc

type LiveTextEditFunc = func(key interface{}, styles Styles, text *streams.S16, placeholder string) Element

LiveTextEdit provides continuous changes as user keeps typing

func NewLiveTextEdit

func NewLiveTextEdit() (update LiveTextEditFunc, closeAll func())

NewLiveTextEdit is the constructor for LiveTextEditFunc

type Margins

type Margins struct {
	Raw                      string
	Left, Right, Top, Bottom Size
}

Margins represents all margins

type Padding

type Padding struct {
	Raw                      string
	Left, Right, Top, Bottom Size
}

Padding represents all padding

type Props

type Props struct {
	Styles
	Tag         string
	Checked     bool
	Type        string
	TextContent string
	ID          string
	For         string
	Href        string
	Src         string
	Placeholder string
	OnChange    *EventHandler
	OnClick     *EventHandler
	OnFocus     *EventHandler
	OnInput     *EventHandler
}

Props represents the props of an element

func (Props) ToMap

func (p Props) ToMap() map[string]interface{}

ToMap returns the map version of props (useful for diffs)

type RunFunc

type RunFunc = func(key interface{}, styles Styles, cells ...Element) Element

RunFunc represents a paragraph-like flex "row" component

func NewRun

func NewRun() (update RunFunc, closeAll func())

NewRun is the constructor for RunFunc

type Size

type Size struct {
	Raw     string
	Percent float32
	Pixels  float32
	Em      float32
	En      float32
}

Size represents a string, percent or numeric values. If an explicit zero value is needed, it is best to use the string form

func (Size) String

func (s Size) String() string

String converts Size to a string form

type StretchFunc

type StretchFunc = func(key interface{}, styles Styles, cells ...Element) Element

StretchFunc represents a non-shrinkable container

func NewStretch

func NewStretch() (update StretchFunc, closeAll func())

NewStretch is the constructor for StretchFunc

type Styles

type Styles struct {
	Background           Background
	Color                string
	Width, Height        Size
	OverflowX, OverflowY string
	Borders              Borders
	Margins              Margins
	Padding              Padding
	AlignItems           string // TODO add enum
	TextAlign            string // TODO add enum
	BoxShadows           BoxShadows
	Font                 Font
	FlexDirection        Direction

	// FlexGrow and FlexShrink should not be set to zero.
	// For actual zero value, use FlexNone instead
	FlexGrow, FlexShrink int
}

Styles represents a set of CSS Styles

func (Styles) String

func (s Styles) String() string

String converts style to "CSS" text

type TextEditFunc

type TextEditFunc = func(key interface{}, styles Styles, text *streams.S16) Element

TextEditFunc represents a text edit control.

func NewTextEdit

func NewTextEdit() (update TextEditFunc, closeAll func())

NewTextEdit is the constructor for TextEditFunc

type TextEditOFunc

type TextEditOFunc = func(key interface{}, opt TextEditOptions) Element

TextEditOFunc is like TextEditFunc but with extended options

func NewTextEditO

func NewTextEditO() (update TextEditOFunc, closeAll func())

NewTextEditO is the constructor for TextEditOFunc

type TextEditOptions

type TextEditOptions struct {
	Styles
	Placeholder string
	Text        *streams.S16
	RawText     *string
}

TextEditOptions configures a TextEditO control

type TextInputFunc

type TextInputFunc = func(key interface{}, styles Styles, eh *EventHandler, id, placeholder string) Element

TextInput calls the callback when user submits input

func NewTextInput

func NewTextInput() (update TextInputFunc, closeAll func())

NewTextInput is the constructor for TextInputFunc

type TextViewFunc

type TextViewFunc = func(key interface{}, styles Styles, text string) Element

TextViewFunc represeentns a text view control

func NewTextView

func NewTextView() (update TextViewFunc, closeAll func())

NewTextView is the constructor for TextViewFunc

type VRunFunc

type VRunFunc = func(key interface{}, styles Styles, cells ...Element) Element

VRunFunc represents a non-shrinkable container

func NewVRun

func NewVRun() (update VRunFunc, closeAll func())

NewVRun is the constructor for VRunFunc

Directories

Path Synopsis
Package html implements a basic html driver for dom It uses "golang.org/x/net/html" as the basis
Package html implements a basic html driver for dom It uses "golang.org/x/net/html" as the basis
Package js implements a basic gopherjs driver for dom
Package js implements a basic gopherjs driver for dom

Jump to

Keyboard shortcuts

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