Documentation
¶
Overview ¶
Package layout provides centralized layout management for the Kafui UI. It handles responsive breakpoints, component sizing, and layout calculations.
Index ¶
- type Breakpoints
- type Layout
- type LayoutCalculator
- func (lc *LayoutCalculator) CalculateTableHeight(layout *Layout, reservedLines int) int
- func (lc *LayoutCalculator) CalculateTableWidth(layout *Layout, reservedColumns int) int
- func (lc *LayoutCalculator) GetResponsiveBreakpoint(layout *Layout) string
- func (lc *LayoutCalculator) ShouldShowComponent(layout *Layout, component string) bool
- type LayoutConfig
- type LayoutMode
- type Rectangle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Breakpoints ¶
type Breakpoints struct {
// CompactWidth triggers compact mode when terminal width is below this value
CompactWidth int
// MinimalWidth triggers minimal mode when terminal width is below this value
MinimalWidth int
// CompactHeight triggers compact mode when terminal height is below this value
CompactHeight int
// MinimalHeight triggers minimal mode when terminal height is below this value
MinimalHeight int
}
Breakpoints defines responsive breakpoints for different screen sizes
func DefaultBreakpoints ¶
func DefaultBreakpoints() Breakpoints
DefaultBreakpoints returns the default responsive breakpoints
type Layout ¶
type Layout struct {
// Total dimensions
Width int
Height int
// Component rectangles
Header Rectangle
Sidebar Rectangle
Main Rectangle
Search Rectangle
StatusBar Rectangle
// Layout mode
Mode LayoutMode
// Responsive state
CompactMode bool
SmallScreen bool
}
Layout represents the complete layout configuration for the application
func CalculateLayout ¶
func CalculateLayout(width, height int, config *LayoutConfig) *Layout
CalculateLayout computes the complete layout based on available space and configuration
func (*Layout) GetAvailableHeight ¶
GetAvailableHeight returns the available height for content in the main area
func (*Layout) GetAvailableWidth ¶
GetAvailableWidth returns the available width for content in the main area
func (*Layout) GetContentArea ¶
GetContentArea returns the available content area (main area minus padding)
func (*Layout) IsFooterVisible ¶
IsFooterVisible returns true if the footer should be visible
func (*Layout) IsHeaderVisible ¶
IsHeaderVisible returns true if the header should be visible
func (*Layout) IsSidebarVisible ¶
IsSidebarVisible returns true if the sidebar should be visible
type LayoutCalculator ¶
type LayoutCalculator struct {
// contains filtered or unexported fields
}
LayoutCalculator provides methods for calculating layout-related values
func NewLayoutCalculator ¶
func NewLayoutCalculator(config *LayoutConfig) *LayoutCalculator
NewLayoutCalculator creates a new layout calculator with the given configuration
func (*LayoutCalculator) CalculateTableHeight ¶
func (lc *LayoutCalculator) CalculateTableHeight(layout *Layout, reservedLines int) int
CalculateTableHeight calculates the appropriate table height for the main content area
func (*LayoutCalculator) CalculateTableWidth ¶
func (lc *LayoutCalculator) CalculateTableWidth(layout *Layout, reservedColumns int) int
CalculateTableWidth calculates the appropriate table width for the main content area
func (*LayoutCalculator) GetResponsiveBreakpoint ¶
func (lc *LayoutCalculator) GetResponsiveBreakpoint(layout *Layout) string
GetResponsiveBreakpoint returns the breakpoint that matches the current layout mode
func (*LayoutCalculator) ShouldShowComponent ¶
func (lc *LayoutCalculator) ShouldShowComponent(layout *Layout, component string) bool
ShouldShowComponent determines if a component should be shown based on layout mode
type LayoutConfig ¶
type LayoutConfig struct {
// ShowSidebar indicates whether sidebar should be shown
ShowSidebar bool
// ShowHeader indicates whether header should be shown
ShowHeader bool
ShowFooter bool
// ShowStatusBar indicates whether status bar should be shown
ShowStatusBar bool
// SidebarWidth is the fixed width of the sidebar when visible
SidebarWidth int
// HeaderHeight is the fixed height of the header when visible
HeaderHeight int
FooterHeight int
// SearchHeight is the height of the search bar when active
SearchHeight int
// StatusBarHeight is the height of the status bar
StatusBarHeight int
// Breakpoints for responsive design
Breakpoints Breakpoints
}
LayoutConfig contains configuration for layout calculations
func DefaultLayoutConfig ¶
func DefaultLayoutConfig() *LayoutConfig
DefaultLayoutConfig returns the default layout configuration
type LayoutMode ¶
type LayoutMode uint8
LayoutMode represents the current layout mode
const ( // LayoutNormal is the standard layout with all components visible LayoutNormal LayoutMode = iota // LayoutCompact is a space-optimized layout for small terminals LayoutCompact // LayoutMinimal is an ultra-minimal layout for very small terminals LayoutMinimal )