mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-25 05:18:47 +00:00
refactor: Clean up colors.go formatting and remove unused style variables
- Remove unused color variables: blackColor, greenColor, blueColor, purpleColor, cyanColor - Remove unused base styles: baseStyle, focusedStyle, blurredStyle, helpStyle - Remove unused text styles: boldStyle, italicStyle, underlineStyle, dimStyle - Remove unused semantic styles: errorStyle, successStyle, warningStyle, infoStyle - Remove unused icon styles: iconStyle, iconSuccessStyle, iconErrorStyle, iconWarningStyle, iconInfoStyle
This commit is contained in:
+75
-134
@@ -10,40 +10,23 @@ import (
|
|||||||
// Color palette using lipgloss
|
// Color palette using lipgloss
|
||||||
var (
|
var (
|
||||||
// Primary colors
|
// Primary colors
|
||||||
primaryColor = lipgloss.Color("#4ECDC4") // Teal
|
primaryColor = lipgloss.Color("#4ECDC4") // Teal
|
||||||
accentColor = lipgloss.Color("#FF6B6B") // Red
|
accentColor = lipgloss.Color("#FF6B6B") // Red
|
||||||
mutedColor = lipgloss.Color("#999999") // Gray
|
mutedColor = lipgloss.Color("#999999") // Gray
|
||||||
whiteColor = lipgloss.Color("#FFFFFF") // White
|
whiteColor = lipgloss.Color("#FFFFFF") // White
|
||||||
blackColor = lipgloss.Color("#000000") // Black
|
|
||||||
|
|
||||||
// Semantic colors
|
// Semantic colors
|
||||||
successColor = lipgloss.Color("#4ECDC4") // Same as primary
|
successColor = lipgloss.Color("#4ECDC4") // Same as primary
|
||||||
warningColor = lipgloss.Color("#FFA726") // Orange
|
warningColor = lipgloss.Color("#FFA726") // Orange
|
||||||
errorColor = lipgloss.Color("#FF6B6B") // Same as accent
|
errorColor = lipgloss.Color("#FF6B6B") // Same as accent
|
||||||
infoColor = lipgloss.Color("#42A5F5") // Blue
|
infoColor = lipgloss.Color("#42A5F5") // Blue
|
||||||
|
|
||||||
// Additional colors
|
// Additional colors
|
||||||
yellowColor = lipgloss.Color("#FFD93D") // Yellow
|
yellowColor = lipgloss.Color("#FFD93D") // Yellow
|
||||||
greenColor = lipgloss.Color("#6BCF7F") // Green
|
|
||||||
blueColor = lipgloss.Color("#4A90E2") // Blue
|
|
||||||
purpleColor = lipgloss.Color("#9B59B6") // Purple
|
|
||||||
cyanColor = lipgloss.Color("#00BCD4") // Cyan
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Base styles
|
// Base styles
|
||||||
var (
|
var (
|
||||||
baseStyle = lipgloss.NewStyle().
|
|
||||||
BorderStyle(lipgloss.RoundedBorder())
|
|
||||||
|
|
||||||
focusedStyle = baseStyle.
|
|
||||||
BorderForeground(accentColor)
|
|
||||||
|
|
||||||
blurredStyle = baseStyle.
|
|
||||||
BorderForeground(mutedColor)
|
|
||||||
|
|
||||||
helpStyle = lipgloss.NewStyle().
|
|
||||||
Foreground(mutedColor)
|
|
||||||
|
|
||||||
headerStyle = lipgloss.NewStyle().
|
headerStyle = lipgloss.NewStyle().
|
||||||
Bold(true).
|
Bold(true).
|
||||||
Foreground(whiteColor).
|
Foreground(whiteColor).
|
||||||
@@ -63,16 +46,16 @@ var (
|
|||||||
|
|
||||||
// Status styles
|
// Status styles
|
||||||
statusSuccessStyle = lipgloss.NewStyle().
|
statusSuccessStyle = lipgloss.NewStyle().
|
||||||
Foreground(successColor).
|
Foreground(successColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
statusErrorStyle = lipgloss.NewStyle().
|
statusErrorStyle = lipgloss.NewStyle().
|
||||||
Foreground(errorColor).
|
Foreground(errorColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
statusWarningStyle = lipgloss.NewStyle().
|
statusWarningStyle = lipgloss.NewStyle().
|
||||||
Foreground(warningColor).
|
Foreground(warningColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
statusInfoStyle = lipgloss.NewStyle().
|
statusInfoStyle = lipgloss.NewStyle().
|
||||||
Foreground(infoColor).
|
Foreground(infoColor).
|
||||||
@@ -80,50 +63,44 @@ var (
|
|||||||
|
|
||||||
// Service status styles
|
// Service status styles
|
||||||
statusRunningStyle = lipgloss.NewStyle().
|
statusRunningStyle = lipgloss.NewStyle().
|
||||||
Foreground(successColor).
|
Foreground(successColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
statusStoppedStyle = lipgloss.NewStyle().
|
statusStoppedStyle = lipgloss.NewStyle().
|
||||||
Foreground(errorColor).
|
Foreground(errorColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
statusPendingStyle = lipgloss.NewStyle().
|
statusPendingStyle = lipgloss.NewStyle().
|
||||||
Foreground(warningColor).
|
Foreground(warningColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
statusUnknownStyle = lipgloss.NewStyle().
|
statusUnknownStyle = lipgloss.NewStyle().
|
||||||
Foreground(mutedColor).
|
Foreground(mutedColor).
|
||||||
Italic(true)
|
Italic(true)
|
||||||
|
|
||||||
// Subscriber status styles
|
// Subscriber status styles
|
||||||
statusActiveStyle = lipgloss.NewStyle().
|
statusActiveStyle = lipgloss.NewStyle().
|
||||||
Foreground(successColor).
|
Foreground(successColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
statusInactiveStyle = lipgloss.NewStyle().
|
statusInactiveStyle = lipgloss.NewStyle().
|
||||||
Foreground(errorColor).
|
Foreground(errorColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
statusSuspendedStyle = lipgloss.NewStyle().
|
statusSuspendedStyle = lipgloss.NewStyle().
|
||||||
Foreground(warningColor).
|
Foreground(warningColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
// Metric styles
|
// Metric styles
|
||||||
metricGoodStyle = lipgloss.NewStyle().
|
metricGoodStyle = lipgloss.NewStyle().
|
||||||
Foreground(successColor)
|
Foreground(successColor)
|
||||||
|
|
||||||
metricWarningStyle = lipgloss.NewStyle().
|
metricWarningStyle = lipgloss.NewStyle().
|
||||||
Foreground(warningColor)
|
Foreground(warningColor)
|
||||||
|
|
||||||
metricCriticalStyle = lipgloss.NewStyle().
|
metricCriticalStyle = lipgloss.NewStyle().
|
||||||
Foreground(errorColor).
|
Foreground(errorColor).
|
||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
// Text styles
|
|
||||||
boldStyle = lipgloss.NewStyle().Bold(true)
|
|
||||||
italicStyle = lipgloss.NewStyle().Italic(true)
|
|
||||||
underlineStyle = lipgloss.NewStyle().Underline(true)
|
|
||||||
dimStyle = lipgloss.NewStyle().Faint(true)
|
|
||||||
|
|
||||||
// Command styles
|
// Command styles
|
||||||
commandStyle = lipgloss.NewStyle().
|
commandStyle = lipgloss.NewStyle().
|
||||||
@@ -139,25 +116,25 @@ var (
|
|||||||
Bold(true)
|
Bold(true)
|
||||||
|
|
||||||
descriptionStyle = lipgloss.NewStyle().
|
descriptionStyle = lipgloss.NewStyle().
|
||||||
Foreground(mutedColor).
|
Foreground(mutedColor).
|
||||||
Italic(true)
|
Italic(true)
|
||||||
|
|
||||||
// Table styles
|
// Table styles
|
||||||
tableHeaderStyle = lipgloss.NewStyle().
|
tableHeaderStyle = lipgloss.NewStyle().
|
||||||
Bold(true).
|
Bold(true).
|
||||||
Foreground(primaryColor).
|
Foreground(primaryColor).
|
||||||
Background(lipgloss.Color("#2D2D2D")).
|
Background(lipgloss.Color("#2D2D2D")).
|
||||||
Padding(0, 1)
|
Padding(0, 1)
|
||||||
|
|
||||||
tableBorderStyle = lipgloss.NewStyle().
|
tableBorderStyle = lipgloss.NewStyle().
|
||||||
Foreground(mutedColor).
|
Foreground(mutedColor).
|
||||||
Faint(true)
|
Faint(true)
|
||||||
|
|
||||||
tableRowEvenStyle = lipgloss.NewStyle().
|
tableRowEvenStyle = lipgloss.NewStyle().
|
||||||
Foreground(whiteColor)
|
Foreground(whiteColor)
|
||||||
|
|
||||||
tableRowOddStyle = lipgloss.NewStyle().
|
tableRowOddStyle = lipgloss.NewStyle().
|
||||||
Foreground(lipgloss.Color("#F0F0F0"))
|
Foreground(lipgloss.Color("#F0F0F0"))
|
||||||
|
|
||||||
// Panel styles
|
// Panel styles
|
||||||
panelStyle = lipgloss.NewStyle().
|
panelStyle = lipgloss.NewStyle().
|
||||||
@@ -166,27 +143,11 @@ var (
|
|||||||
Padding(1)
|
Padding(1)
|
||||||
|
|
||||||
panelFocusedStyle = lipgloss.NewStyle().
|
panelFocusedStyle = lipgloss.NewStyle().
|
||||||
BorderStyle(lipgloss.RoundedBorder()).
|
BorderStyle(lipgloss.RoundedBorder()).
|
||||||
BorderForeground(accentColor).
|
BorderForeground(accentColor).
|
||||||
Padding(1)
|
Padding(1)
|
||||||
|
|
||||||
// Error and success styles
|
|
||||||
errorStyle = lipgloss.NewStyle().
|
|
||||||
Foreground(errorColor).
|
|
||||||
Bold(true)
|
|
||||||
|
|
||||||
successStyle = lipgloss.NewStyle().
|
|
||||||
Foreground(successColor).
|
|
||||||
Bold(true)
|
|
||||||
|
|
||||||
warningStyle = lipgloss.NewStyle().
|
|
||||||
Foreground(warningColor).
|
|
||||||
Bold(true)
|
|
||||||
|
|
||||||
infoStyle = lipgloss.NewStyle().
|
|
||||||
Foreground(infoColor).
|
|
||||||
Bold(true)
|
|
||||||
|
|
||||||
|
// Debug and muted styles
|
||||||
debugStyle = lipgloss.NewStyle().
|
debugStyle = lipgloss.NewStyle().
|
||||||
Foreground(mutedColor).
|
Foreground(mutedColor).
|
||||||
Italic(true)
|
Italic(true)
|
||||||
@@ -194,26 +155,6 @@ var (
|
|||||||
mutedStyle = lipgloss.NewStyle().
|
mutedStyle = lipgloss.NewStyle().
|
||||||
Foreground(mutedColor).
|
Foreground(mutedColor).
|
||||||
Faint(true)
|
Faint(true)
|
||||||
|
|
||||||
// Icon styles
|
|
||||||
iconStyle = lipgloss.NewStyle().
|
|
||||||
Bold(true)
|
|
||||||
|
|
||||||
iconSuccessStyle = lipgloss.NewStyle().
|
|
||||||
Foreground(successColor).
|
|
||||||
Bold(true)
|
|
||||||
|
|
||||||
iconErrorStyle = lipgloss.NewStyle().
|
|
||||||
Foreground(errorColor).
|
|
||||||
Bold(true)
|
|
||||||
|
|
||||||
iconWarningStyle = lipgloss.NewStyle().
|
|
||||||
Foreground(warningColor).
|
|
||||||
Bold(true)
|
|
||||||
|
|
||||||
iconInfoStyle = lipgloss.NewStyle().
|
|
||||||
Foreground(infoColor).
|
|
||||||
Bold(true)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Style represents a lipgloss style
|
// Style represents a lipgloss style
|
||||||
@@ -223,33 +164,33 @@ type Style struct {
|
|||||||
|
|
||||||
// Predefined styles using lipgloss
|
// Predefined styles using lipgloss
|
||||||
var (
|
var (
|
||||||
StyleSuccess = Style{Style: statusSuccessStyle}
|
StyleSuccess = Style{Style: statusSuccessStyle}
|
||||||
StyleError = Style{Style: statusErrorStyle}
|
StyleError = Style{Style: statusErrorStyle}
|
||||||
StyleWarning = Style{Style: statusWarningStyle}
|
StyleWarning = Style{Style: statusWarningStyle}
|
||||||
StyleInfo = Style{Style: statusInfoStyle}
|
StyleInfo = Style{Style: statusInfoStyle}
|
||||||
StyleDebug = Style{Style: debugStyle}
|
StyleDebug = Style{Style: debugStyle}
|
||||||
StyleMuted = Style{Style: mutedStyle}
|
StyleMuted = Style{Style: mutedStyle}
|
||||||
|
|
||||||
StyleRunning = Style{Style: statusRunningStyle}
|
StyleRunning = Style{Style: statusRunningStyle}
|
||||||
StyleStopped = Style{Style: statusStoppedStyle}
|
StyleStopped = Style{Style: statusStoppedStyle}
|
||||||
StylePending = Style{Style: statusPendingStyle}
|
StylePending = Style{Style: statusPendingStyle}
|
||||||
StyleUnknown = Style{Style: statusUnknownStyle}
|
StyleUnknown = Style{Style: statusUnknownStyle}
|
||||||
|
|
||||||
StyleActive = Style{Style: statusActiveStyle}
|
StyleActive = Style{Style: statusActiveStyle}
|
||||||
StyleInactive = Style{Style: statusInactiveStyle}
|
StyleInactive = Style{Style: statusInactiveStyle}
|
||||||
StyleSuspended = Style{Style: statusSuspendedStyle}
|
StyleSuspended = Style{Style: statusSuspendedStyle}
|
||||||
|
|
||||||
StyleHeader = Style{Style: headerStyle}
|
StyleHeader = Style{Style: headerStyle}
|
||||||
StyleSubHeader = Style{Style: subHeaderStyle}
|
StyleSubHeader = Style{Style: subHeaderStyle}
|
||||||
StyleTitle = Style{Style: titleStyle}
|
StyleTitle = Style{Style: titleStyle}
|
||||||
|
|
||||||
StyleHeaderRow = Style{Style: tableHeaderStyle}
|
StyleHeaderRow = Style{Style: tableHeaderStyle}
|
||||||
StyleRowEven = Style{Style: tableRowEvenStyle}
|
StyleRowEven = Style{Style: tableRowEvenStyle}
|
||||||
StyleRowOdd = Style{Style: tableRowOddStyle}
|
StyleRowOdd = Style{Style: tableRowOddStyle}
|
||||||
StyleBorder = Style{Style: tableBorderStyle}
|
StyleBorder = Style{Style: tableBorderStyle}
|
||||||
|
|
||||||
StyleMetricGood = Style{Style: metricGoodStyle}
|
StyleMetricGood = Style{Style: metricGoodStyle}
|
||||||
StyleMetricWarning = Style{Style: metricWarningStyle}
|
StyleMetricWarning = Style{Style: metricWarningStyle}
|
||||||
StyleMetricCritical = Style{Style: metricCriticalStyle}
|
StyleMetricCritical = Style{Style: metricCriticalStyle}
|
||||||
|
|
||||||
StyleCommand = Style{Style: commandStyle}
|
StyleCommand = Style{Style: commandStyle}
|
||||||
@@ -257,7 +198,7 @@ var (
|
|||||||
StyleArgument = Style{Style: argumentStyle}
|
StyleArgument = Style{Style: argumentStyle}
|
||||||
StyleDescription = Style{Style: descriptionStyle}
|
StyleDescription = Style{Style: descriptionStyle}
|
||||||
|
|
||||||
StylePanel = Style{Style: panelStyle}
|
StylePanel = Style{Style: panelStyle}
|
||||||
StylePanelFocused = Style{Style: panelFocusedStyle}
|
StylePanelFocused = Style{Style: panelFocusedStyle}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -369,12 +310,12 @@ func (c *Colorizer) StatusSuspended(text string) string {
|
|||||||
// Metric colorizations based on value
|
// Metric colorizations based on value
|
||||||
func (c *Colorizer) Metric(value float64, thresholds ...float64) string {
|
func (c *Colorizer) Metric(value float64, thresholds ...float64) string {
|
||||||
text := fmt.Sprintf("%.1f%%", value)
|
text := fmt.Sprintf("%.1f%%", value)
|
||||||
|
|
||||||
// Default thresholds if not provided
|
// Default thresholds if not provided
|
||||||
if len(thresholds) == 0 {
|
if len(thresholds) == 0 {
|
||||||
thresholds = []float64{70, 90}
|
thresholds = []float64{70, 90}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case value >= thresholds[1]:
|
case value >= thresholds[1]:
|
||||||
return c.Colorize(text, StyleMetricCritical)
|
return c.Colorize(text, StyleMetricCritical)
|
||||||
@@ -399,12 +340,12 @@ func ShouldDisableColors() bool {
|
|||||||
if os.Getenv("NO_COLOR") != "" {
|
if os.Getenv("NO_COLOR") != "" {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if output is not a TTY
|
// Check if output is not a TTY
|
||||||
if fileInfo, _ := os.Stdout.Stat(); fileInfo != nil {
|
if fileInfo, _ := os.Stdout.Stat(); fileInfo != nil {
|
||||||
return (fileInfo.Mode() & 0o100) == 0 // Not a TTY
|
return (fileInfo.Mode() & 0o100) == 0 // Not a TTY
|
||||||
}
|
}
|
||||||
|
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user