refactor(ui): replace neon palette and ad-hoc echo with minimal design system
- reduce color palette to red/cyan/white/gray; alias legacy vars onto CYAN - add show_box_top/mid/bottom, show_separator, show_menu_item, show_prompt helpers to lib/common.sh - update apps/index.sh and tools/index.sh to use new UI helpers instead of inline echo/ANSI - drop BLINK, REV escape codes and remove hardcoded prompt strings from callers
This commit is contained in:
+99
-27
@@ -7,46 +7,118 @@
|
||||
# Repo: https://git.hyko.cx/hykocx/lxs
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# Colors — Cyberpunk 2077 neon palette
|
||||
# Colors — minimal palette: red, cyan, white (+ gray as a white shade)
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
RED='\033[1;91m' # ICE alert
|
||||
GREEN='\033[1;92m' # phosphor green
|
||||
YELLOW='\033[1;93m' # signature electric yellow
|
||||
MAGENTA='\033[1;95m' # hot pink neon
|
||||
CYAN='\033[1;96m' # neon cyan
|
||||
WHITE='\033[1;97m' # bold white
|
||||
GRAY='\033[0;90m' # dark gray
|
||||
PURPLE='\033[1;95m' # alias on MAGENTA for legacy sub-scripts
|
||||
RED='\033[38;2;255;64;64m' # errors, destructive actions
|
||||
CYAN='\033[38;2;0;229;255m' # accents, titles, OK, info
|
||||
WHITE='\033[38;2;240;240;240m' # primary text
|
||||
GRAY='\033[38;2;140;140;140m' # secondary text, comments, separators
|
||||
NC='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
DIM='\033[2m'
|
||||
BLINK='\033[5m'
|
||||
REV='\033[7m'
|
||||
|
||||
# Legacy aliases — older sub-scripts still reference these. Map onto CYAN
|
||||
# so the palette stays at red/cyan/white without breaking them.
|
||||
YELLOW="$CYAN"
|
||||
GREEN="$CYAN"
|
||||
MAGENTA="$CYAN"
|
||||
PURPLE="$CYAN"
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
# UI helpers
|
||||
# UI helpers — title + horizontal rule, no closed box.
|
||||
#
|
||||
# Layout:
|
||||
# show_box_top "TITLE" ["RIGHT_TAG"] → TITLE [ RIGHT ]
|
||||
# ─────────────────────────────────
|
||||
# show_box_mid "SECTION" → ─ SECTION ─────────────────────
|
||||
# show_box_bottom → ───────────────────────────────
|
||||
# show_separator → ─── (light gray divider)
|
||||
# show_menu_item "01" "LABEL" "desc" → [01] LABEL // desc
|
||||
# show_prompt → >
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
|
||||
_lxs_term_cols() {
|
||||
local cols
|
||||
cols=$(tput cols 2>/dev/null || echo 80)
|
||||
[ "$cols" -gt 100 ] && cols=100
|
||||
[ "$cols" -lt 60 ] && cols=60
|
||||
echo "$cols"
|
||||
}
|
||||
|
||||
show_box_top() {
|
||||
local title="$1" right="${2:-}"
|
||||
local cols pad_len pad
|
||||
cols=$(_lxs_term_cols)
|
||||
if [ -n "$right" ]; then
|
||||
pad_len=$(( cols - 2 - ${#title} - ${#right} - 4 ))
|
||||
[ "$pad_len" -lt 1 ] && pad_len=1
|
||||
pad=$(printf ' %.0s' $(seq 1 "$pad_len"))
|
||||
printf " ${CYAN}${BOLD}%s${NC}%s${GRAY}[ ${CYAN}%s${GRAY} ]${NC}\n" \
|
||||
"$title" "$pad" "$right"
|
||||
else
|
||||
printf " ${CYAN}${BOLD}%s${NC}\n" "$title"
|
||||
fi
|
||||
_lxs_hr "$cols"
|
||||
}
|
||||
|
||||
show_box_mid() {
|
||||
local title="$1"
|
||||
local cols fill_len fill
|
||||
cols=$(_lxs_term_cols)
|
||||
fill_len=$(( cols - ${#title} - 4 ))
|
||||
[ "$fill_len" -lt 2 ] && fill_len=2
|
||||
fill=$(printf '─%.0s' $(seq 1 "$fill_len"))
|
||||
printf "${GRAY}─ ${CYAN}${BOLD}%s${NC} ${GRAY}%s${NC}\n" "$title" "$fill"
|
||||
}
|
||||
|
||||
show_box_bottom() {
|
||||
_lxs_hr "$(_lxs_term_cols)"
|
||||
}
|
||||
|
||||
show_separator() {
|
||||
local cols
|
||||
cols=$(tput cols 2>/dev/null || echo 64)
|
||||
printf "${YELLOW}"
|
||||
printf '▀%.0s' $(seq 1 "$cols")
|
||||
printf "${NC}\n"
|
||||
_lxs_hr "$(_lxs_term_cols)"
|
||||
}
|
||||
|
||||
_lxs_hr() {
|
||||
local cols=$1 fill
|
||||
fill=$(printf '─%.0s' $(seq 1 "$cols"))
|
||||
printf "${GRAY}%s${NC}\n" "$fill"
|
||||
}
|
||||
|
||||
show_title() {
|
||||
local title="$1"
|
||||
local subtitle="${2:-SYS_MODULE}"
|
||||
local subtitle="${2:-}"
|
||||
echo ""
|
||||
echo -e "${YELLOW}${REV} ${title} ${NC} ${MAGENTA}// ${subtitle}${NC}"
|
||||
show_separator
|
||||
if [ -n "$subtitle" ]; then
|
||||
show_box_top "$title" "$subtitle"
|
||||
else
|
||||
show_box_top "$title"
|
||||
fi
|
||||
}
|
||||
|
||||
info() { echo -e "${MAGENTA}[··]${NC} $*"; }
|
||||
ok() { echo -e "${GREEN}[OK]${NC} $*"; }
|
||||
warn() { echo -e "${YELLOW}[!!]${NC} $*"; }
|
||||
# Render a menu line. Pass "exit" as 4th arg to color the key red.
|
||||
# show_menu_item "01" "APPLICATIONS" "deploy stacks"
|
||||
# show_menu_item "00" "EXIT" "quit shell" exit
|
||||
show_menu_item() {
|
||||
local key="$1" label="$2" desc="${3:-}" kind="${4:-}"
|
||||
local key_color="${CYAN}"
|
||||
[ "$kind" = "exit" ] && key_color="${RED}"
|
||||
if [ -n "$desc" ]; then
|
||||
printf " ${key_color}[%s]${NC} ${WHITE}${BOLD}%-18s${NC} ${GRAY}// %s${NC}\n" \
|
||||
"$key" "$label" "$desc"
|
||||
else
|
||||
printf " ${key_color}[%s]${NC} ${WHITE}${BOLD}%s${NC}\n" "$key" "$label"
|
||||
fi
|
||||
}
|
||||
|
||||
show_prompt() {
|
||||
echo -e -n " ${CYAN}>${NC} "
|
||||
}
|
||||
|
||||
info() { echo -e "${CYAN}[..]${NC} $*"; }
|
||||
ok() { echo -e "${CYAN}[OK]${NC} $*"; }
|
||||
warn() { echo -e "${CYAN}[!!]${NC} $*"; }
|
||||
err() { echo -e "${RED}[KO]${NC} $*" >&2; }
|
||||
|
||||
# ═══════════════════════════════════════════════════════════════════════════
|
||||
@@ -67,13 +139,13 @@ run_spinner() {
|
||||
local spinstr='|/-\'
|
||||
local log="${LXS_LOG_FILE:-/tmp/lxs.log}"
|
||||
|
||||
echo -e "${MAGENTA}[··] ${message}${NC}"
|
||||
echo -e "${CYAN}[..] ${message}${NC}"
|
||||
eval "$command" > "$log" 2>&1 &
|
||||
local pid=$!
|
||||
|
||||
while kill -0 "$pid" 2>/dev/null; do
|
||||
local temp=${spinstr#?}
|
||||
printf "\r${MAGENTA}[%c·]${NC} ${message}" "$spinstr"
|
||||
printf "\r${CYAN}[%c.]${NC} ${message}" "$spinstr"
|
||||
spinstr=$temp${spinstr%"$temp"}
|
||||
sleep 0.15
|
||||
done
|
||||
@@ -81,7 +153,7 @@ run_spinner() {
|
||||
wait "$pid"
|
||||
local exit_code=$?
|
||||
if [ $exit_code -eq 0 ]; then
|
||||
printf "\r${GREEN}[OK]${NC} ${message}\n"
|
||||
printf "\r${CYAN}[OK]${NC} ${message}\n"
|
||||
else
|
||||
printf "\r${RED}[KO]${NC} ${message}\n"
|
||||
fi
|
||||
@@ -176,7 +248,7 @@ wait_for_apt() {
|
||||
[ $wait_count -ge $max_wait ] && \
|
||||
echo -e "${RED}[KO] Timeout waiting for package manager${NC}" && return 1
|
||||
|
||||
printf "\r${GRAY}[··] Waiting... (%ds/%ds)${NC}" $wait_count $max_wait
|
||||
printf "\r${GRAY}[..] Waiting... (%ds/%ds)${NC}" $wait_count $max_wait
|
||||
sleep 1
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user