widget

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultKind kind = iota
	Primary
	Success
	Neutral
	Warning
	Dangerous
)
View Source
const (
	DefaultShape shape = iota
	Outline
	Pill
	Circle
)

Variables

View Source
var (
	PrimaryColor = NewColor("primary", 500)
	SuccessColor = NewColor("success", 500)
	WarningColor = NewColor("warning", 500)
	DangerColor  = NewColor("danger", 500)
	NeutralColor = NewColor("neutral", 500)
	Black        = NewColor("neutral", 0)
	White        = NewColor("neutral", 1000)
	Gray         = NewColor("gray", 500)
	Red          = NewColor("red", 500)
	Orange       = NewColor("orange", 500)
	Amber        = NewColor("amber", 500)
	Yellow       = NewColor("yellow", 500)
	Lime         = NewColor("lime", 500)
	Green        = NewColor("green", 500)
	Emerald      = NewColor("emerald", 500)
	Teal         = NewColor("teal", 500)
	Cyan         = NewColor("cyan", 500)
	Sky          = NewColor("sky", 500)
	Blue         = NewColor("blue", 500)
	Indigo       = NewColor("indigo", 500)
	Violet       = NewColor("violet", 500)
	Purple       = NewColor("purple", 500)
	Fuchsia      = NewColor("fuchsia", 500)
	Pink         = NewColor("pink", 500)
	Rose         = NewColor("rose", 500)
)
View Source
var (
	TwoXSmall   = NewFontSize("2x-small")
	XSmall      = NewFontSize("x-small")
	Small       = NewFontSize("small")
	Medium      = NewFontSize("medium")
	Large       = NewFontSize("large")
	XLarge      = NewFontSize("x-large")
	TwoXLarge   = NewFontSize("2x-large")
	ThreeXLarge = NewFontSize("3x-large")
	FourXLarge  = NewFontSize("4x-large")
)

Functions

func Shape

func Shape(s shape) func(*ButtonOption)

func Type

func Type(k kind) func(*ButtonOption)

Types

type Base

type Base struct {
	// contains filtered or unexported fields
}

func NewBase

func NewBase() Base

func (*Base) Align

func (b *Base) Align(ta TextAlign) Widget

func (*Base) Attach

func (b *Base) Attach(a *core.App)

func (*Base) BgColor

func (b *Base) BgColor(bg *Color) Widget

func (*Base) BorderColor

func (b *Base) BorderColor(c *Color) Widget

func (*Base) BorderRadius

func (b *Base) BorderRadius(r int) Widget

func (*Base) Build

func (b *Base) Build() Widget

func (*Base) Detach

func (b *Base) Detach()

func (*Base) FgColor

func (b *Base) FgColor(fg *Color) Widget

func (*Base) FixedHeight

func (b *Base) FixedHeight(height int) Widget

func (*Base) FixedRatioHeight

func (b *Base) FixedRatioHeight(height int) Widget

func (*Base) FixedRatioWidth

func (b *Base) FixedRatioWidth(width int) Widget

func (*Base) FixedSize

func (b *Base) FixedSize(w, h int) Widget

func (*Base) FixedWidth

func (b *Base) FixedWidth(width int) Widget

func (*Base) FontSize

func (b *Base) FontSize(size *FontSize) Widget

func (*Base) Height

func (b *Base) Height() int

func (*Base) ID

func (b *Base) ID() core.WidgetID

func (*Base) Margin

func (b *Base) Margin(n int) Widget

func (*Base) OnChange

func (b *Base) OnChange(handler func(ev core.Event)) Widget

func (*Base) OnClick

func (b *Base) OnClick(handler func(ev core.Event)) Widget

func (*Base) OtherStyle

func (b *Base) OtherStyle() *OtherStyle

func (*Base) Padding

func (b *Base) Padding(n int) Widget

func (*Base) SetHeight

func (b *Base) SetHeight(height int) Widget

func (*Base) SetSize

func (b *Base) SetSize(width, height int) Widget

func (*Base) SetSizePolicy

func (b *Base) SetSizePolicy(sp SizePolicy) Widget

func (*Base) SetSizeStyle

func (b *Base) SetSizeStyle(s string)

func (*Base) SetTextStyle

func (b *Base) SetTextStyle(style *TextStyle) Widget

