Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,6 @@ vendor/bundle
.bundle/
.claude/settings.local.json
/.claude/worktrees

# Local SPM package transient files
Sources/HADesignSystem/Package.resolved
109 changes: 27 additions & 82 deletions HomeAssistant.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions Sources/HADesignSystem/Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "HADesignSystem",
platforms: [
.iOS(.v16),
.watchOS(.v9),
],
Comment thread
bgoncal marked this conversation as resolved.
products: [
.library(name: "HADesignSystem", targets: ["HADesignSystem"]),
],
dependencies: [
.package(url: "https://github.com/SFSafeSymbols/SFSafeSymbols", .upToNextMajor(from: "5.3.0")),
],
targets: [
.target(
name: "HADesignSystem",
dependencies: ["SFSafeSymbols"],
path: "Sources"
),
.testTarget(
name: "HADesignSystemTests",
dependencies: ["HADesignSystem"],
path: "Tests"
),
]
)
43 changes: 43 additions & 0 deletions Sources/HADesignSystem/Sources/Colors/Color+Semantic.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import SwiftUI
#if canImport(UIKit)
import UIKit
#endif

public extension Color {
static let haPrimary = Color(.sRGB, red: 0x00 / 255, green: 0x9A / 255, blue: 0xC7 / 255, opacity: 1)

static let track = Color(.displayP3, red: 0, green: 0, blue: 0, opacity: 0.12)

static let onSurface = adaptive(
light: Color(.sRGB, red: 0x1A / 255, green: 0x1C / 255, blue: 0x1E / 255, opacity: 0.16),
dark: Color(.sRGB, red: 0xE2 / 255, green: 0xE2 / 255, blue: 0xE5 / 255, opacity: 0.16)
)

static let tileBorder = adaptive(
light: Color(.displayP3, red: 0xE0 / 255, green: 0xE0 / 255, blue: 0xE0 / 255, opacity: 1),
dark: Color(.displayP3, red: 0x34 / 255, green: 0x37 / 255, blue: 0x37 / 255, opacity: 1)
)

static let haColorBorderPrimaryQuiet = adaptive(
light: Color(.sRGB, red: 0xB9 / 255, green: 0xE6 / 255, blue: 0xFC / 255, opacity: 1),
dark: Color(.sRGB, red: 0x00 / 255, green: 0x9A / 255, blue: 0xC7 / 255, opacity: 1)
)
Comment thread
bgoncal marked this conversation as resolved.
Outdated

private static func adaptive(light: Color, dark: Color) -> Color {
#if os(watchOS)
return dark
#elseif canImport(UIKit)
return Color(UIColor { traits in
traits.userInterfaceStyle == .dark ? UIColor(dark) : UIColor(light)
})
#else
return light
#endif
}
}

#if canImport(UIKit)
public extension UIColor {
static let haPrimary = UIColor(red: 0x00 / 255, green: 0x9A / 255, blue: 0xC7 / 255, alpha: 1)
Comment thread
bgoncal marked this conversation as resolved.
Outdated
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if !os(watchOS)
import SFSafeSymbols
import SwiftUI

public enum AppleLikeBottomSheetViewState {
Expand Down Expand Up @@ -202,3 +204,4 @@ public struct AppleLikeBottomSheet<Content: View>: View {
trailing: DesignSystem.Spaces.two
), state: .constant(.initial), willDismiss: {})
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import SwiftUI

public struct CardView<Content: View>: View {
Expand Down Expand Up @@ -37,3 +38,4 @@ public struct CardView<Content: View>: View {
}
.background(Color.yellow)
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#if !os(watchOS)
import SFSafeSymbols
import SwiftUI

public struct CloseButton: View {
Expand All @@ -7,25 +9,25 @@ public struct CloseButton: View {
case large

var size: CGFloat {
if Current.isCatalyst {
switch self {
case .small:
return 24
case .medium:
return 28
case .large:
return 32
}
} else {
switch self {
case .small:
return 20
case .medium:
return 24
case .large:
return 28
}
#if targetEnvironment(macCatalyst)
switch self {
case .small:
return 24
case .medium:
return 28
case .large:
return 32
}
#else
switch self {
case .small:
return 20
case .medium:
return 24
case .large:
return 28
}
#endif
}
}

Expand Down Expand Up @@ -86,3 +88,4 @@ public struct CloseButton: View {
Spacer()
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import SwiftUI

public struct PillView: View {
Expand Down Expand Up @@ -39,3 +40,4 @@ public struct PillView: View {
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import SFSafeSymbols
import SwiftUI

Expand All @@ -22,3 +23,4 @@ public struct SheetCloseButton: View {
#Preview {
SheetCloseButton(action: {})
}
#endif
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if !os(watchOS)
import Foundation
import UIKit

Expand All @@ -16,3 +17,4 @@ public extension UIScreen {
return cornerRadius
}
}
#endif
5 changes: 5 additions & 0 deletions Sources/HADesignSystem/Sources/Tokens/Sizes.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import Foundation

public enum Sizes {
public static var maxWidthForLargerScreens: CGFloat = 600
}
26 changes: 26 additions & 0 deletions Sources/HADesignSystem/Tests/HADesignSystemTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@testable import HADesignSystem
import SwiftUI
import XCTest

final class HADesignSystemTests: XCTestCase {
func testSpacingScale() {
XCTAssertEqual(DesignSystem.Spaces.one, 8)
XCTAssertEqual(DesignSystem.Spaces.two, 16)
XCTAssertEqual(DesignSystem.Spaces.six, 48)
}

func testCornerRadiusScale() {
XCTAssertEqual(DesignSystem.CornerRadius.one, 8)
XCTAssertEqual(HACornerRadius.standard, 8)
}

func testHexColorParsing() {
XCTAssertEqual(Color(hex: "0xFF18BCF2"), Color.brandBlue)
}

func testSemanticColorsResolve() {
XCTAssertNotNil(Color.haPrimary)
XCTAssertNotNil(Color.onSurface)
XCTAssertNotNil(Color.tileBorder)
}
Comment thread
bgoncal marked this conversation as resolved.
Outdated
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading