Documentation
¶
Overview ¶
Package theme resolves and applies themes with precedence (project-specific > global > default), supporting both built-in and community color schemes with user overrides.
Index ¶
- Constants
- func ApplyResolved(r ResolvedTheme)
- func CountSelectable(entries []Entry) int
- func IndexOf(entries []Entry, target Entry) int
- func Label(entry Entry) string
- func Preview(entry Entry)
- func ShouldAnnounceDefaultChange(global config.ThemeConfig, hasPriorState, seen bool) bool
- func Swatch(entry Entry) []string
- func ThemeConfig(entry Entry) config.ThemeConfig
- type Counts
- type Entry
- type ResolvedTheme
Constants ¶
const DefaultThemeNotice = "New default theme: Sidecar Modern — press # to switch back"
DefaultThemeNotice is the one-time message shown to a user whose look changed underneath them when Sidecar's fresh-install default became Sidecar Modern.
`#` is the theme switcher, so the message names the way back rather than a path through Configuration.
Variables ¶
This section is empty.
Functions ¶
func ApplyResolved ¶
func ApplyResolved(r ResolvedTheme)
ApplyResolved applies a resolved theme to the styles system.
func CountSelectable ¶ added in v1.0.0
CountSelectable counts the entries a cursor can land on.
func Preview ¶ added in v1.0.0
func Preview(entry Entry)
Preview applies an entry live. It is the same call every surface makes, so a preview looks identical wherever it is started from.
func ShouldAnnounceDefaultChange ¶ added in v1.0.0
func ShouldAnnounceDefaultChange(global config.ThemeConfig, hasPriorState, seen bool) bool
ShouldAnnounceDefaultChange reports whether the notice is owed.
It is deliberately a pure function of three facts the caller gathers, so the policy can be read, tested, and reused without a running app:
- global: the recorded global theme configuration. Sidecar only writes config.json when a setting changes, so an empty one means the user never chose a theme and ResolveTheme is about to restyle them. A user with any recorded choice — including the original "default" — is not being restyled and must see nothing.
- hasPriorState: whether this installation has run before. A genuinely fresh install has nothing to announce: there is no previous look to contrast against, and "the default changed" is meaningless to someone who has never seen the old one.
- seen: whether the notice has already been shown. It fires once, ever.
func Swatch ¶ added in v1.0.0
Swatch is the four colors that identify a theme at a glance: primary, success, secondary, and error. It returns nil for a separator or an unknown theme.
func ThemeConfig ¶ added in v1.0.0
func ThemeConfig(entry Entry) config.ThemeConfig
ThemeConfig is what saving an entry writes.
Types ¶
type Counts ¶ added in v1.0.0
Counts is how many themes each library contributes, for the result count the design brief asks every theme list to show.
func LibraryCounts ¶ added in v1.0.0
func LibraryCounts() Counts
LibraryCounts reports the total theme count.
type Entry ¶ added in v1.0.0
type Entry struct {
Name string // display name
IsBuiltIn bool
ThemeKey string // built-in: theme registry key; community: scheme name
IsSeparator bool // non-selectable divider between the two libraries
SeparatorText string // e.g. "Community Themes (453)"
}
Entry is one theme in the unified built-in + community list.
func EntryForConfig ¶ added in v1.0.0
func EntryForConfig(tc config.ThemeConfig) Entry
EntryForConfig is the reverse: the entry a saved ThemeConfig selects.
func Filter ¶ added in v1.0.0
Filter narrows a list by case-insensitive substring on the display name.
func GlobalEntry ¶ added in v1.0.0
func GlobalEntry(tc config.ThemeConfig) Entry
GlobalEntry is the entry the global scope shows as current. Unlike EntryForConfig, an empty configuration is not "inherits from the level above" here — there is no level above the global scope — so it resolves to the same fresh-install theme ResolveTheme would apply, and the picker opens with its cursor on the theme actually on screen.
type ResolvedTheme ¶
ResolvedTheme represents a fully-determined theme configuration.
func ResolveTheme ¶
func ResolveTheme(cfg *config.Config, projectPath string) ResolvedTheme
ResolveTheme determines the effective theme for a project path. Priority: project.Theme > global UI.Theme > styles.FreshInstallTheme.
The last step is what makes the launch theme a fresh-install default rather than an upgrade: a recorded name — including "default" — is used as written, and only an empty one, which is what a config with no ui.theme block loads as, falls through.
func Resolved ¶ added in v1.0.0
func Resolved(entry Entry) ResolvedTheme
Resolved is the theme an entry previews as. A preview deliberately carries no user overrides: the point of moving through the list is to see the theme itself, not another theme's customizations.