Documentation
¶
Overview ¶
Package theme provides a customizable theme toggle button. The theme toggle button sets the data-color-scheme attribute of the root html element and the button.
Index ¶
- type Button
- func (b *Button) Apply()
- func (b *Button) Load()
- func (b *Button) LoadFromOperatingSystem()
- func (b *Button) OnNav(ctx app.Context)
- func (b *Button) Render() app.UI
- func (b *Button) Save()
- func (b *Button) SetState(darkMode bool)
- func (b *Button) State() bool
- func (b *Button) SwitchToDarkMode()
- func (b *Button) SwitchToLightMode()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Button ¶
type Button struct { app.Compo ID string // ID is the ID of the button Class string // Class is the string-separated list of classes to apply to the button LightModeTitle string // LightModeTitle is the title of the button when in light mode DarkModeTitle string // DarkModeTitle is the title of the button when in dark mode LightModeBody app.UI // LightModeBody is the body of the button when in light mode DarkModeBody app.UI // DarkModeBody is the body of the button when in dark mode // contains filtered or unexported fields }
Button is a button to toggle the theme
func New ¶
func New(id, class, lightModeTitle, darkModeTitle string, lightModeBody, darkModeBody app.UI) *Button
New makes a new theme button with the given id, classes, light mode title, dark mode title, light mode body, and dark mode body
func (*Button) Apply ¶
func (b *Button) Apply()
Apply applies the theme button's current state to the app
func (*Button) Load ¶
func (b *Button) Load()
Load loads the theme button's state from local storage, if it is saved there. Otherwise, it uses the operating system theme setting.
func (*Button) LoadFromOperatingSystem ¶
func (b *Button) LoadFromOperatingSystem()
LoadFromOperatingSystem loads the theme button's state from the operating system theme
func (*Button) SetState ¶
SetState sets the current state of the button to the given value (of whether it is in dark mode)
func (*Button) SwitchToDarkMode ¶
func (b *Button) SwitchToDarkMode()
SwitchToDarkMode switches the app to dark mode
func (*Button) SwitchToLightMode ¶
func (b *Button) SwitchToLightMode()
SwitchToLightMode switches the app to light mode