90 lines
2.0 KiB
Swift
90 lines
2.0 KiB
Swift
/// 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 blue
|
|
case darkGray
|
|
case darkYellow
|
|
case gray
|
|
case yellow
|
|
|
|
var color: String {
|
|
switch self {
|
|
case .blue: return "border-blue-500"
|
|
case .darkGray: return "border-gray-400"
|
|
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)
|
|
}
|
|
}
|