feat: Adds styleguide, working on result view container.
This commit is contained in:
85
Sources/Styleguide/Colors.swift
Normal file
85
Sources/Styleguide/Colors.swift
Normal file
@@ -0,0 +1,85 @@
|
||||
/// Common tailwind colors used.
|
||||
///
|
||||
/// Use these with string interpolation in the class.
|
||||
///
|
||||
/// **Example:**
|
||||
///
|
||||
/// ```swift
|
||||
/// div(.class("\(text: .yellow) \(border: .gray) \(bg: .blue)")) {
|
||||
/// ...
|
||||
/// }
|
||||
/// ```
|
||||
public enum Color {
|
||||
|
||||
public enum BackgroundColor: Sendable {
|
||||
case blue
|
||||
case darkBlue
|
||||
case darkGray
|
||||
case darkSlate
|
||||
case slate
|
||||
case yellow
|
||||
|
||||
var color: String {
|
||||
switch self {
|
||||
case .blue: return "bg-blue-500"
|
||||
case .darkBlue: return "bg-blue-600"
|
||||
case .darkGray: return "bg-gray-700"
|
||||
case .darkSlate: return "bg-slate-700"
|
||||
case .slate: return "bg-slate-300"
|
||||
case .yellow: return "bg-yellow-300"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum BorderColor: Sendable {
|
||||
case darkYellow
|
||||
case gray
|
||||
case yellow
|
||||
|
||||
var color: String {
|
||||
switch self {
|
||||
case .darkYellow: return "border-yellow-800"
|
||||
case .gray: return "border-gray-300"
|
||||
case .yellow: return "border-yellow-300"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum TextColor: Sendable {
|
||||
case blue
|
||||
case darkBlue
|
||||
case darkGray
|
||||
case gray
|
||||
case green
|
||||
case yellow
|
||||
case white
|
||||
|
||||
var color: String {
|
||||
switch self {
|
||||
case .blue: return "text-blue-500"
|
||||
case .darkBlue: return "text-blue-600"
|
||||
case .darkGray: return "text-gray-700"
|
||||
case .gray: return "text-gray-300"
|
||||
case .green: return "text-green-600"
|
||||
case .yellow: return "text-yellow-300"
|
||||
case .white: return "text-white"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public extension String.StringInterpolation {
|
||||
|
||||
mutating func appendInterpolation(bg background: Color.BackgroundColor) {
|
||||
appendInterpolation(background.color)
|
||||
}
|
||||
|
||||
mutating func appendInterpolation(border: Color.BorderColor) {
|
||||
appendInterpolation(border.color)
|
||||
}
|
||||
|
||||
mutating func appendInterpolation(text: Color.TextColor) {
|
||||
appendInterpolation(text.color)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user