Documentation
¶
Overview ¶
Package layout provides consistent border styles and spacing utilities for TUI layout. ABOUTME: Border styles and spacing utilities for consistent TUI layout ABOUTME: Provides responsive layout components with Dracula theme integration
Index ¶
- Variables
- func Box(content string, t *theme.Theme) string
- func FocusedBox(content string, t *theme.Theme) string
- func JoinHorizontal(spacing int, elements ...string) string
- func JoinVertical(spacing int, elements ...string) string
- func MaxWidth(width int, content string) string
- func PaddedContent(content string, padding SpacingConfig) string
- func PlaceHorizontal(width int, pos lipgloss.Position, content string) string
- func PlaceVertical(height int, pos lipgloss.Position, content string) string
- func Separator(width int, color lipgloss.Color) string
- func TitledBox(content, title string, t *theme.Theme) string
- func VerticalSeparator(height int, color lipgloss.Color) string
- type BorderSet
- type BorderStyle
- func (b *BorderStyle) Render(content string) string
- func (b *BorderStyle) WithBorder(border BorderSet) *BorderStyle
- func (b *BorderStyle) WithColor(color lipgloss.Color) *BorderStyle
- func (b *BorderStyle) WithFocus(focused bool) *BorderStyle
- func (b *BorderStyle) WithSize(width, height int) *BorderStyle
- func (b *BorderStyle) WithSpacing(spacing SpacingConfig) *BorderStyle
- func (b *BorderStyle) WithTitle(title string, align lipgloss.Position) *BorderStyle
- type SpacingConfig
Constants ¶
This section is empty.
Variables ¶
var ( // RoundedBorder uses rounded corners RoundedBorder = BorderSet{ TopLeft: "╭", Top: "─", TopRight: "╮", Right: "│", BottomRight: "╯", Bottom: "─", BottomLeft: "╰", Left: "│", } // ThickBorder uses thick lines ThickBorder = BorderSet{ TopLeft: "┏", Top: "━", TopRight: "┓", Right: "┃", BottomRight: "┛", Bottom: "━", BottomLeft: "┗", Left: "┃", } // DoubleBorder uses double lines DoubleBorder = BorderSet{ TopLeft: "╔", Top: "═", TopRight: "╗", Right: "║", BottomRight: "╝", Bottom: "═", BottomLeft: "╚", Left: "║", } // NormalBorder uses standard box drawing characters NormalBorder = BorderSet{ TopLeft: "┌", Top: "─", TopRight: "┐", Right: "│", BottomRight: "┘", Bottom: "─", BottomLeft: "└", Left: "│", } )
Common border sets
Functions ¶
func FocusedBox ¶
FocusedBox creates a focused box around content
func JoinHorizontal ¶
JoinHorizontal joins multiple strings horizontally with spacing
func JoinVertical ¶
JoinVertical joins multiple strings vertically with spacing
func PaddedContent ¶
func PaddedContent(content string, padding SpacingConfig) string
PaddedContent adds padding to content without borders
func PlaceHorizontal ¶
PlaceHorizontal positions content horizontally within a width
func PlaceVertical ¶
PlaceVertical positions content vertically within a height
Types ¶
type BorderSet ¶
type BorderSet struct {
TopLeft string
Top string
TopRight string
Right string
BottomRight string
Bottom string
BottomLeft string
Left string
}
BorderSet represents a complete set of border characters
type BorderStyle ¶
type BorderStyle struct {
Border BorderSet
Color lipgloss.Color
Style lipgloss.Style
Spacing SpacingConfig
Width int
Height int
Title string
TitleAlign lipgloss.Position
Focused bool
// contains filtered or unexported fields
}
BorderStyle creates a lipgloss border style with Dracula theme colors
func NewBorderStyle ¶
func NewBorderStyle(t *theme.Theme) *BorderStyle
NewBorderStyle creates a new border style with Dracula theme
func (*BorderStyle) Render ¶
func (b *BorderStyle) Render(content string) string
Render applies the border and spacing to content
func (*BorderStyle) WithBorder ¶
func (b *BorderStyle) WithBorder(border BorderSet) *BorderStyle
WithBorder sets the border character set
func (*BorderStyle) WithColor ¶
func (b *BorderStyle) WithColor(color lipgloss.Color) *BorderStyle
WithColor sets the border color
func (*BorderStyle) WithFocus ¶
func (b *BorderStyle) WithFocus(focused bool) *BorderStyle
WithFocus sets whether the border is focused
func (*BorderStyle) WithSize ¶
func (b *BorderStyle) WithSize(width, height int) *BorderStyle
WithSize sets the width and height
func (*BorderStyle) WithSpacing ¶
func (b *BorderStyle) WithSpacing(spacing SpacingConfig) *BorderStyle
WithSpacing sets the spacing configuration
func (*BorderStyle) WithTitle ¶
func (b *BorderStyle) WithTitle(title string, align lipgloss.Position) *BorderStyle
WithTitle sets the title and its alignment
type SpacingConfig ¶
type SpacingConfig struct {
PaddingTop int
PaddingRight int
PaddingBottom int
PaddingLeft int
MarginTop int
MarginRight int
MarginBottom int
MarginLeft int
}
SpacingConfig defines padding and margin settings
func NewMargin ¶
func NewMargin(top, right, bottom, left int) SpacingConfig
NewMargin creates a SpacingConfig with only margin
func NewPadding ¶
func NewPadding(top, right, bottom, left int) SpacingConfig
NewPadding creates a SpacingConfig with only padding
func NewSpacing ¶
func NewSpacing(padding, margin int) SpacingConfig
NewSpacing creates a SpacingConfig with uniform padding and margin