flexbox

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2023 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 Cell

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

Cell is a building block object of the FlexBox, it represents a single cell within a box A FlexBox stacks cells horizonally. A HorizontalFlexBox stacks cells vertically. (controverse, isn't it?)

func NewCell

func NewCell(ratioX, ratioY int) *Cell

NewCell initialize FlexBoxCell object with defaults

func (*Cell) GetContent

func (r *Cell) GetContent() string

GetContent returns the cells raw content

func (*Cell) GetContentHeight

func (r *Cell) GetContentHeight() int

func (*Cell) GetContentWidth

func (r *Cell) GetContentWidth() int

func (*Cell) GetHeight

func (r *Cell) GetHeight() int

GetHeight returns real height of the cell

func (*Cell) GetStyle

func (r *Cell) GetStyle() lipgloss.Style

GetStyle returns the copy of the cells current style

func (*Cell) GetWidth

func (r *Cell) GetWidth() int

GetWidth returns real width of the cell

func (*Cell) SetContent

func (r *Cell) SetContent(content string) *Cell

SetContent sets the cells content

func (*Cell) SetID

func (r *Cell) SetID(id string) *Cell

SetID sets the cells ID

func (*Cell) SetMinHeigth

func (r *Cell) SetMinHeigth(value int) *Cell

SetMinHeigth sets the cells minimum height, this will not disable responsivness. This has only an effect to cells of a HorizontalFlexBox.

func (*Cell) SetMinWidth

func (r *Cell) SetMinWidth(value int) *Cell

SetMinWidth sets the cells minimum width, this will not disable responsivness. This has only an effect to cells of a normal FlexBox, not a HorizontalFlexBox.

func (*Cell) SetStyle

func (r *Cell) SetStyle(style lipgloss.Style) *Cell

SetStyle replaces the style, it unsets width/height related keys

type Column

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

Column is the container for the cells, this object has the least to do with the ratio of the construction as it takes all of the needed ratio information from the cell slice columns are stacked horizontally.

func (*Column) AddCells

func (r *Column) AddCells(cells ...*Cell) *Column

AddCells appends the cells to the column if the cell ID is not set it will default to the index of the cell

func (*Column) CellsLen

func (r *Column) CellsLen() int

CellsLen returns the len of the cells slice

func (*Column) GetCell

func (r *Column) GetCell(index int) *Cell

GetCell returns the Cell on the given index if it exists note: forces the recalculation if found

returns nil if not found

func (*Column) GetCellCopy

func (r *Column) GetCellCopy(index int) *Cell

GetCellCopy returns a copy of the Cell on the given index, if cell does not exist it will return nil. This is useful when you need to get cells attribute without triggering a recalculation.

func (*Column) GetCellWithID

func (r *Column) GetCellWithID(id string) *Cell

GetCellWithID returns the cell with the given ID if existing note: forces the recalculation if found

returns nil if not found

func (*Column) SetStyle

func (r *Column) SetStyle(style lipgloss.Style) *Column

SetStyle replaces the style, it unsets width/height related keys

func (*Column) StylePassing

func (r *Column) StylePassing(value bool) *Column

StylePassing set whether the style should be passed to the cells

func (*Column) UpdateCellWithIndex

func (r *Column) UpdateCellWithIndex(index int, cell *Cell)

UpdateCellWithIndex replaces the cell on the given index if it exists if its not existing no changes will apply

type FlexBox

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

FlexBox responsive box grid insipred by CSS flexbox

func New

func New(width, height int) *FlexBox

New initialize FlexBox object with defaults

func (*FlexBox) AddRows

func (r *FlexBox) AddRows(rows []*Row) *FlexBox

AddRows appends additional rows to the FlexBox

func (*FlexBox) ForceRecalculate

func (r *FlexBox) ForceRecalculate()

ForceRecalculate forces the recalculation for the box and all the rows

func (*FlexBox) GetCellByID

func (r *FlexBox) GetCellByID(id string) *Cell

GetCellByID returns the Cell with the given id if it exists. note: forces the recalculation if found returns nil if not found, if there are multiple cells with the same id it will return the first one.

func (*FlexBox) GetHeight

func (r *FlexBox) GetHeight() int

GetHeight yields current FlexBox height

func (*FlexBox) GetRow

func (r *FlexBox) GetRow(index int) *Row

GetRow returns the Row on the given index if it exists note: forces the recalculation if found

returns nil if not found

func (*FlexBox) GetRowCellCopy

func (r *FlexBox) GetRowCellCopy(rowIndex, cellIndex int) *Cell

GetRowCellCopy returns a copy of the FlexBoxCell on the given index x, within the given row with index y, if row or cell do not exist it will return nil. This is useful when you need to get rows attribute without triggering a recalculation.

func (*FlexBox) GetRowCopy

func (r *FlexBox) GetRowCopy(index int) *Row

GetRowCopy returns a copy of the Row on the given index, if row does not exist it will return nil. Copied row also gets copies of the cells. This is useful when you need to get rows attribute without triggering a recalculation.

func (*FlexBox) GetWidth

func (r *FlexBox) GetWidth() int

GetWidth yields current FlexBox width

func (*FlexBox) LockRowHeight

func (r *FlexBox) LockRowHeight(value int) *FlexBox

LockRowHeight sets the fixed height value for all the rows this will disable vertical scaling

func (*FlexBox) NewRow

func (r *FlexBox) NewRow() *Row

NewRow initialize a new Row with width inherited from the FlexBox

func (*FlexBox) Render

func (r *FlexBox) Render() string

Render initiates the recalculation of the rows dimensions(height) if the recalculate flag is on, and then it renders all the rows and combines them on the vertical axis

func (*FlexBox) RowsLen

func (r *FlexBox) RowsLen() int

RowsLen returns the len of the rows slice

func (*FlexBox) SetHeight

func (r *FlexBox) SetHeight(value int) *FlexBox

SetHeight sets the FlexBox height

func (*FlexBox) SetRows

func (r *FlexBox) SetRows(rows []*Row) *FlexBox

SetRows replace rows on the FlexBox

func (*FlexBox) SetStyle

func (r *FlexBox) SetStyle(style lipgloss.Style) *FlexBox

SetStyle replaces the style, it unsets width/height related keys

func (*FlexBox) SetWidth

func (r *FlexBox) SetWidth(value int) *FlexBox

SetWidth sets the FlexBox width

func (*FlexBox) StylePassing

func (r *FlexBox) StylePassing(value bool) *FlexBox

StylePassing set whether the style should be passed to the rows

func (*FlexBox) UpdateRow

func (r *FlexBox) UpdateRow(index int, row *Row) *FlexBox

UpdateRow replaces the Row on the given index

type HorizontalFlexBox

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

HorizontalFlexBox responsive box grid insipred by CSS flexbox

func NewHorizontal

func NewHorizontal(width, height int) *HorizontalFlexBox

NewHorizontal initialize a HorizontalFlexBox object with defaults

func (*HorizontalFlexBox) AddColumns

func (r *HorizontalFlexBox) AddColumns(columns []*Column) *HorizontalFlexBox

AddColumns appends additional columns to the FlexBox

func (*HorizontalFlexBox) ColumnsLen

func (r *HorizontalFlexBox) ColumnsLen() int

ColumnsLen returns the len of the columns slice

func (*HorizontalFlexBox) ForceRecalculate

func (r *HorizontalFlexBox) ForceRecalculate()

ForceRecalculate forces the recalculation for the box and all the columns

func (*HorizontalFlexBox) GetCellByID

func (r *HorizontalFlexBox) GetCellByID(id string) *Cell

GetCellByID returns the Cell with the given id if it exists. note: forces the recalculation if found returns nil if not found, if there are multiple cells with the same id it will return the first one.

func (*HorizontalFlexBox) GetColumn

func (r *HorizontalFlexBox) GetColumn(index int) *Column

GetColumn returns the FlexBoxColumn on the given index if it exists note: forces the recalculation if found

returns nil if not found

func (*HorizontalFlexBox) GetColumnCellCopy

func (r *HorizontalFlexBox) GetColumnCellCopy(columnIndex, cellIndex int) *Cell

GetColumnCellCopy returns a copy of the FlexBoxCell on the given index x, within the given column with index y, if column or cell do not exist it will return nil. This is useful when you need to get columns attribute without triggering a recalculation.

func (*HorizontalFlexBox) GetColumnCopy

func (r *HorizontalFlexBox) GetColumnCopy(index int) *Column

GetColumnCopy returns a copy of the FlexBoxColumn on the given index, if column does not exist it will return nil. Copied column also gets copies of the cells. This is useful when you need to get columns attribute without triggering a recalculation.

func (*HorizontalFlexBox) GetHeight

func (r *HorizontalFlexBox) GetHeight() int

GetHeight yields current FlexBox height

func (*HorizontalFlexBox) GetWidth

func (r *HorizontalFlexBox) GetWidth() int

GetWidth yields current FlexBox width

func (*HorizontalFlexBox) LockColumnWidth

func (r *HorizontalFlexBox) LockColumnWidth(value int) *HorizontalFlexBox

LockColumnWidth sets the fixed width value for all the columns this will disable horizontal scaling

func (*HorizontalFlexBox) NewColumn

func (r *HorizontalFlexBox) NewColumn() *Column

NewColumn initialize a new FlexBoxColumn with width inherited from the FlexBox

func (*HorizontalFlexBox) Render

func (r *HorizontalFlexBox) Render() string

Render initiates the recalculation of the columns dimensions(width) if the recalculate flag is on, and then it renders all the columns and combines them on the horizontal axis

func (*HorizontalFlexBox) SetColumns

func (r *HorizontalFlexBox) SetColumns(columns []*Column) *HorizontalFlexBox

SetColumns replace columns on the FlexBox

func (*HorizontalFlexBox) SetHeight

func (r *HorizontalFlexBox) SetHeight(value int) *HorizontalFlexBox

SetHeight sets the FlexBox height

func (*HorizontalFlexBox) SetStyle

func (r *HorizontalFlexBox) SetStyle(style lipgloss.Style) *HorizontalFlexBox

SetStyle replaces the style, it unsets width/height related keys

func (*HorizontalFlexBox) SetWidth

func (r *HorizontalFlexBox) SetWidth(value int) *HorizontalFlexBox

SetWidth sets the FlexBox width

func (*HorizontalFlexBox) StylePassing

func (r *HorizontalFlexBox) StylePassing(value bool) *HorizontalFlexBox

StylePassing set whether the style should be passed to the columns

func (*HorizontalFlexBox) UpdateColumn

func (r *HorizontalFlexBox) UpdateColumn(index int, column *Column) *HorizontalFlexBox

UpdateColumn replaces the FlexBoxColumn on the given index

type Row

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

Row is the container for the cells, this object has the least to do with the ratio of the construction as it takes all of the needed ratio information from the cell slice rows are stacked vertically

func (*Row) AddCells

func (r *Row) AddCells(cells ...*Cell) *Row

AddCells appends the cells to the row if the cell ID is not set it will default to the index of the cell

func (*Row) CellsLen

func (r *Row) CellsLen() int

CellsLen returns the len of the cells slice

func (*Row) GetCell

func (r *Row) GetCell(index int) *Cell

GetCell returns the FlexBoxCell on the given index if it exists note: forces the recalculation if found

returns nil if not found

func (*Row) GetCellCopy

func (r *Row) GetCellCopy(index int) *Cell

GetCellCopy returns a copy of the FlexBoxCell on the given index, if cell does not exist it will return nil. This is useful when you need to get cells attribute without triggering a recalculation.

func (*Row) GetCellWithID

func (r *Row) GetCellWithID(id string) *Cell

GetCellWithID returns the cell with the given ID if existing note: forces the recalculation if found

returns nil if not found

func (*Row) SetStyle

func (r *Row) SetStyle(style lipgloss.Style) *Row

SetStyle replaces the style, it unsets width/height related keys

func (*Row) StylePassing

func (r *Row) StylePassing(value bool) *Row

StylePassing set whether the style should be passed to the cells

func (*Row) UpdateCellWithIndex

func (r *Row) UpdateCellWithIndex(index int, cell *Cell)

UpdateCellWithIndex replaces the cell on the given index if it exists if its not existing no changes will apply

Jump to

Keyboard shortcuts

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