cli + tui to publish to leaflet (wip) & manage tasks, notes & watch/read lists 馃崈
charm leaflet readability golang
at main 126 lines 7.2 kB view raw
1package ui 2 3import ( 4 "image/color" 5 6 "github.com/charmbracelet/fang" 7 "github.com/charmbracelet/lipgloss" 8 lipglossv2 "github.com/charmbracelet/lipgloss/v2" 9) 10 11var ( 12 PrimaryColors = []Key{Guac, Julep, Bok, Pickle, NeueGuac} 13 SecondaryColors = []Key{Malibu, Sardine, Lichen} 14 TertiaryColors = []Key{Violet, Mauve, Plum, Orchid, Charple, Hazy} 15 ProvisionalColors = []Key{NeueGuac, NeueZinc} 16 AdditionColors = []Key{Pickle, Gator, Spinach} 17 DeletionColors = []Key{Pom, Steak, Toast} 18) 19 20var NoteleafColorScheme fang.ColorSchemeFunc = noteleafColorScheme 21 22// noteleafColorScheme provides Iceberg-inspired colors for CLI help/documentation 23// 24// Philosophy: Cool blues as primary, warm accents for emphasis, hierarchical text colors 25// See: https://github.com/cocopon/iceberg.vim for more information 26func noteleafColorScheme(c lipglossv2.LightDarkFunc) fang.ColorScheme { 27 return fang.ColorScheme{ 28 Base: c(Salt, Pepper), // Primary text on dark background 29 Title: c(Malibu, Malibu), // Blue primary for titles (Iceberg primary) 30 Description: c(Smoke, Smoke), // Secondary text for descriptions 31 Codeblock: c(Butter, BBQ), // Light/Dark background for code blocks 32 Program: c(Malibu, Sardine), // Blue for program names (primary accent) 33 DimmedArgument: c(Oyster, Ash), // Dimmed text for optional arguments 34 Comment: c(Squid, Squid), // Muted gray for comments (Iceberg comment) 35 Flag: c(Hazy, Jelly), // Purple for flags (Iceberg special) 36 FlagDefault: c(Lichen, Turtle), // Teal for flag defaults (secondary accent) 37 Command: c(Julep, Julep), // Green for commands (success/positive) 38 QuotedString: c(Tang, Tang), // Orange for quoted strings (warning/warm) 39 Argument: c(Lichen, Lichen), // Teal for arguments (secondary accent) 40 Help: c(Squid, Squid), // Muted gray for help text 41 Dash: c(Oyster, Oyster), // Dimmed gray for dashes/separators 42 ErrorHeader: [2]color.Color{Sriracha, Sriracha}, // Red for error headers (Iceberg error) 43 ErrorDetails: c(Coral, Salmon), // Pink/coral for error details 44 } 45} 46 47// Palette provides semantic color access 48type Palette struct { 49 scheme fang.ColorScheme 50} 51 52// NewPalette creates a new palette instance 53func NewPalette(isDark bool) *Palette { 54 return &Palette{ 55 scheme: noteleafColorScheme(lipglossv2.LightDark(isDark)), 56 } 57} 58 59var ( 60 ColorBGBase = Pepper.Hex() // #201F26 - Darkest base 61 ColorBGSecondary = BBQ.Hex() // #2d2c35 - Secondary background 62 ColorBGTertiary = Charcoal.Hex() // #3A3943 - Tertiary/elevated 63 ColorBGInput = Iron.Hex() // #4D4C57 - Input fields/focus 64 65 ColorTextPrimary = Salt.Hex() // #F1EFEF - Primary text (brightest) 66 ColorTextSecondary = Smoke.Hex() // #BFBCC8 - Secondary text 67 ColorTextMuted = Squid.Hex() // #858392 - Muted/comments 68 ColorTextDimmed = Oyster.Hex() // #605F6B - Dimmed text 69 70 ColorPrimary = Malibu.Hex() // #00A4FF - Blue (primary accent) 71 ColorSuccess = Julep.Hex() // #00FFB2 - Green (success/positive) 72 ColorError = Sriracha.Hex() // #EB4268 - Red (errors) 73 ColorWarning = Tang.Hex() // #FF985A - Orange (warnings) 74 ColorInfo = Violet.Hex() // #C259FF - Purple (info) 75 ColorAccent = Lichen.Hex() // #5CDFEA - Teal (secondary accent) 76 77 PrimaryStyle = newStyle().Foreground(lipgloss.Color(ColorPrimary)) 78 SuccessStyle = newBoldStyle().Foreground(lipgloss.Color(ColorSuccess)) 79 ErrorStyle = newBoldStyle().Foreground(lipgloss.Color(ColorError)) 80 WarningStyle = newBoldStyle().Foreground(lipgloss.Color(ColorWarning)) 81 InfoStyle = newStyle().Foreground(lipgloss.Color(ColorTextSecondary)) 82 AccentStyle = newStyle().Foreground(lipgloss.Color(ColorAccent)) 83 TextStyle = newStyle().Foreground(lipgloss.Color(ColorTextPrimary)) 84 MutedStyle = newStyle().Foreground(lipgloss.Color(ColorTextMuted)) 85 TitleStyle = newPBoldStyle(0, 1).Foreground(lipgloss.Color(ColorPrimary)) 86 SubtitleStyle = newEmStyle().Foreground(lipgloss.Color(ColorAccent)) 87 88 BoxStyle = newPStyle(1, 2).Border(lipgloss.RoundedBorder()).BorderForeground(lipgloss.Color(ColorPrimary)) 89 ErrorBoxStyle = newPStyle(1, 2).Border(lipgloss.RoundedBorder()).BorderForeground(lipgloss.Color(ColorError)) 90 HeaderStyle = newPBoldStyle(0, 1).Foreground(lipgloss.Color(ColorPrimary)) 91 CellStyle = newPStyle(0, 1).Foreground(lipgloss.Color(ColorTextPrimary)) 92 93 ListItemStyle = newStyle().Foreground(lipgloss.Color(ColorTextPrimary)).PaddingLeft(2) 94 SelectedItemStyle = newBoldStyle().Foreground(lipgloss.Color(ColorPrimary)).PaddingLeft(2) 95 96 TableStyle = newStyle().BorderStyle(lipgloss.NormalBorder()).BorderForeground(lipgloss.Color(ColorTextMuted)) 97 TableHeaderStyle = newBoldStyle().Foreground(lipgloss.Color(ColorAccent)) 98 TableTitleStyle = newBoldStyle().Foreground(lipgloss.Color(ColorPrimary)) 99 TableSelectedStyle = newBoldStyle().Foreground(lipgloss.Color(ColorTextPrimary)).Background(lipgloss.Color(ColorBGInput)) 100 101 TaskTitleStyle = newBoldStyle().Foreground(lipgloss.Color(ColorTextPrimary)) 102 TaskIDStyle = newStyle().Foreground(lipgloss.Color(ColorTextMuted)).Width(8) 103 104 StatusTodo = newStyle().Foreground(lipgloss.Color(ColorTextMuted)) // Gray (muted) 105 StatusInProgress = newStyle().Foreground(lipgloss.Color(ColorPrimary)) // Blue (active) 106 StatusBlocked = newStyle().Foreground(lipgloss.Color(ColorError)) // Red (blocked) 107 StatusDone = newStyle().Foreground(lipgloss.Color(ColorSuccess)) // Green (success) 108 StatusPending = newStyle().Foreground(lipgloss.Color(ColorWarning)) // Orange (pending) 109 StatusCompleted = newStyle().Foreground(lipgloss.Color(ColorSuccess)) // Green (completed) 110 StatusAbandoned = newStyle().Foreground(lipgloss.Color(ColorTextDimmed)) // Dimmed gray (abandoned) 111 StatusDeleted = newStyle().Foreground(lipgloss.Color(Pom.Hex())) // Dark red (deleted) 112 113 PriorityHigh = newBoldStyle().Foreground(lipgloss.Color(Pom.Hex())) // #FF388B - Bright red 114 PriorityMedium = newStyle().Foreground(lipgloss.Color(Tang.Hex())) // #FF985A - Orange 115 PriorityLow = newStyle().Foreground(lipgloss.Color(ColorAccent)) // #5CDFEA - Teal (low) 116 PriorityNone = newStyle().Foreground(lipgloss.Color(ColorTextMuted)) // #858392 - Gray (no priority) 117 PriorityLegacy = newStyle().Foreground(lipgloss.Color(Urchin.Hex())) // #C337E0 - Magenta (legacy) 118 119 MovieStyle = newBoldStyle().Foreground(lipgloss.Color(Coral.Hex())) // #FF577D - Pink/coral 120 TVStyle = newBoldStyle().Foreground(lipgloss.Color(Violet.Hex())) // #C259FF - Purple 121 BookStyle = newBoldStyle().Foreground(lipgloss.Color(Guac.Hex())) // #12C78F - Green 122 MusicStyle = newBoldStyle().Foreground(lipgloss.Color(Lichen.Hex())) // #5CDFEA - Teal 123 124 AdditionStyle = newStyle().Foreground(lipgloss.Color(Pickle.Hex())) // #00A475 - Green 125 DeletionStyle = newStyle().Foreground(lipgloss.Color(Pom.Hex())) // #AB2454 - Red 126)