theme

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func CountSelectable(entries []Entry) int

CountSelectable counts the entries a cursor can land on.

func IndexOf added in v1.0.0

func IndexOf(entries []Entry, target Entry) int

IndexOf finds an entry in a list, or -1.

func Label added in v1.0.0

func Label(entry Entry) string

Label returns empty string since all themes are unified.

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

func Swatch(entry Entry) []string

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

type Counts struct {
	BuiltIn   int
	Community int
}

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.

func (Counts) Summary added in v1.0.0

func (c Counts) Summary() string

Summary is the "21 themes" line.

func (Counts) Total added in v1.0.0

func (c Counts) Total() int

Total is every selectable theme.

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

func Filter(entries []Entry, query string) []Entry

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.

func List added in v1.0.0

func List() []Entry

List returns all themes in canonical order.

func (Entry) IsZero added in v1.0.0

func (e Entry) IsZero() bool

IsZero reports the empty entry, which is what "no theme chosen" looks like.

func (Entry) Same added in v1.0.0

func (e Entry) Same(other Entry) bool

Same reports whether two entries name the same theme.

type ResolvedTheme

type ResolvedTheme struct {
	BaseName      string
	CommunityName string
	Overrides     map[string]interface{}
}

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.

Jump to

Keyboard shortcuts

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