Files
TUIkit/Sources/TUIkitExample/Pages/ColorsPage.swift
T
phranck ac5e63eb84 Feat: Add ButtonRole, horizontal Alert buttons, ESC dismiss, arrow key navigation
- Add ButtonRole (.cancel, .destructive) with SwiftUI-conformant API
- Alert renders buttons horizontally, sorted by role (cancel left)
- Alert max width capped at 60 characters for readability
- ESC key dismisses alerts via AlertPresentationModifier handler
- FocusManager: Left/Right arrows navigate within sections (like Up/Down)
- Move completed plans to done/ directory
- Update example pages with minor adjustments
2026-02-08 23:00:59 +01:00

73 lines
2.5 KiB
Swift
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 🖥 TUIKit Terminal UI Kit for Swift
// ColorsPage.swift
//
// Created by LAYERED.work
// License: MIT
import TUIkit
/// Colors demo page.
///
/// Shows various color options including:
/// - Standard ANSI colors (8 colors)
/// - Bright colors (8 colors)
/// - RGB colors (24-bit true color)
/// - Semantic colors (primary, success, warning, error)
struct ColorsPage: View {
var body: some View {
VStack(alignment: .leading, spacing: 1) {
DemoSection("Standard ANSI Colors") {
HStack(spacing: 2) {
Text("Black").foregroundStyle(.black).background(.white)
Text("Red").foregroundStyle(.red)
Text("Green").foregroundStyle(.green)
Text("Yellow").foregroundStyle(.yellow)
}
HStack(spacing: 2) {
Text("Blue").foregroundStyle(.blue)
Text("Magenta").foregroundStyle(.magenta)
Text("Cyan").foregroundStyle(.cyan)
Text("White").foregroundStyle(.white)
}
}
DemoSection("Bright Colors") {
HStack(spacing: 2) {
Text("Bright Red").foregroundStyle(.brightRed)
Text("Bright Green").foregroundStyle(.brightGreen)
Text("Bright Yellow").foregroundStyle(.brightYellow)
Text("Bright Blue").foregroundStyle(.brightBlue)
}
}
DemoSection("RGB Colors (24-bit)") {
HStack(spacing: 2) {
Text("Orange").foregroundStyle(.rgb(255, 128, 0))
Text("Pink").foregroundStyle(.rgb(255, 105, 180))
Text("Teal").foregroundStyle(.rgb(0, 128, 128))
Text("Purple").foregroundStyle(.rgb(128, 0, 128))
}
}
DemoSection("Semantic Colors") {
HStack(spacing: 2) {
Text("Primary").foregroundStyle(.primary)
Text("Success").foregroundStyle(.success)
Text("Warning").foregroundStyle(.warning)
Text("Error").foregroundStyle(.error)
}
}
Spacer()
}
.appHeader {
HStack {
Text("Colors Demo").bold().foregroundStyle(.palette.accent)
Spacer()
Text("TUIkit v\(tuiKitVersion)").foregroundStyle(.palette.foregroundTertiary)
}
}
}
}