func (*Base) SetWidget

func (b *Base) SetWidget(w Widget)

func (*Base) SetWidth

func (b *Base) SetWidth(width int) Widget

func (*Base) SizePolicy

func (b *Base) SizePolicy() SizePolicy

func (*Base) SizeStyle

func (b *Base) SizeStyle() string

func (*Base) TextStyle

func (b *Base) TextStyle() *TextStyle

func (*Base) Update

func (b *Base) Update()

func (*Base) VerticalAlign

func (b *Base) VerticalAlign(va VerticalAlign) Widget

func (*Base) View

func (b *Base) View() string

func (*Base) Width

func (b *Base) Width() int

type BoolStateModel

type BoolStateModel struct {
	Model
	// contains filtered or unexported fields
}

func BoolState

func BoolState(value bool) *BoolStateModel

func (*BoolStateModel) SetValue

func (b *BoolStateModel) SetValue(value bool)

func (*BoolStateModel) String

func (b *BoolStateModel) String() string

func (*BoolStateModel) Value

func (b *BoolStateModel) Value() bool

type ButtonModel

type ButtonModel struct {
	Model
	// contains filtered or unexported fields
}

func NewButtonModel

func NewButtonModel(label string) *ButtonModel

func (*ButtonModel) Disable

func (bm *ButtonModel) Disable()

func (*ButtonModel) Enable

func (bm *ButtonModel) Enable()

func (*ButtonModel) Label

func (bm *ButtonModel) Label() string

func (*ButtonModel) Loading

func (bm *ButtonModel) Loading(flag bool)

func (*ButtonModel) SetLabel

func (bm *ButtonModel) SetLabel(label string)

type ButtonOption

type ButtonOption struct {
	// contains filtered or unexported fields
}

func (*ButtonOption) String

func (o *ButtonOption) String() string

type ButtonWidget

type ButtonWidget struct {
	Base
	// contains filtered or unexported fields
}

func Button

func Button(label string, options ...func(*ButtonOption)) *ButtonWidget

func ButtonWithModel

func ButtonWithModel(m *ButtonModel, options ...func(*ButtonOption)) *ButtonWidget

func (*ButtonWidget) Disable

func (b *ButtonWidget) Disable() *ButtonWidget

func (*ButtonWidget) Enable

func (b *ButtonWidget) Enable() *ButtonWidget

func (*ButtonWidget) Label

func (b *ButtonWidget) Label() string

func (*ButtonWidget) SetLabel

func (b *ButtonWidget) SetLabel(label string) *ButtonWidget

func (*ButtonWidget) View

func (b *ButtonWidget) View() string

type Color

type Color struct {
	// contains filtered or unexported fields
}

func NewColor

func NewColor(name string, swatchNum int) *Color

func (*Color) String

func (c *Color) String() string

type ColumnLayout

type ColumnLayout struct {
	Layout
}

func Column

func Column(children ...Widget) *ColumnLayout

func (*ColumnLayout) View

func (c *ColumnLayout) View() string

type Component

type Component struct {
	Base
	// contains filtered or unexported fields
}

func NewComponent

func NewComponent(builder func() Widget) *Component

func (*Component) Attach

func (c *Component) Attach(a *core.App)

func (*Component) Detach

func (c *Component) Detach()

func (*Component) View

func (c *Component) View() string

type DataRow

type DataRow struct {
	Items []string
}

type DataTableStyle

type DataTableStyle struct{}

func (*DataTableStyle) String

func (s *DataTableStyle) String() string

type DataTableWidget

type DataTableWidget struct {
	Base
	// contains filtered or unexported fields
}

func DataTable

func DataTable(m *TableModel) *DataTableWidget

func (*DataTableWidget) SetStyle

func (dt *DataTableWidget) SetStyle(style *DataTableStyle) *DataTableWidget

func (*DataTableWidget) View

func (dt *DataTableWidget) View() string

type DividerWidget

type DividerWidget struct {
	Base
}

func Divider

func Divider() *DividerWidget

func (*DividerWidget) View

func (d *DividerWidget) View() string

type EventPublisher

type EventPublisher interface {
	AddListener(w Widget)
	Notify()
}

type FontSize

type FontSize struct {
	// contains filtered or unexported fields
}

func NewFontSize

func NewFontSize(name string) *FontSize

