Add datetime components 196-215; Kit.At; inert stepper arrows
Calendars, date and time inputs, pickers, clocks, timers, a sun dial, a season wheel, an agenda and a day schedule. Kit.At rebuilds at a moment (relative times, midnight). Stepper and NumberInput arrows stop under Inert. DateInput parks a popup focus as its own.
This commit is contained in:
38 files changed
+2651
-5
No files matched your search
@@ -0,0 +1,29 @@
|
||||
package datetime
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"time"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
)
|
||||
|
||||
type CalendarOptions struct {
|
||||
Disabled bool
|
||||
}
|
||||
|
||||
type CalendarResult struct {
|
||||
Element *ui.Element
|
||||
// Picked is a click, Enter or Space on a day.
|
||||
Changed, Picked bool
|
||||
}
|
||||
|
||||
// Calendar moves *date through a month grid; today is marked.
|
||||
func Calendar(c *ui.Context, text string, date *time.Time, o CalendarOptions) CalendarResult {
|
||||
old := *date
|
||||
e, _, picked := month(c, text, date, o.Disabled, false, func(d time.Time) look { return look{chosen: sameDay(d, *date)} })
|
||||
res := CalendarResult{Element: e, Changed: !date.Equal(old), Picked: picked}
|
||||
if res.Changed || res.Picked {
|
||||
slog.Debug("8bit: calendar", "label", text, "date", date.Format("2006-01-02"), "picked", picked)
|
||||
}
|
||||
return res
|
||||
}
|
||||
Reference in new issue
Block a user