box

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

package box contains Box a highly configurable building block for retort apps.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Box

func Box(p r.Properties) r.Element

Box is the basic building block for a retort app. Box implements the Box Model, see Properties

Types

type Align

type Align int
const (
	AlignAuto Align = iota
	AlignStart
	AlignCenter
	AlignEnd
)

type Border

type Border struct {
	Style      BorderStyle
	Background tcell.Color
	Foreground tcell.Color
}

type BorderStyle

type BorderStyle int
const (
	BorderStyleNone BorderStyle = iota
	BorderStyleSingle
	BorderStyleDouble
	BorderStyleBox // Box drawing characters
)

type Direction

type Direction int
const (
	DirectionRow Direction = iota
	DirectionRowReverse
	DirectionColumn
	DirectionColumnReverse
)

type Label

type Label struct {
	Value   string
	Wrap    LabelWrap
	Align   Align
	Margin  Margin
	Padding Padding
}

Label is a decorative string that can be added to the top or bottom border

Margin allows you to move the whole label around, while Padding allows you to define the gap between the Wrap and Value. If no Padding is specified a single column is still added to each side of the Value.

type LabelWrap

type LabelWrap int
const (
	LabelWrapNone LabelWrap = iota
	LabelWrapBracket
	LabelWrapBrace
	LabelWrapChevron
	LabelWrapSquareBracket
)

type Margin

type Margin struct {
	Top    int
	Right  int
	Bottom int
	Left   int
}

type Overflow

type Overflow int
const (
	OverflowScroll Overflow = iota
	OverflowNone
	OverflowScrollX
	OverflowScrollY
)

type Padding

type Padding struct {
	Top    int
	Right  int
	Bottom int
	Left   int
}

type Properties

type Properties struct {
	// ZIndex is the layer this Box is rendered on, with larger numbers appearing
	// on top.
	ZIndex int

	Align Align

	// Content Box
	// If neither Width,Height or Rows,Columns are set, it will be calculated
	// automatically  When set this is the percentage width and height.
	// Ignored when Rows,Columns is not 0
	Width, Height int // 0 = auto

	// Set the size fixed in rows and columns.
	// Ignored if 0
	// If both Rows and Width are set Rows with be used.
	Rows, Columns int

	Grow int

	// Padding Box
	Padding Padding
	Margin  Margin

	Direction Direction

	// Border
	Border Border

	Background tcell.Color
	Foreground tcell.Color

	Overflow Overflow

	MinHeight int
	MinWidth  int

	// Title is a Label placed on the top border
	Title Label

	// Footer is a Label place on the bottom border
	Footer Label
}

Properties are passed along with box.Box tocreate and configure a Box element

Contents

The contents of the Box is not rendered by this component

Box Sizing

Box Sizing is Border Box only Border and padding is accounted for inside the width and height, meaning the Box can never be bigger than the width or height.

Jump to

Keyboard shortcuts

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