func (*FontSize) String

func (fs *FontSize) String() string

type HeaderRow

type HeaderRow struct {
	Labels []string
}

type InputModel

type InputModel struct {
	Model
	// contains filtered or unexported fields
}

func NewInputModel

func NewInputModel(t InputType, placeholder string) *InputModel

func (*InputModel) InputType

func (im *InputModel) InputType() InputType

func (*InputModel) Placeholder

func (im *InputModel) Placeholder() string

func (*InputModel) SetInputType

func (im *InputModel) SetInputType(inputType InputType)

func (*InputModel) SetPlaceholder

func (im *InputModel) SetPlaceholder(placeholder string)

type InputType

type InputType int
const (
	TextInputType InputType = iota
	DateInputType
	EmailInputType
	NumberInputType
	PasswordInputType
	SearchInputType
	TelInputType
	URLInputType
)

func (InputType) String

func (i InputType) String() string

type InputWidget

type InputWidget struct {
	Base
	// contains filtered or unexported fields
}

func Input

func Input(inputType InputType, placeholder string) *InputWidget

func InputWithModel

func InputWithModel(m *InputModel) *InputWidget

func (*InputWidget) View

func (i *InputWidget) View() string

type IntStateModel

type IntStateModel struct {
	Model
	// contains filtered or unexported fields
}

func IntState

func IntState(value int) *IntStateModel

func (*IntStateModel) Add

func (i *IntStateModel) Add(n int)

func (*IntStateModel) Decrement

func (i *IntStateModel) Decrement()

func (*IntStateModel) Div

func (i *IntStateModel) Div(n int)

func (*IntStateModel) Increment

func (i *IntStateModel) Increment()

func (*IntStateModel) Mul

func (i *IntStateModel) Mul(n int)

func (*IntStateModel) SetString

func (i *IntStateModel) SetString(value string)

func (*IntStateModel) SetValue

func (i *IntStateModel) SetValue(value int)

func (*IntStateModel) String

func (i *IntStateModel) String() string

func (*IntStateModel) Sub

func (i *IntStateModel) Sub(n int)

func (*IntStateModel) Value

func (i *IntStateModel) Value() int

type Layout

type Layout struct {
	Base
	// contains filtered or unexported fields
}

func NewLayout

func NewLayout(children ...Widget) Layout

func (*Layout) Add

func (l *Layout) Add(w Widget)

func (*Layout) Attach

func (l *Layout) Attach(a *core.App)

func (*Layout) Children

func (l *Layout) Children() []Widget

func (*Layout) Detach

func (l *Layout) Detach()

func (*Layout) Remove

func (l *Layout) Remove(w Widget)

func (*Layout) View

func (l *Layout) View() string

type Model

type Model struct {
	// contains filtered or unexported fields
}

func NewModel

func NewModel() Model

func (*Model) AddListener

func (m *Model) AddListener(b Widget)

func (*Model) Notify

func (m *Model) Notify()

type OtherStyle

type OtherStyle struct {
	// contains filtered or unexported fields
}

func (*OtherStyle) String

func (s *OtherStyle) String() string

type RowLayout

type RowLayout struct {
	Layout
}

func Row

func Row(children ...Widget) *RowLayout

func (*RowLayout) View

func (r *RowLayout) View() string

type SizePolicy

type SizePolicy int
const (
	Fixed SizePolicy = iota
	FixedWidth
	FixedRatioWidth
	FixedHeight
	FixedRatioHeight
	Expanding
)

type SpacerWidget

type SpacerWidget struct {
	Base
}

func Spacer

func Spacer() *SpacerWidget

func (*SpacerWidget) View

func (s *SpacerWidget) View() string

type StrStateModel

type StrStateModel struct {
	Model
	// contains filtered or unexported fields
}

func StrState

func StrState(value string) *StrStateModel

func (*StrStateModel) SetString

func (s *StrStateModel) SetString(value string)

func (*StrStateModel) SetValue

func (s *StrStateModel) SetValue(value string)

func (*StrStateModel) String

func (s *StrStateModel) String() string

type StringEventPublisher

type StringEventPublisher interface {
	EventPublisher
	fmt.Stringer
	SetString(value string)
}

type SwitchModel

type SwitchModel struct {
	Model
	// contains filtered or unexported fields
}

