Documentation
¶
Overview ¶
Package timeline provides timeline components for the LiveTemplate framework.
Timelines display a list of events in chronological order with optional icons, status indicators, and content.
Available Templates ¶
- lvt:timeline:default:v1 - Standard vertical timeline
Basic Usage ¶
tl := timeline.New("history",
timeline.WithItems(
timeline.NewItem("1", timeline.WithItemTitle("Event 1")),
timeline.NewItem("2", timeline.WithItemTitle("Event 2")),
),
)
{{template "lvt:timeline:default:v1" .Timeline}}
Index ¶
- func Templates() *base.TemplateSet
- type Color
- type ItemOption
- func WithItemActive(active bool) ItemOption
- func WithItemColor(color Color) ItemOption
- func WithItemCompleted(completed bool) ItemOption
- func WithItemDescription(desc string) ItemOption
- func WithItemIcon(icon string) ItemOption
- func WithItemStatus(status Status) ItemOption
- func WithItemStyled(styled bool) ItemOption
- func WithItemTime(time string) ItemOption
- func WithItemTitle(title string) ItemOption
- type Option
- type Orientation
- type Position
- type Status
- type Timeline
- func (t *Timeline) AddItem(item *TimelineItem)
- func (t *Timeline) GetItem(id string) *TimelineItem
- func (t *Timeline) HasItems() bool
- func (t *Timeline) IsAlternate() bool
- func (t *Timeline) IsHorizontal() bool
- func (t *Timeline) IsVertical() bool
- func (t *Timeline) ItemCount() int
- func (t *Timeline) OrientationClass() string
- func (t *Timeline) RemoveItem(id string)
- func (t *Timeline) Styles() styles.TimelineStyles
- type TimelineItem
- func (i *TimelineItem) HasDescription() bool
- func (i *TimelineItem) HasIcon() bool
- func (i *TimelineItem) HasTime() bool
- func (i *TimelineItem) HasTitle() bool
- func (i *TimelineItem) IndicatorClass() string
- func (i *TimelineItem) IsActive() bool
- func (i *TimelineItem) IsComplete() bool
- func (i *TimelineItem) IsError() bool
- func (i *TimelineItem) IsPending() bool
- func (i *TimelineItem) RingClass() string
- func (i *TimelineItem) StatusClass() string
- func (i *TimelineItem) Styles() styles.TimelineItemStyles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ItemOption ¶
type ItemOption func(*TimelineItem)
ItemOption configures a TimelineItem.
func WithItemActive ¶
func WithItemActive(active bool) ItemOption
WithItemActive sets the item as active.
func WithItemCompleted ¶
func WithItemCompleted(completed bool) ItemOption
WithItemCompleted sets the item as completed.
func WithItemDescription ¶
func WithItemDescription(desc string) ItemOption
WithItemDescription sets the item description.
func WithItemStatus ¶
func WithItemStatus(status Status) ItemOption
WithItemStatus sets the item status.
func WithItemStyled ¶
func WithItemStyled(styled bool) ItemOption
WithItemStyled sets the item styled mode.
type Option ¶
type Option func(*Timeline)
Option configures a Timeline.
func WithOrientation ¶
func WithOrientation(o Orientation) Option
WithOrientation sets the timeline orientation.
func WithShowConnectors ¶
WithShowConnectors enables/disables connectors.
type Orientation ¶
type Orientation string
Orientation defines timeline layout direction.
const ( // OrientationVertical displays items top to bottom. OrientationVertical Orientation = "vertical" // OrientationHorizontal displays items left to right. OrientationHorizontal Orientation = "horizontal" )
type Status ¶
type Status string
Status defines item status indicators.
const ( // StatusDefault is the default/neutral status. StatusDefault Status = "default" // StatusPending indicates a pending/waiting state. StatusPending Status = "pending" // StatusActive indicates the current/active state. StatusActive Status = "active" // StatusComplete indicates completion. StatusComplete Status = "complete" // StatusError indicates an error state. StatusError Status = "error" )
type Timeline ¶
type Timeline struct {
base.Base
// Items in the timeline.
Items []*TimelineItem
// Orientation controls layout direction.
Orientation Orientation
// Position controls content placement (for vertical orientation).
Position Position
// ShowConnectors displays lines between items.
ShowConnectors bool
// Reverse displays items in reverse order.
Reverse bool
}
Timeline represents a timeline container.
func (*Timeline) AddItem ¶
func (t *Timeline) AddItem(item *TimelineItem)
AddItem adds an item to the timeline.
func (*Timeline) GetItem ¶
func (t *Timeline) GetItem(id string) *TimelineItem
GetItem returns an item by ID or nil if not found.
func (*Timeline) IsAlternate ¶
IsAlternate returns true if position is alternate.
func (*Timeline) IsHorizontal ¶
IsHorizontal returns true if orientation is horizontal.
func (*Timeline) IsVertical ¶
IsVertical returns true if orientation is vertical.
func (*Timeline) OrientationClass ¶
OrientationClass returns CSS class for orientation.
func (*Timeline) RemoveItem ¶
RemoveItem removes an item by ID.
func (*Timeline) Styles ¶
func (t *Timeline) Styles() styles.TimelineStyles
Styles returns the resolved TimelineStyles for this component. It uses lazy resolution: the result is cached after the first call.
type TimelineItem ¶
type TimelineItem struct {
base.Base
// Title is the item heading.
Title string
// Description is additional content.
Description string
// Time displays a timestamp or date.
Time string
// Icon is the icon name or SVG.
Icon string
// Status indicates the item state.
Status Status
// Color is the indicator color.
Color Color
// Active highlights this item.
Active bool
// Completed marks item as done.
Completed bool
}
TimelineItem represents a single timeline entry.
func NewItem ¶
func NewItem(id string, opts ...ItemOption) *TimelineItem
NewItem creates a new TimelineItem with the given ID and options.
func (*TimelineItem) HasDescription ¶
func (i *TimelineItem) HasDescription() bool
HasDescription returns true if description is set.
func (*TimelineItem) HasIcon ¶
func (i *TimelineItem) HasIcon() bool
HasIcon returns true if icon is set.
func (*TimelineItem) HasTime ¶
func (i *TimelineItem) HasTime() bool
HasTime returns true if time is set.
func (*TimelineItem) HasTitle ¶
func (i *TimelineItem) HasTitle() bool
HasTitle returns true if title is set.
func (*TimelineItem) IndicatorClass ¶
func (i *TimelineItem) IndicatorClass() string
IndicatorClass returns CSS class for the indicator dot.
func (*TimelineItem) IsActive ¶
func (i *TimelineItem) IsActive() bool
IsActive returns true if status is active or Active is true.
func (*TimelineItem) IsComplete ¶
func (i *TimelineItem) IsComplete() bool
IsComplete returns true if status is complete or Completed is true.
func (*TimelineItem) IsError ¶
func (i *TimelineItem) IsError() bool
IsError returns true if status is error.
func (*TimelineItem) IsPending ¶
func (i *TimelineItem) IsPending() bool
IsPending returns true if status is pending.
func (*TimelineItem) RingClass ¶
func (i *TimelineItem) RingClass() string
RingClass returns ring CSS class for active items.
func (*TimelineItem) StatusClass ¶
func (i *TimelineItem) StatusClass() string
StatusClass returns CSS class based on status.
func (*TimelineItem) Styles ¶
func (i *TimelineItem) Styles() styles.TimelineItemStyles
Styles returns the resolved TimelineItemStyles for this component. It uses lazy resolution: the result is cached after the first call.