Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The rail's **Settings** (or the command palette) has these sections, for the con

**Appearance** is a page of its own, not one of these sections, reached from the sidebar's menu or the palette. It keeps the app in Dark mode, Light mode, or System mode, which follows the device as its appearance changes. Existing preferences stay dark until another mode is chosen. Every palette has a light variant; the chosen palette and custom accent survive mode changes. Light accents use a contrast-safe shade of the same color. The app and its floating control update together; terminals keep the palette's dark variant so CLI programs with their own pale input text remain readable. These preferences are local to the device.

On the same page, **Style** builds the whole app another way, on this device: Liquid Glass (the default), Ledger (real black, flat panes on one-pixel lines, denser controls), Tonal (flat tones of one hue, no lines or shadows) or Bento (Ledger's look with regions and page sections in fixed tiles). Regions, navigation, labels and shortcuts are the same in each. A palette tints any style: Ledger and Bento keep their black ground, taking the palette's accent and a tint in their surfaces; Tonal takes the palette's ground and accent for its whole field. A background image, its opacity and blur, and Follow background apply to Liquid Glass only: in the others those controls are disabled and say so, and the image is kept for going back. Ledger, Tonal and Bento ask for IBM Plex Sans or Rubik and use the system's font on a device that lacks it.
On the same page, **Style** builds the whole app another way, on this device: Liquid Glass (the default), Windows 11 (Fluent Design System with Mica layering and rounded geometry), Ledger (real black, flat panes on one-pixel lines, denser controls), Tonal (flat tones of one hue, no lines or shadows) or Bento (Ledger's look with regions and page sections in fixed tiles). Regions, navigation, labels and shortcuts are the same in each. A palette tints any style: Ledger and Bento keep their black ground, taking the palette's accent and a tint in their surfaces; Tonal takes the palette's ground and accent for its whole field. A background image, its opacity and blur, and Follow background apply to Liquid Glass only: in the others those controls are disabled and say so, and the image is kept for going back. Ledger, Tonal and Bento ask for IBM Plex Sans or Rubik and use the system's font on a device that lacks it.

**Background**, on that page: an image of the user's own behind the panels (PNG, JPEG, GIF's first frame, WebP; up to 64 MB and about 120 megapixels, kept in memory at no more than 2560 pixels on its longest side), how opaque the panels over it are, and the strength of its blur, with the window itself as the preview; **Use the default** goes back to the theme's own. **Follow background**, beside the palettes, derives the palette from the image, once per image and off the drawing path: its most common color, darkened, for the ground, its main colors for the wallpaper, its most colorful for the accent, lifted or deepened to read as words, in dark and light; a custom accent still replaces that one. It is kept per device, and with no image, or one gone, the palette last saved applies. The image stays a path on that device and isn't synced: another device has its own files and picks its own. A file gone or unreadable shows the theme's background and says so. The slider reaches every main surface, from fully opaque down to the image alone with a faint edge: the session list, the frame, the side panel, the bars' pieces, the tools dock, cards, terminals, chat, code and diffs. A scrim of the theme's ground fades with it, and glass stops frosting near its lowest. The default stays readable over any image; how readable the low end is, is the user's choice. Menus, dialogs and pop-overs stay as they are, as they float over content. Blur is drawn on the GPU where the window draws, on every platform; a page in a web view is a native surface above the window, so nothing of the background shows behind it.

Expand Down
102 changes: 102 additions & 0 deletions ui/appearance_fluent_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package ui

import (
"encoding/json"
"os"
"path/filepath"
"testing"

"github.com/egoist/mygo/ui"

"github.com/enowx/enowx/ui/theme"
)

func TestWindows11FluentStyleIntegration(t *testing.T) {
app := &App{}
app.state = appState{
UIStyle: "windows-11",
Theme: "windows-11",
ThemeMode: "dark",
}

app.applyTheme()

if style := theme.CurrentStyle(); style.ID != "windows-11" {
t.Fatalf("expected active style 'windows-11', got %q", style.ID)
} else {
if style.RadiusControl != 8 {
t.Errorf("expected RadiusControl=8, got %.0f", style.RadiusControl)
}
if style.RadiusCard != 12 {
t.Errorf("expected RadiusCard=12, got %.0f", style.RadiusCard)
}
if style.RadiusPanel != 12 {
t.Errorf("expected RadiusPanel=12, got %.0f", style.RadiusPanel)
}
if style.Family != theme.FluentFontFamily {
t.Errorf("expected Family=%q, got %q", theme.FluentFontFamily, style.Family)
}
}

curPal := theme.Current()
if curPal.ID != "windows-11" {
t.Fatalf("expected active palette 'windows-11', got %q", curPal.ID)
}
if theme.Hex(curPal.Background) != "#202020" {
t.Errorf("expected dark background #202020, got %s", theme.Hex(curPal.Background))
}
if theme.Hex(curPal.Accent) != "#60CDFF" {
t.Errorf("expected dark accent #60CDFF, got %s", theme.Hex(curPal.Accent))
}

// Switch to light mode
app.setAppearanceMode("light")
lightPal := theme.Current()
if !lightPal.Light {
t.Fatalf("expected light palette, got Light=false")
}
if theme.Hex(lightPal.Background) != "#F3F3F3" {
t.Errorf("expected light background #F3F3F3, got %s", theme.Hex(lightPal.Background))
}
if theme.Hex(lightPal.Accent) != "#0067C0" {
t.Errorf("expected light accent #0067C0, got %s", theme.Hex(lightPal.Accent))
}
}

func TestWindows11StatePersistenceAndFallback(t *testing.T) {
dir := t.TempDir()
stateFile := filepath.Join(dir, "state.json")

// 1. Save valid Windows 11 state
st := appState{
UIStyle: "windows-11",
Theme: "windows-11",
ThemeMode: "light",
}
data, err := json.MarshalIndent(st, "", " ")
if err != nil {
t.Fatal(err)
}
if err := os.WriteFile(stateFile, data, 0o600); err != nil {
t.Fatal(err)
}

loaded := loadState(stateFile)
if loaded.UIStyle != "windows-11" || loaded.Theme != "windows-11" || loaded.ThemeMode != "light" {
t.Fatalf("failed to restore Windows 11 state: %+v", loaded)
}

// 2. Fallback on corrupt or invalid theme / style IDs
corruptSt := appState{
UIStyle: "unknown-corrupt-style",
Theme: "unknown-corrupt-theme",
}
s := theme.StyleByID(corruptSt.UIStyle)
if s.ID != theme.LiquidGlass.ID {
t.Errorf("expected fallback to LiquidGlass on unknown style, got %q", s.ID)
}
p := theme.Lookup(corruptSt.Theme, ui.Color{})
if p.ID != theme.Default.ID {
t.Errorf("expected fallback to Default on unknown palette, got %q", p.ID)
}
}
2 changes: 1 addition & 1 deletion ui/appearance_style.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
func (a *App) stylePicker(c *ui.Context) {
ui.Column(c.Key("style-picker")).FillWidth().Gap(theme.S2).Children(func() {
ui.Text(c, "Style").FontSize(theme.TextUI).FontWeight(500)
ui.Grid(c).FillWidth().Columns(4).Gap(theme.S3).Children(func() {
ui.Grid(c).FillWidth().Columns(len(theme.Styles)).Gap(theme.S3).Children(func() {
current := theme.StyleByID(a.state.UIStyle).ID
for _, s := range theme.Styles {
if a.styleCard(c.Key(s.ID), s, s.ID == current) && s.ID != current {
Expand Down
40 changes: 40 additions & 0 deletions ui/theme/fluent_palette.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package theme

import "github.com/egoist/mygo/ui"

// Windows11Palette is the Windows 11 Fluent Design System palette: Mica dark #202020 base,
// subtle acrylic layering, and official Windows 11 royal blue / cyan accents.
var Windows11Palette = Palette{
ID: "windows-11",
Name: "Windows 11",

Ground: ui.Hex("#202020"),
Wall: [3]ui.Color{light("#0078D4", 0.35), light("#60CDFF", 0.25), light("#1F1F1F", 0.35)},
Background: ui.Hex("#202020"),
Panel: ui.RGBA(39, 39, 39, 0.85),
Raised: ui.RGBA(255, 255, 255, 0.05),
Sunken: ui.RGBA(0, 0, 0, 0.25),
Frame: ui.RGBA(42, 42, 42, 0.92),
Popover: ui.RGBA(44, 44, 44, 0.98),
composer: ui.RGBA(30, 30, 30, 0.92),
Hover: ui.RGBA(255, 255, 255, 0.08),
Selected: ui.RGBA(255, 255, 255, 0.15),
Dialog: ui.RGBA(44, 44, 44, 0.98),
Border: ui.RGBA(255, 255, 255, 0.08),
BorderStrong: ui.Hex("#8A8A8A"),
Text: ui.Hex("#F5F6FA"),
TextStrong: ui.Hex("#FFFFFF"),
TextSoft: ui.Hex("#D0D2DE"),
Muted: ui.Hex("#B4B6C4"),
Accent: ui.Hex("#60CDFF"),
OnAccent: ui.Hex("#000000"),
Working: ui.Hex("#60CDFF"),
Done: ui.Hex("#6CCB5F"),
Warning: ui.Hex("#FFD60A"),
Error: ui.Hex("#FF6961"),
Idle: ui.Hex("#AEAEB2"),
Add: ui.Hex("#6CCB5F"),
Del: ui.Hex("#FF6961"),
Now: ui.Hex("#60CDFF"),
own: true,
}
66 changes: 66 additions & 0 deletions ui/theme/fluent_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package theme

import (
"testing"

"github.com/egoist/mygo/ui"
)

func TestFluentTokensStructureAndValues(t *testing.T) {
for _, dark := range []bool{true, false} {
tokens := GetFluentTokens(dark)

if tokens.FontFamily == "" {
t.Errorf("dark=%v: FontFamily is empty", dark)
}
if tokens.RadiusSmall != 4 || tokens.RadiusControl != 8 || tokens.RadiusCard != 12 || tokens.RadiusPanel != 12 {
t.Errorf("dark=%v: unexpected corner radii: small=%.0f, control=%.0f, card=%.0f, panel=%.0f",
dark, tokens.RadiusSmall, tokens.RadiusControl, tokens.RadiusCard, tokens.RadiusPanel)
}
if tokens.AccentPrimary.A == 0 {
t.Errorf("dark=%v: AccentPrimary is zero", dark)
}
if tokens.SurfaceBackground.A == 0 || tokens.SurfaceCard.A == 0 || tokens.SurfaceFlyout.A == 0 {
t.Errorf("dark=%v: Surface colors have zero alpha", dark)
}
if tokens.StrokeSubtle.A == 0 || tokens.StrokeDefault.A == 0 {
t.Errorf("dark=%v: Stroke colors have zero alpha", dark)
}
if tokens.ElevationRest == "" || tokens.ElevationFlyout == "" || tokens.ElevationDialog == "" {
t.Errorf("dark=%v: Elevation shadows are empty", dark)
}
if tokens.EasingStandard == "" || tokens.DurationFast == "" {
t.Errorf("dark=%v: Motion tokens are empty", dark)
}
}
}

func TestWindows11StyleLookupAndSurfaces(t *testing.T) {
s := StyleByID("windows-11")
if s.ID != Windows11.ID {
t.Fatalf("expected style ID %q, got %q", Windows11.ID, s.ID)
}
if s.RadiusControl != 8 || s.RadiusCard != 12 || s.RadiusPanel != 12 {
t.Fatalf("unexpected Windows11 style metrics: %+v", s)
}

pDark := fluentSurfaces(Windows11Palette)
if pDark.Background.A == 0 || pDark.Text.A == 0 || pDark.Accent.A == 0 {
t.Fatalf("dark fluent surfaces returned invalid palette: %+v", pDark)
}

pLight := fluentSurfaces(lightOf(Windows11Palette, ui.Color{}))
if pLight.Background.A == 0 || pLight.Text.A == 0 || pLight.Accent.A == 0 {
t.Fatalf("light fluent surfaces returned invalid palette: %+v", pLight)
}
}

func TestWindows11PaletteLookup(t *testing.T) {
p := Lookup("windows-11", ui.Color{})
if p.ID != "windows-11" {
t.Fatalf("expected 'windows-11', got %q", p.ID)
}
if p.Name != "Windows 11" {
t.Fatalf("expected 'Windows 11', got %q", p.Name)
}
}
170 changes: 170 additions & 0 deletions ui/theme/fluent_tokens.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
package theme

import (
"fmt"

"github.com/egoist/mygo/ui"
)

// FluentTokens defines the Microsoft Fluent Design System token hierarchy
// for Windows 11 styling across surfaces, strokes, effects, accents, and motion.
type FluentTokens struct {
IsDark bool

// Surfaces
SurfaceBackground ui.Color
SurfaceCard ui.Color
SurfaceCardHover ui.Color
SurfaceFlyout ui.Color
SurfaceDialog ui.Color
SurfaceMica ui.Color

// Borders / Strokes
StrokeSubtle ui.Color
StrokeDefault ui.Color
StrokeCard ui.Color
StrokeFocus ui.Color

// Effects & Elevation
ElevationRest string
ElevationHover string
ElevationFlyout string
ElevationDialog string
MaterialMicaFilter string

// Accents
AccentPrimary ui.Color
AccentSecondary ui.Color
AccentPressed ui.Color
AccentFocusOutline ui.Color
OnAccent ui.Color

// Typography
FontFamily string
TextCaption float32
TextBody float32
TextSubtitle float32
TextTitle float32

// Corner Radii
RadiusSmall float32 // 4px (badge, checkbox, micro)
RadiusControl float32 // 8px (buttons, inputs)
RadiusCard float32 // 12px (cards, containers, flyouts)
RadiusPanel float32 // 12px (dialogs, main panels)

// Motion
EasingStandard string
EasingEnterExit string
DurationFast string
DurationNormal string
}

// FluentFontFamily is the standard Windows 11 font stack with Segoe UI Variable first.
const FluentFontFamily = "Segoe UI Variable, Segoe UI, system-ui, -apple-system, Roboto, sans-serif"

// FluentDarkTokens holds the Windows 11 Fluent tokens for Dark mode.
var FluentDarkTokens = FluentTokens{
IsDark: true,

SurfaceBackground: ui.Hex("#202020"),
SurfaceCard: ui.RGBA(255, 255, 255, 0.05),
SurfaceCardHover: ui.RGBA(255, 255, 255, 0.08),
SurfaceFlyout: ui.RGBA(44, 44, 44, 0.96),
SurfaceDialog: ui.RGBA(44, 44, 44, 0.98),
SurfaceMica: ui.RGBA(32, 32, 32, 0.88),

StrokeSubtle: ui.RGBA(255, 255, 255, 0.08),
StrokeDefault: ui.RGBA(255, 255, 255, 0.15),
StrokeCard: ui.RGBA(255, 255, 255, 0.08),
StrokeFocus: ui.Hex("#60CDFF"),

ElevationRest: "0 0 0 1px rgba(255, 255, 255, 0.08)",
ElevationHover: "0 2px 4px rgba(0, 0, 0, 0.20), 0 0 0 1px rgba(255, 255, 255, 0.12)",
ElevationFlyout: "0 8px 16px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(255, 255, 255, 0.10)",
ElevationDialog: "0 32px 64px rgba(0, 0, 0, 0.40), 0 0 0 1px rgba(255, 255, 255, 0.12)",
MaterialMicaFilter: "blur(30px) saturate(125%)",

AccentPrimary: ui.Hex("#60CDFF"),
AccentSecondary: ui.Hex("#4CC2FF"),
AccentPressed: ui.Hex("#1CA8F8"),
AccentFocusOutline: ui.Hex("#60CDFF"),
OnAccent: ui.Hex("#000000"),

FontFamily: FluentFontFamily,
TextCaption: 12,
TextBody: 13,
TextSubtitle: 15,
TextTitle: 18,

RadiusSmall: 4,
RadiusControl: 8,
RadiusCard: 12,
RadiusPanel: 12,

EasingStandard: "cubic-bezier(0, 0, 0, 1)",
EasingEnterExit: "cubic-bezier(0.1, 0.9, 0.2, 1)",
DurationFast: "150ms",
DurationNormal: "250ms",
}

// FluentLightTokens holds the Windows 11 Fluent tokens for Light mode.
var FluentLightTokens = FluentTokens{
IsDark: false,

SurfaceBackground: ui.Hex("#F3F3F3"),
SurfaceCard: ui.RGBA(255, 255, 255, 0.70),
SurfaceCardHover: ui.RGBA(255, 255, 255, 0.90),
SurfaceFlyout: ui.RGBA(252, 252, 252, 0.96),
SurfaceDialog: ui.Hex("#FFFFFF"),
SurfaceMica: ui.RGBA(243, 243, 243, 0.88),

StrokeSubtle: ui.RGBA(0, 0, 0, 0.06),
StrokeDefault: ui.RGBA(0, 0, 0, 0.14),
StrokeCard: ui.RGBA(0, 0, 0, 0.06),
StrokeFocus: ui.Hex("#0067C0"),

ElevationRest: "0 0 0 1px rgba(0, 0, 0, 0.06)",
ElevationHover: "0 2px 4px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(0, 0, 0, 0.08)",
ElevationFlyout: "0 8px 16px rgba(0, 0, 0, 0.14), 0 0 0 1px rgba(0, 0, 0, 0.06)",
ElevationDialog: "0 32px 64px rgba(0, 0, 0, 0.24), 0 0 0 1px rgba(0, 0, 0, 0.08)",
MaterialMicaFilter: "blur(30px) saturate(125%)",

AccentPrimary: ui.Hex("#0067C0"),
AccentSecondary: ui.Hex("#0078D4"),
AccentPressed: ui.Hex("#005A9E"),
AccentFocusOutline: ui.Hex("#0067C0"),
OnAccent: ui.Hex("#FFFFFF"),

FontFamily: FluentFontFamily,
TextCaption: 12,
TextBody: 13,
TextSubtitle: 15,
TextTitle: 18,

RadiusSmall: 4,
RadiusControl: 8,
RadiusCard: 12,
RadiusPanel: 12,

EasingStandard: "cubic-bezier(0, 0, 0, 1)",
EasingEnterExit: "cubic-bezier(0.1, 0.9, 0.2, 1)",
DurationFast: "150ms",
DurationNormal: "250ms",
}

// GetFluentTokens returns the active token set based on light/dark mode.
func GetFluentTokens(isDark bool) FluentTokens {
if isDark {
return FluentDarkTokens
}
return FluentLightTokens
}

// ColorRGBAString formats a ui.Color into a standard CSS rgba(r, g, b, a) string.
func ColorRGBAString(c ui.Color) string {
a := float32(c.A) / 255.0
if a >= 0.999 {
return fmt.Sprintf("#%02X%02X%02X", c.R, c.G, c.B)
}
return fmt.Sprintf("rgba(%d, %d, %d, %.2f)", c.R, c.G, c.B, a)
}
Loading
Loading