
A custom interactive component for Bubbletea applications. This bubble is designed to offer datepicker functionality similar to the jQuery Datepicker widget from the web world. Easily select dates within your Bubbletea application!
To use this library in your Bubbletea project, you can add it as a dependency using go get:
go get github.com/ethanefung/bubble-datepicker
go
import (
tea "github.com/charmbracelet/bubbletea"
"github.com/ethanefung/bubble-datepicker"
)
go
dp := datepicker.New(time.Now())
dp.SelectDate() // datepicker date is not selected by default
Model struct, include the datepicker as one of the fields:go
type Model struct {
// Other fields in your model...
DatePicker datepicker.Model
}
bubbletea.Model to satisfy the interface:```go func (m Model) Init() tea.Model { // Initialization logic here... return m }
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // Update logic here... return m, nil }
func (m Model) View() string { // View logic here... return "" } ```
View method, include the datepicker view:```go func (m Model) View() string { // Other view elements...
// Include the datepicker component
dpView := m.DatePicker.View()
return fmt.Sprintf("%s\n%s", otherViews, dpView)
} ```
Update method. Utilize the datepicker's .Update function for sane defaults and/or interact directly with the bubble using a plethora of the datepicker's Methods:```go func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) { // Handle datepicker events and updates dp, cmd := m.DatePicker.Update(msg) m.DatePicker = dp
// or just modify the datepicker directly
xmas := time.Date(2023, time.December, 25, 0, 0, 0, 0, time.UTC)
m.DatePicker.SetTime(xmas)
// Your other update logic here...
return m, cmd
} ```
You can customize the appearance and behavior of the datepicker component by modifying its settings and styles. For more detailed usage and customization options, refer to the library's documentation.
To see examples of how to use this datepicker component in a Bubbletea application, check the examples directory in the library's repository.
This library is licensed under the MIT License. See the LICENSE file for details.
We welcome contributions! If you find a bug or have an enhancement in mind, please open an issue or create a pull request on the GitHub repository.
If you have any questions or need assistance, please feel free to reach out to me.
This library was inspired by the jQuery Datepicker widget and is made possible thanks to the Bubbletea framework and the open-source community.
Happy coding with your new bubble datepicker! 📅🎉
$ claude mcp add bubble-datepicker \
-- python -m otcore.mcp_server <graph>