120 lines
3.6 KiB
Swift
120 lines
3.6 KiB
Swift
//
|
|
// VDSColor.swift
|
|
// VDS
|
|
//
|
|
// Created by Matt Bruce on 5/15/23.
|
|
//
|
|
|
|
import Foundation
|
|
import VDSColorTokens
|
|
|
|
extension VDSColor {
|
|
public enum Color: String, CaseIterable {
|
|
case paletteBlack
|
|
case paletteWhite
|
|
case paletteRed
|
|
case paletteGray95
|
|
case paletteGray85
|
|
case paletteGray65
|
|
case paletteGray44
|
|
case paletteGray20
|
|
case paletteGray11
|
|
case paletteOrange94
|
|
case paletteOrange83
|
|
case paletteOrange71
|
|
case paletteOrange58
|
|
case paletteOrange41
|
|
case paletteOrange24
|
|
case paletteOrange17
|
|
case paletteYellow94
|
|
case paletteYellow87
|
|
case paletteYellow74
|
|
case paletteYellow53
|
|
case paletteYellow39
|
|
case paletteYellow20
|
|
case paletteYellow15
|
|
case paletteBlue94
|
|
case paletteBlue82
|
|
case paletteBlue62
|
|
case paletteBlue46
|
|
case paletteBlue38
|
|
case paletteBlue21
|
|
case paletteBlue15
|
|
case paletteGreen91
|
|
case paletteGreen77
|
|
case paletteGreen61
|
|
case paletteGreen36
|
|
case paletteGreen26
|
|
case paletteGreen15
|
|
case paletteGreen10
|
|
case palettePink87
|
|
case palettePink76
|
|
case palettePink62
|
|
case palettePink46
|
|
case palettePink25
|
|
case palettePurple85
|
|
case palettePurple75
|
|
case palettePurple60
|
|
case palettePurple39
|
|
case palettePurple20
|
|
case backgroundPrimaryLight
|
|
case backgroundPrimaryDark
|
|
case backgroundSecondaryLight
|
|
case backgroundSecondaryDark
|
|
case backgroundBrandhighlight
|
|
case feedbackErrorOnlight
|
|
case feedbackErrorOndark
|
|
case feedbackErrorBackgroundOnlight
|
|
case feedbackErrorBackgroundOndark
|
|
case feedbackWarningOnlight
|
|
case feedbackWarningOndark
|
|
case feedbackWarningBackgroundOnlight
|
|
case feedbackWarningBackgroundOndark
|
|
case feedbackInformationOnlight
|
|
case feedbackInformationOndark
|
|
case feedbackInformationBackgroundOnlight
|
|
case feedbackInformationBackgroundOndark
|
|
case feedbackSuccessOnlight
|
|
case feedbackSuccessOndark
|
|
case feedbackSuccessBackgroundOnlight
|
|
case feedbackSuccessBackgroundOndark
|
|
case interactiveActiveOnlight
|
|
case interactiveActiveOndark
|
|
case interactiveDisabledOnlight
|
|
case interactiveDisabledOndark
|
|
case interactiveScrollthumbOnlight
|
|
case interactiveScrollthumbOndark
|
|
case interactiveScrollthumbHoverOnlight
|
|
case interactiveScrollthumbHoverOndark
|
|
case interactiveScrolltrackOnlight
|
|
case interactiveScrolltrackOndark
|
|
case elementsPrimaryOnlight
|
|
case elementsPrimaryOndark
|
|
case elementsSecondaryOnlight
|
|
case elementsSecondaryOndark
|
|
case elementsBrandhighlight
|
|
case elementsLowcontrastOnlight
|
|
case elementsLowcontrastOndark
|
|
|
|
// Map each color name to its corresponding UIColor object.
|
|
public var uiColor: UIColor {
|
|
do {
|
|
let color = try VDSColor.getTokenByString(tokenName: "VDSColor.\(rawValue)")
|
|
return color
|
|
} catch {
|
|
print(error)
|
|
return VDSColor.paletteBlack
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
extension UIColor {
|
|
public static func isVDSColor(color: UIColor) -> Bool {
|
|
guard let hex = color.hexString else { return false }
|
|
let found = VDSColor.Color.allCases.first{ $0.uiColor.hexString == hex }
|
|
guard let _ = found else { return false}
|
|
return true
|
|
}
|
|
}
|