theme

package
v0.0.0-...-23f44f6 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2022 License: BSD-3-Clause Imports: 3 Imported by: 0

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

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

func (b *Button) OnNav(ctx app.Context)

OnNav is called when a page with the theme button is navigated to

func (*Button) Render

func (b *Button) Render() app.UI

Render returns the UI of the theme button

func (*Button) Save

func (b *Button) Save()

Save saves the theme button's state to local storage

func (*Button) SetState

func (b *Button) SetState(darkMode bool)

SetState sets the current state of the button to the given value (of whether it is in dark mode)

func (*Button) State

func (b *Button) State() bool

State returns the current state of the button (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

Jump to

Keyboard shortcuts

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