func NewSwitchModel

func NewSwitchModel(checked bool) *SwitchModel

func (*SwitchModel) Checked

func (sm *SwitchModel) Checked() bool

func (*SwitchModel) SetChecked

func (sm *SwitchModel) SetChecked(checked bool)

type SwitchWidget

type SwitchWidget struct {
	Base
	// contains filtered or unexported fields
}

func Switch

func Switch(checked bool, label string) *SwitchWidget

func SwitchWithModel

func SwitchWithModel(b *BoolStateModel, label string) *SwitchWidget

func (*SwitchWidget) View

func (s *SwitchWidget) View() string

type TableData

type TableData struct {
	Header *HeaderRow
	Rows   []*DataRow
}

type TableModel

type TableModel struct {
	Model
	// contains filtered or unexported fields
}

func NewTableModel

func NewTableModel(header *HeaderRow, rows []*DataRow) *TableModel

func (*TableModel) AddRow

func (m *TableModel) AddRow(row *DataRow)

func (*TableModel) Header

func (m *TableModel) Header() *HeaderRow

func (*TableModel) Rows

func (m *TableModel) Rows() []*DataRow

func (*TableModel) SetHeader

func (m *TableModel) SetHeader(header *HeaderRow)

func (*TableModel) SetRows

func (m *TableModel) SetRows(rows []*DataRow)

type TextAlign

type TextAlign int
const (
	Center TextAlign = iota
	Start
	End
	Justify
)

func (TextAlign) String

func (ta TextAlign) String() string

type TextAreaModel

type TextAreaModel struct {
	Model
	// contains filtered or unexported fields
}

func NewTextAreaModel

func NewTextAreaModel(placeholder string) *TextAreaModel

func (*TextAreaModel) Placeholder

func (sm *TextAreaModel) Placeholder() string

func (*TextAreaModel) SetPlaceholder

func (sm *TextAreaModel) SetPlaceholder(placeholder string)

type TextAreaWidget

type TextAreaWidget struct {
	Base
	// contains filtered or unexported fields
}

func TextArea

func TextArea(placeholder string) *TextAreaWidget

func TextAreaWithModel

func TextAreaWithModel(m *TextAreaModel) *TextAreaWidget

func (*TextAreaWidget) View

func (t *TextAreaWidget) View() string

type TextStyle

type TextStyle struct {
	// contains filtered or unexported fields
}

func (*TextStyle) String

func (s *TextStyle) String() string

type TextWidget

type TextWidget struct {
	Base
	// contains filtered or unexported fields
}

func Text

Go 1.18がリリースされたらstring | State[T] のようになるだろう..

func (*TextWidget) SetLabel

func (t *TextWidget) SetLabel(label string)

func (*TextWidget) View

func (t *TextWidget) View() string

type VerticalAlign

type VerticalAlign int
const (
	Middle VerticalAlign = iota
	Baseline
	Top
	Bottom
	Sub
	TextTop
)

func (VerticalAlign) String

func (va VerticalAlign) String() string

type Widget

type Widget interface {
	core.Widget
	Detach()
	Update()
	SetSize(w, h int) Widget
	Width() int
	SetWidth(w int) Widget
	Height() int
	SetHeight(h int) Widget
	SizePolicy() SizePolicy
	SetSizePolicy(sp SizePolicy) Widget
	FixedWidth(n int) Widget
	FixedRatioWidth(n int) Widget
	FixedHeight(n int) Widget
	FixedRatioHeight(n int) Widget
	FixedSize(w, h int) Widget
	SizeStyle() string
	SetSizeStyle(s string)
	TextStyle() *TextStyle
	OtherStyle() *OtherStyle
	SetTextStyle(style *TextStyle) Widget
	Align(ta TextAlign) Widget
	VerticalAlign(va VerticalAlign) Widget
	FgColor(fg *Color) Widget
	BgColor(bg *Color) Widget
	BorderColor(c *Color) Widget
	BorderRadius(r int) Widget
	FontSize(size *FontSize) Widget
	Padding(n int) Widget
	Margin(n int) Widget
	OnClick(func(ev core.Event)) Widget
	OnChange(func(ev core.Event)) Widget
}

func ForEach

func ForEach(items interface{}, builder interface{}) []Widget

Jump to

Keyboard shortcuts

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