flex

package
v0.1.1 Latest Latest
Warning

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

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

README

Flex

master-gif

Check a guide to flexbox to understand the details.

Currently support:

  • row and column directions on a container
  • grow, shrink and basis properties on a box
  • minsize and maxsize on a box

Examples

You can run examples under ./examples like cd ./examples/flex-row/ && go run .

Tutorial

Create a container and add boxes:

layout := flex.NewContainer(flex.Row).
  AddBox(boxOne, flex.NewStyle().Flex(1)).
  AddBox(boxTwo, flex.NewStyle().Flex(2)).
  AddBox(boxThree, flex.NewStyle().Flex(4))

Here a box need to implement:

type Box interface {
 SetSize(int, int)
 View() string
}

Potential Roadmap

Container

  • add row and column direction properties
  • support style on container
  • add flex-wrap property
  • add justify-content property
  • add align-items property
  • add align-content property
  • add gap, row-gap and column-gap properties
  • add row-reverse and column-reverse properties

Box

  • add flex grow property
  • add flex shrink property
  • add flex basis property
  • add order property
  • add alignment property

Documentation

Index

Constants

View Source
const None = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type Box

type Box interface {
	SetSize(int, int)
	View() string
}

type BoxStyle

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

func NewStyle

func NewStyle() *BoxStyle

func (*BoxStyle) Basis

func (b *BoxStyle) Basis(basis int) *BoxStyle

func (*BoxStyle) Flex

func (b *BoxStyle) Flex(grow float64) *BoxStyle

func (*BoxStyle) FlexAuto

func (b *BoxStyle) FlexAuto(basis int) *BoxStyle

func (*BoxStyle) FlexCustom

func (b *BoxStyle) FlexCustom(grow float64, shrink float64, basis int) *BoxStyle

func (*BoxStyle) FlexDefault

func (b *BoxStyle) FlexDefault() *BoxStyle

func (*BoxStyle) FlexNone

func (b *BoxStyle) FlexNone(basis int) *BoxStyle

func (*BoxStyle) Grow

func (b *BoxStyle) Grow(grow float64) *BoxStyle

func (*BoxStyle) MaxSize

func (b *BoxStyle) MaxSize(maxSize int) *BoxStyle

func (*BoxStyle) MinSize

func (b *BoxStyle) MinSize(minSize int) *BoxStyle

func (*BoxStyle) Shrink

func (b *BoxStyle) Shrink(shrink float64) *BoxStyle

type Container

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

func NewContainer

func NewContainer(direction Direction) *Container

func (*Container) AddBox

func (c *Container) AddBox(box Box, style *BoxStyle) *Container

func (*Container) SetSize

func (c *Container) SetSize(width int, height int)

func (*Container) View

func (c *Container) View() string

type Direction

type Direction int8
const (
	Row Direction = iota
	Column
)

Jump to

Keyboard shortcuts

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