-
Notifications
You must be signed in to change notification settings - Fork 480
Extract design system into HADesignSystem SPM package #5007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
dc1239e
Extract design system into HADesignSystem SPM package
bgoncal 55db2b7
Address review: make color division explicit, fix package tests
bgoncal a4130ef
Merge branch 'main' into bgoncal/design-system-package
bgoncal cb12aee
Fix build: define semantic colors on ShapeStyle where Self == Color
bgoncal 59ba1fd
Add components library explorer to HADesignSystem + agent guidance
bgoncal 1ab4fa2
Merge remote-tracking branch 'origin/main' into bgoncal/design-system…
bgoncal 217d367
Merge branch 'main' into bgoncal/design-system-package
bgoncal e4cd91d
Merge remote-tracking branch 'origin/main' into bgoncal/design-system…
bgoncal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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), | ||
| ], | ||
| 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" | ||
| ), | ||
| ] | ||
| ) | ||
File renamed without changes.
File renamed without changes.
43 changes: 43 additions & 0 deletions
43
Sources/HADesignSystem/Sources/Colors/Color+Semantic.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| ) | ||
|
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) | ||
|
bgoncal marked this conversation as resolved.
Outdated
|
||
| } | ||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||
| } | ||
|
bgoncal marked this conversation as resolved.
Outdated
|
||
| } | ||
38 changes: 0 additions & 38 deletions
38
Sources/Shared/Assets/Colors.xcassets/Border/tileBorder.colorset/Contents.json
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
Sources/Shared/Assets/Colors.xcassets/ha-color-border-primary-quiet.colorset/Contents.json
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
Sources/Shared/Assets/Colors.xcassets/haPrimary.colorset/Contents.json
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
Sources/Shared/Assets/Colors.xcassets/onSurface.colorset/Contents.json
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
Sources/Shared/Assets/Colors.xcassets/trackColor.colorset/Contents.json
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.