timeline

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Templates

func Templates() *base.TemplateSet

Templates returns the timeline template set.

Types

type Color

type Color string

Color defines item indicator colors.

const (
	ColorGray   Color = "gray"
	ColorBlue   Color = "blue"
	ColorGreen  Color = "green"
	ColorYellow Color = "yellow"
	ColorRed    Color = "red"
	ColorPurple Color = "purple"
)

type ItemOption

type ItemOption func(*TimelineItem)

ItemOption configures a TimelineItem.

func WithItemActive

func WithItemActive(active bool) ItemOption

WithItemActive sets the item as active.

func WithItemColor

func WithItemColor(color Color) ItemOption

WithItemColor sets the item color.

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 WithItemIcon

func WithItemIcon(icon string) ItemOption

WithItemIcon sets the item icon.

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.

func WithItemTime

func WithItemTime(time string) ItemOption

WithItemTime sets the item time/date.

func WithItemTitle

func WithItemTitle(title string) ItemOption

WithItemTitle sets the item title.

type Option

type Option func(*Timeline)

Option configures a Timeline.

func WithItems

func WithItems(items ...*TimelineItem) Option

WithItems sets the timeline items.

func WithOrientation

func WithOrientation(o Orientation) Option

WithOrientation sets the timeline orientation.

func WithPosition

func WithPosition(p Position) Option

WithPosition sets the content position.

func WithReverse

func WithReverse(reverse bool) Option

WithReverse reverses the item order.

func WithShowConnectors

func WithShowConnectors(show bool) Option

WithShowConnectors enables/disables connectors.

func WithStyled

func WithStyled(styled bool) Option

WithStyled sets the styled mode.

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 Position

type Position string

Position defines item content placement.

const (
	// PositionLeft places content on the left side.
	PositionLeft Position = "left"
	// PositionRight places content on the right side.
	PositionRight Position = "right"
	// PositionAlternate alternates content between left and right.
	PositionAlternate Position = "alternate"
)

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 New

func New(id string, opts ...Option) *Timeline

New creates a new Timeline with the given ID and options.

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) HasItems

func (t *Timeline) HasItems() bool

HasItems returns true if timeline has items.

func (*Timeline) IsAlternate

func (t *Timeline) IsAlternate() bool

IsAlternate returns true if position is alternate.

func (*Timeline) IsHorizontal

func (t *Timeline) IsHorizontal() bool

IsHorizontal returns true if orientation is horizontal.

func (*Timeline) IsVertical

func (t *Timeline) IsVertical() bool

IsVertical returns true if orientation is vertical.

func (*Timeline) ItemCount

func (t *Timeline) ItemCount() int

ItemCount returns the number of items.

func (*Timeline) OrientationClass

func (t *Timeline) OrientationClass() string

OrientationClass returns CSS class for orientation.

func (*Timeline) RemoveItem

func (t *Timeline) RemoveItem(id string)

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

Styles returns the resolved TimelineItemStyles for this component. It uses lazy resolution: the result is cached after the first call.

Jump to

Keyboard shortcuts

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