Help us shape the future of Go! Take the 2026 Go Developer Survey

calendar

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: MIT Imports: 10 Imported by: 0

README

Bubble Calendar

simple demo Bubble Calendar is a calendar component for the Bubble Tea framework. It provides a visual representation of events throughout the day, with each event color-coded for easy identification.

Features

  • Visual representation of a day's events.
  • Week view feature to see events for the entire week.
  • Events are color-coded for easy identification.
  • The calendar adjusts to fit the width of your terminal.
  • Compatible with the Bubble Tea framework.
  • Week start on Monday or Sunday.
  • Customizable event colors.

Installation

You can use the go get command:

go get github.com/Fabianexe/bubble-calendar

Usage

Import the package in your Go file:

import calendar "github.com/Fabianexe/bubble-calendar"

Create a new calendar and add events to it:

c := calendar.New("Calendar Title", 25, 10, events...),

The events are represented by the calendar.Event interface:

type Event interface {
	Start() time.Time
	End() time.Time
	Title() string
}

See the Example code.

Configuration

The Calendar struct has several public fields and methods that you can use to configure your calendar:

Fields
  • CurrentMode: The current view mode of the calendar. It can be calendar.DayMode or calendar.WeekMode.
  • Events: An array of events to be displayed on the calendar.
  • Title: The title of the calendar.
  • ViewedDay: The day currently being viewed in the calendar.
  • Colors: An array of lipgloss.Style that define the colors used for the events in the calendar.
  • ExternalKeybinds: An array of key.Binding that define the external key bindings for the calendar.
  • WeekStartMonday: A boolean that determines whether the week starts on Monday. If set to false, the week starts on Sunday.
  • ShowDuration: A boolean that determines whether to show the duration of events.
Methods
  • SetAllowedModes(m ...mode) error: Sets the allowed modes for the calendar.

Please refer to the source code for more detailed information about these fields and methods.

Limitations

While Bubble Calendar provides a robust and flexible way to visualize your events, there are a few limitations to be aware of:

  • Space Constraints: Especially in the week view, the space available for each day might be limited depending on the size of your terminal. This could potentially lead to inaccurate event start times being displayed and in the worst case, no calendar is displayed at all.

  • No Parallel Events: Currently, Bubble Calendar does not support the display of parallel events If two events occur at the same time, they will be displayed sequentially. This means that the start time of the second event might not accurately reflect its actual start time.

These limitations may be subject to change in future versions as we continue to improve and expand the capabilities of Bubble Calendar.

Contributing

Contributions to Bubble Calendar are welcome. Please open an issue or submit a pull request on GitHub.

License

Bubble Calendar is licensed under the MIT License. See the LICENSE file for more details.

Documentation

Index

Constants

View Source
const (
	DayMode mode = iota
	WeekMode
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Calendar

type Calendar struct {
	CurrentMode      mode
	Events           []Event
	Title            string
	ViewedDay        time.Time
	Colors           []lipgloss.Style
	ExternalKeybinds []key.Binding
	WeekStartMonday  bool
	ShowDuration     bool
	// contains filtered or unexported fields
}

func New

func New(title string, width, height int, events ...Event) *Calendar

func (*Calendar) Init

func (c *Calendar) Init() tea.Cmd

func (*Calendar) SetAllowedModes

func (c *Calendar) SetAllowedModes(m ...mode) error

func (*Calendar) Update

func (c *Calendar) Update(msg tea.Msg) (*Calendar, tea.Cmd)

func (*Calendar) View

func (c *Calendar) View() string

type Event

type Event interface {
	Start() time.Time
	End() time.Time
	Title() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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