Skip to content

Privacy-first password manager with built-in email aliasing. Fully encrypted and self-hostable.

5.0 KB
Raw Blame
// <auto-generated />
// This file is auto-generated from core/assets/colors/palette.json by core/models/scripts/generate-colors.cjs.
// Do not edit this file directly. Run 'node core/models/scripts/generate-colors.cjs' to regenerate.

import SwiftUI

/// Color constants for the app
public struct ColorConstants {
    /// Light mode colors
    public struct Light {
        public static let text = SwiftUI.Color(hex: "#11181c")
        public static let textMuted = SwiftUI.Color(hex: "#4b5563")
        public static let background = SwiftUI.Color(hex: "#f3f2f7")
        public static let accentBackground = SwiftUI.Color(hex: "#ffffff")
        public static let accentBorder = SwiftUI.Color(hex: "#d1d5db")
        public static let primary = SwiftUI.Color(hex: "#f49541")
        public static let primarySurfaceText = SwiftUI.Color(hex: "#ffffff")
        public static let secondary = SwiftUI.Color(hex: "#6b7280")
        public static let tertiary = SwiftUI.Color(hex: "#eabf69")
        public static let icon = SwiftUI.Color(hex: "#687076")
        public static let success = SwiftUI.Color(hex: "#10b981")
        public static let successBackground = SwiftUI.Color(hex: "#dcfce7")
        public static let warning = SwiftUI.Color(hex: "#d97706")
        public static let warningBackground = SwiftUI.Color(hex: "#fef3c7")
        public static let info = SwiftUI.Color(hex: "#2563eb")
        public static let infoBackground = SwiftUI.Color(hex: "#dbeafe")
        public static let destructive = SwiftUI.Color(hex: "#ef4444")
    }

    /// Dark mode colors
    public struct Dark {
        public static let text = SwiftUI.Color(hex: "#ecedee")
        public static let textMuted = SwiftUI.Color(hex: "#9ba1a6")
        public static let background = SwiftUI.Color(hex: "#000000")
        public static let accentBackground = SwiftUI.Color(hex: "#202020")
        public static let accentBorder = SwiftUI.Color(hex: "#444444")
        public static let primary = SwiftUI.Color(hex: "#f49541")
        public static let primarySurfaceText = SwiftUI.Color(hex: "#ffffff")
        public static let secondary = SwiftUI.Color(hex: "#6b7280")
        public static let tertiary = SwiftUI.Color(hex: "#eabf69")
        public static let icon = SwiftUI.Color(hex: "#9ba1a6")
        public static let success = SwiftUI.Color(hex: "#10b981")
        public static let successBackground = SwiftUI.Color(hex: "#1a3d2b")
        public static let warning = SwiftUI.Color(hex: "#f59e0b")
        public static let warningBackground = SwiftUI.Color(hex: "#352d1e")
        public static let info = SwiftUI.Color(hex: "#3b82f6")
        public static let infoBackground = SwiftUI.Color(hex: "#1e3a5f")
        public static let destructive = SwiftUI.Color(hex: "#ef4444")
    }

    /// Get colors for the specified color scheme
    /// - Parameter colorScheme: The current color scheme
    /// - Returns: The appropriate color constants (Light or Dark)
    public static func colors(for colorScheme: ColorScheme) -> Colors.Type {
        colorScheme == .dark ? Dark.self : Light.self
    }

    /// Protocol to enable generic access to color properties
    public protocol Colors {
        static var text: Color { get }
        static var textMuted: Color { get }
        static var background: Color { get }
        static var accentBackground: Color { get }
        static var accentBorder: Color { get }
        static var primary: Color { get }
        static var primarySurfaceText: Color { get }
        static var secondary: Color { get }
        static var tertiary: Color { get }
        static var icon: Color { get }
        static var success: Color { get }
        static var successBackground: Color { get }
        static var warning: Color { get }
        static var warningBackground: Color { get }
        static var info: Color { get }
        static var infoBackground: Color { get }
        static var destructive: Color { get }
    }
}

// Conform Light and Dark to the Colors protocol
extension ColorConstants.Light: ColorConstants.Colors {}
extension ColorConstants.Dark: ColorConstants.Colors {}

// Add Color extension for hex support
extension SwiftUI.Color {
    init(hex: String) {
        let hex = hex.trimmingCharacters(in: CharacterSet.alphanumerics.inverted)
        var int: UInt64 = 0
        Scanner(string: hex).scanHexInt64(&int)
        let colorA, colorR, colorG, colorB: UInt64
        switch hex.count {
        case 3: (colorA, colorR, colorG, colorB) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17)
        case 6: (colorA, colorR, colorG, colorB) = (255, int >> 16, int >> 8 & 0xFF, int & 0xFF)
        case 8: (colorA, colorR, colorG, colorB) = (int >> 24, int >> 16 & 0xFF, int >> 8 & 0xFF, int & 0xFF)
        default: (colorA, colorR, colorG, colorB) = (255, 0, 0, 0)
        }
        self.init(
            .sRGB,
            red: Double(colorR) / 255,
            green: Double(colorG) / 255,
            blue: Double(colorB) / 255,
            opacity: Double(colorA) / 255
        )
    }
}