From 8d1193a5d2d8671fac6617152c3a13cc64c9b120 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Mon, 3 Apr 2023 20:53:44 +0100 Subject: [PATCH 01/21] Add initial color and type definitions --- Package.swift | 5 +- .../Colors.xcassets/Contents.json | 6 + .../accent.colorset/Contents.json | 38 +++++ .../background.colorset/Contents.json | 38 +++++ .../container.colorset/Contents.json | 38 +++++ .../lines.colorset/Contents.json | 38 +++++ .../panel.colorset/Contents.json | 38 +++++ .../surface.colorset/Contents.json | 38 +++++ .../textPrimary.colorset/Contents.json | 38 +++++ .../textSecondary.colorset/Contents.json | 38 +++++ .../DesignResourcesKit.swift | 150 +++++++++++++++++- 11 files changed, 461 insertions(+), 4 deletions(-) create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/Contents.json create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/accent.colorset/Contents.json create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/background.colorset/Contents.json create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/container.colorset/Contents.json create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/lines.colorset/Contents.json create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/panel.colorset/Contents.json create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/surface.colorset/Contents.json create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/textPrimary.colorset/Contents.json create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/textSecondary.colorset/Contents.json diff --git a/Package.swift b/Package.swift index c0bd738..7f5abe7 100644 --- a/Package.swift +++ b/Package.swift @@ -5,8 +5,11 @@ import PackageDescription let package = Package( name: "DesignResourcesKit", + platforms: [ + .iOS("14.0"), + .macOS("10.15") + ], products: [ - // Products define the executables and libraries a package produces, and make them visible to other packages. .library( name: "DesignResourcesKit", targets: ["DesignResourcesKit"]), diff --git a/Sources/DesignResourcesKit/Colors.xcassets/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/Colors.xcassets/accent.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/accent.colorset/Contents.json new file mode 100644 index 0000000..5703f0a --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/accent.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xEF", + "green" : "0x69", + "red" : "0x39" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF6", + "green" : "0x95", + "red" : "0x72" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/Colors.xcassets/background.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/background.colorset/Contents.json new file mode 100644 index 0000000..60f40e5 --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/background.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xF5", + "green" : "0xF5", + "red" : "0xF5" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x11", + "green" : "0x11", + "red" : "0x11" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/Colors.xcassets/container.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/container.colorset/Contents.json new file mode 100644 index 0000000..e631f98 --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/container.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.060", + "blue" : "0x00", + "green" : "0x00", + "red" : "0x00" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.120", + "blue" : "0xFF", + "green" : "0xFF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/Colors.xcassets/lines.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/lines.colorset/Contents.json new file mode 100644 index 0000000..524f806 --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/lines.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.090", + "blue" : "0x00", + "green" : "0x00", + "red" : "0x00" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.090", + "blue" : "0xFF", + "green" : "0xFF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/Colors.xcassets/panel.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/panel.colorset/Contents.json new file mode 100644 index 0000000..edc7b21 --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/panel.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFA", + "green" : "0xFA", + "red" : "0xFA" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x22", + "green" : "0x22", + "red" : "0x22" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/Colors.xcassets/surface.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/surface.colorset/Contents.json new file mode 100644 index 0000000..4b4777b --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/surface.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0xFF", + "green" : "0xFF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "1.000", + "blue" : "0x22", + "green" : "0x22", + "red" : "0x22" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/Colors.xcassets/textPrimary.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/textPrimary.colorset/Contents.json new file mode 100644 index 0000000..4194158 --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/textPrimary.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.840", + "blue" : "0x00", + "green" : "0x00", + "red" : "0x00" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.600", + "blue" : "0xFF", + "green" : "0xFF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/Colors.xcassets/textSecondary.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/textSecondary.colorset/Contents.json new file mode 100644 index 0000000..3757a57 --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/textSecondary.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.600", + "blue" : "0x00", + "green" : "0x00", + "red" : "0x00" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.600", + "blue" : "0xFF", + "green" : "0xFF", + "red" : "0xFF" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index f678a11..c371a1b 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -1,6 +1,150 @@ -public struct DesignResourcesKit { - public private(set) var text = "Hello, World!" +// +// DesignResourcesKit.swift +// +// Copyright © 2023 DuckDuckGo. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// - public init() { + +import Foundation +import SwiftUI + +/// After importing Common you can access this with `Common.bundle` +/// unsure if I need this, but would mean no changes required if split up targets? +public let bundle = Bundle.module + +//TODO wait on answer if they should be defined with opacity +public enum DesignSystemColor: String { + case panel + case background + case surface + case container + case textPrimary + case textSecondary + case lines + case accent +} + +public extension Color { + init(designSystemColor: DesignSystemColor) { + self.init(designSystemColor.rawValue, bundle: bundle) + } +} + +#if canImport(UIKit) + +import UIKit + +public extension UIFont { + + public static func daxTitle1() -> UIFont { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .title1) + let newDescriptor = descriptor.addingAttributes([.traits: [ + UIFontDescriptor.TraitKey.weight: .bold]]) + return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) + } + + public static func daxTitle2() -> UIFont { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .title2) + let newDescriptor = descriptor.addingAttributes([.traits: [ + UIFontDescriptor.TraitKey.weight: .bold]]) + return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) + } + + public static func daxTitle3() -> UIFont { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .title3) + let newDescriptor = descriptor.addingAttributes([.traits: [ + UIFontDescriptor.TraitKey.weight: .bold]]) + return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) + } + + public static func daxHeadline() -> UIFont { + return UIFont.preferredFont(forTextStyle: .headline) + } + + public static func daxBodyRegular() -> UIfont { + return UIFont.preferredFont(forTextStyle: .callout) + } + + public static func daxBodyBold() -> UIFont { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .callout) + let newDescriptor = descriptor.addingAttributes([.traits: [ + UIFontDescriptor.TraitKey.weight: .bold]]) + return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) + } + + public static func daxSubheadRegular() -> UIfont { + return UIFont.preferredFont(forTextStyle: .subhead) + } + + public static func daxSubheadSemibold() -> UIFont { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .subhead) + let newDescriptor = descriptor.addingAttributes([.traits: [ + UIFontDescriptor.TraitKey.weight: .semibold]]) + return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) + } + + public static func daxButton() -> UIFont { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .subhead) + let newDescriptor = descriptor.addingAttributes([.traits: [ + UIFontDescriptor.TraitKey.weight: .bold]]) + return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) + } + + public static func daxFootnoteRegular() -> UIfont { + return UIFont.preferredFont(forTextStyle: .footnote) + } + + public static func daxFootnoteSemibold() -> UIFont { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .footnote) + let newDescriptor = descriptor.addingAttributes([.traits: [ + UIFontDescriptor.TraitKey.weight: .semibold]]) + return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) + } + + public static func daxCaption() -> UIfont { + return UIFont.preferredFont(forTextStyle: .caption2) + } + + //TODO delete if unused + @available(*, deprecated) + public static func daxFontOutsideOfTheDesignSystemToFixLegacyLayoutBreakage(ofSize size: CGFloat, weight: UIFont.Weight) -> UIFont { + UIFont.systemFont(ofSize: size, weight: weight) } } + +/* + + title1 (bold) + title2 (bold) + title3 (bold) + headline + body (callout) reg/bold. Callout is same as reg + subhead semibold + subhead regular, subhead same as reb + button size and leading as the system subhead (different weight), so could be based on that. + footnote regular/semibold + caption Caption is also slightly different to both systems styles caption 1 and caption 2, in both size and leading. This is the only one that might need custom leading, although if we base it on caption 2 it may be correct. + + The following have different weights + title 1, title 2, title 3 + callout has two styles, one is the same, one is bold + same for subhead + Body (callout) is same size and leading as the system callout, (slightly different to system body) + Button is not based on a system style, but is the size and leading as the system subhead (different weight), so could be based on that. + Caption is also slightly different to both systems styles caption 1 and caption 2, in both size and leading. This is the only one that might need custom leading, although if we base it on caption 2 it may be correct. + + */ + +#endif From c42862d8689afd167eb9bef5294d077c34130674 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Mon, 3 Apr 2023 21:09:08 +0100 Subject: [PATCH 02/21] Add initial font view modifiers --- .../DesignResourcesKit.swift | 105 ++++++++++++++---- 1 file changed, 83 insertions(+), 22 deletions(-) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index c371a1b..4869b30 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -124,27 +124,88 @@ public extension UIFont { } } -/* - - title1 (bold) - title2 (bold) - title3 (bold) - headline - body (callout) reg/bold. Callout is same as reg - subhead semibold - subhead regular, subhead same as reb - button size and leading as the system subhead (different weight), so could be based on that. - footnote regular/semibold - caption Caption is also slightly different to both systems styles caption 1 and caption 2, in both size and leading. This is the only one that might need custom leading, although if we base it on caption 2 it may be correct. - - The following have different weights - title 1, title 2, title 3 - callout has two styles, one is the same, one is bold - same for subhead - Body (callout) is same size and leading as the system callout, (slightly different to system body) - Button is not based on a system style, but is the size and leading as the system subhead (different weight), so could be based on that. - Caption is also slightly different to both systems styles caption 1 and caption 2, in both size and leading. This is the only one that might need custom leading, although if we base it on caption 2 it may be correct. - - */ +public struct DaxTitle1: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxTitle1())) + } +} + +public struct DaxTitle2: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxTitle2())) + } +} + +public struct DaxTitle3: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxTitle3())) + } +} + +public struct DaxHeadline: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxHeadline())) + } +} + +public struct DaxBodyRegular: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxBodyRegular())) + } +} + +public struct DaxBodyBold: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxBodyBold())) + } +} + +public struct DaxSubheadRegular: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxSubheadRegular())) + } +} + +public struct DaxSubheadSemibold: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxSubheadSemibold())) + } +} + +public struct DaxButton: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxButton())) + } +} + +public struct DaxFootnoteRegular: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxFootnoteRegular())) + } +} + +public struct daxFootnoteSemibold: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxFootnoteSemibold())) + } +} + +public struct DaxCaption: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(uiFont: UIFont.daxCaption())) + } +} #endif From da4dec5304d37eca05c3d3a5466ecf1627c9b2c7 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 4 Apr 2023 16:06:59 +0100 Subject: [PATCH 03/21] Add readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46d0212..27bfd77 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # DesignResourcesKit -A description of this package. +Implementation of design system elements for iOS and macOS apps. Currently only includes colors and typography. From b3f157797fc588e96502c85bb593d5cced799401 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 4 Apr 2023 16:08:05 +0100 Subject: [PATCH 04/21] Clean up comments --- Sources/DesignResourcesKit/DesignResourcesKit.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index 4869b30..a447e0f 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -20,11 +20,9 @@ import Foundation import SwiftUI -/// After importing Common you can access this with `Common.bundle` -/// unsure if I need this, but would mean no changes required if split up targets? +/// Unsure if I need this, but would mean no changes required if split up targets? public let bundle = Bundle.module -//TODO wait on answer if they should be defined with opacity public enum DesignSystemColor: String { case panel case background From 1e5cd451904e0aba8bce8a113b71a1ca4be02185 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 4 Apr 2023 19:34:46 +0100 Subject: [PATCH 05/21] Add license information --- LICENSE | 201 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 11 ++- 2 files changed, 211 insertions(+), 1 deletion(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README.md b/README.md index 27bfd77..37eb662 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,12 @@ # DesignResourcesKit -Implementation of design system elements for iOS and macOS apps. Currently only includes colors and typography. +## What is it? +`DesignResourcesKit` is a narrowly scoped Swift package continating the implementation of design system elements for iOS and macOS apps. This currently only includes colors and typography. + +## Making changes +Any changes to the actual content of this package (e.g. values or names of colors, font sizes or leading etc.) should only be made if the changes are applied across the design system. +If a design contains typography or colors not in this package, they should either be changed to use something in this package, or those new colors/type styles should be added fully to the design system. + +## License +DuckDuckGo is distributed under the Apache 2.0 [license](https://github.com/duckduckgo/ios/blob/master/LICENSE.md). + From 3a4fe4dbb630b4e048550eb8e4879e5b9bafb8dd Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 4 Apr 2023 19:36:42 +0100 Subject: [PATCH 06/21] Update licence link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37eb662..5e93f5e 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,5 @@ Any changes to the actual content of this package (e.g. values or names of color If a design contains typography or colors not in this package, they should either be changed to use something in this package, or those new colors/type styles should be added fully to the design system. ## License -DuckDuckGo is distributed under the Apache 2.0 [license](https://github.com/duckduckgo/ios/blob/master/LICENSE.md). +DuckDuckGo is distributed under the Apache 2.0 [license](https://github.com/duckduckgo/DesignResourcesKit/blob/main/LICENSE). From 197c208a1482efb20ed563b040ee2ecd81800bb4 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 4 Apr 2023 19:43:20 +0100 Subject: [PATCH 07/21] Fix errors --- .../DesignResourcesKit.swift | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index a447e0f..0fecefc 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -46,78 +46,78 @@ import UIKit public extension UIFont { - public static func daxTitle1() -> UIFont { + static func daxTitle1() -> UIFont { let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .title1) let newDescriptor = descriptor.addingAttributes([.traits: [ - UIFontDescriptor.TraitKey.weight: .bold]]) + UIFontDescriptor.TraitKey.weight: UIFont.Weight.bold]]) return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) } - public static func daxTitle2() -> UIFont { + static func daxTitle2() -> UIFont { let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .title2) let newDescriptor = descriptor.addingAttributes([.traits: [ - UIFontDescriptor.TraitKey.weight: .bold]]) + UIFontDescriptor.TraitKey.weight: UIFont.Weight.bold]]) return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) } - public static func daxTitle3() -> UIFont { + static func daxTitle3() -> UIFont { let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .title3) let newDescriptor = descriptor.addingAttributes([.traits: [ - UIFontDescriptor.TraitKey.weight: .bold]]) + UIFontDescriptor.TraitKey.weight: UIFont.Weight.bold]]) return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) } - public static func daxHeadline() -> UIFont { + static func daxHeadline() -> UIFont { return UIFont.preferredFont(forTextStyle: .headline) } - public static func daxBodyRegular() -> UIfont { + static func daxBodyRegular() -> UIfont { return UIFont.preferredFont(forTextStyle: .callout) } - public static func daxBodyBold() -> UIFont { + static func daxBodyBold() -> UIFont { let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .callout) let newDescriptor = descriptor.addingAttributes([.traits: [ - UIFontDescriptor.TraitKey.weight: .bold]]) + UIFontDescriptor.TraitKey.weight: UIFont.Weight.bold]]) return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) } - public static func daxSubheadRegular() -> UIfont { - return UIFont.preferredFont(forTextStyle: .subhead) + static func daxSubheadRegular() -> UIfont { + return UIFont.preferredFont(forTextStyle: .subheadline) } - public static func daxSubheadSemibold() -> UIFont { - let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .subhead) + static func daxSubheadSemibold() -> UIFont { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .subheadline) let newDescriptor = descriptor.addingAttributes([.traits: [ - UIFontDescriptor.TraitKey.weight: .semibold]]) + UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold]]) return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) } - public static func daxButton() -> UIFont { - let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .subhead) + static func daxButton() -> UIFont { + let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .subheadline) let newDescriptor = descriptor.addingAttributes([.traits: [ - UIFontDescriptor.TraitKey.weight: .bold]]) + UIFontDescriptor.TraitKey.weight: UIFont.Weight.bold]]) return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) } - public static func daxFootnoteRegular() -> UIfont { + static func daxFootnoteRegular() -> UIfont { return UIFont.preferredFont(forTextStyle: .footnote) } - public static func daxFootnoteSemibold() -> UIFont { + static func daxFootnoteSemibold() -> UIFont { let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: .footnote) let newDescriptor = descriptor.addingAttributes([.traits: [ - UIFontDescriptor.TraitKey.weight: .semibold]]) + UIFontDescriptor.TraitKey.weight: UIFont.Weight.semibold]]) return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) } - public static func daxCaption() -> UIfont { + static func daxCaption() -> UIFont { return UIFont.preferredFont(forTextStyle: .caption2) } //TODO delete if unused @available(*, deprecated) - public static func daxFontOutsideOfTheDesignSystemToFixLegacyLayoutBreakage(ofSize size: CGFloat, weight: UIFont.Weight) -> UIFont { + static func daxFontOutsideOfTheDesignSystemToFixLegacyLayoutBreakage(ofSize size: CGFloat, weight: UIFont.Weight) -> UIFont { UIFont.systemFont(ofSize: size, weight: weight) } } @@ -125,84 +125,84 @@ public extension UIFont { public struct DaxTitle1: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxTitle1())) + .font(Font(UIFont.daxTitle1())) } } public struct DaxTitle2: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxTitle2())) + .font(Font(UIFont.daxTitle2())) } } public struct DaxTitle3: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxTitle3())) + .font(Font(UIFont.daxTitle3())) } } public struct DaxHeadline: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxHeadline())) + .font(Font(UIFont.daxHeadline())) } } public struct DaxBodyRegular: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxBodyRegular())) + .font(Font(UIFont.daxBodyRegular())) } } public struct DaxBodyBold: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxBodyBold())) + .font(Font(UIFont.daxBodyBold())) } } public struct DaxSubheadRegular: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxSubheadRegular())) + .font(Font(UIFont.daxSubheadRegular())) } } public struct DaxSubheadSemibold: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxSubheadSemibold())) + .font(Font(UIFont.daxSubheadSemibold())) } } public struct DaxButton: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxButton())) + .font(Font(UIFont.daxButton())) } } public struct DaxFootnoteRegular: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxFootnoteRegular())) + .font(Font(UIFont.daxFootnoteRegular())) } } public struct daxFootnoteSemibold: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxFootnoteSemibold())) + .font(Font(UIFont.daxFootnoteSemibold())) } } public struct DaxCaption: ViewModifier { public func body(content: Content) -> some View { content - .font(Font(uiFont: UIFont.daxCaption())) + .font(Font(UIFont.daxCaption())) } } From d4d7d11411fcee91548e98aacae8151138f83c56 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 4 Apr 2023 19:45:27 +0100 Subject: [PATCH 08/21] Fix references to UIFont --- Sources/DesignResourcesKit/DesignResourcesKit.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index 0fecefc..6aac693 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -71,7 +71,7 @@ public extension UIFont { return UIFont.preferredFont(forTextStyle: .headline) } - static func daxBodyRegular() -> UIfont { + static func daxBodyRegular() -> UIFont { return UIFont.preferredFont(forTextStyle: .callout) } @@ -82,7 +82,7 @@ public extension UIFont { return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) } - static func daxSubheadRegular() -> UIfont { + static func daxSubheadRegular() -> UIFont { return UIFont.preferredFont(forTextStyle: .subheadline) } @@ -100,7 +100,7 @@ public extension UIFont { return UIFont(descriptor: newDescriptor, size: descriptor.pointSize) } - static func daxFootnoteRegular() -> UIfont { + static func daxFootnoteRegular() -> UIFont { return UIFont.preferredFont(forTextStyle: .footnote) } From 64d9db99012e78855b52346624cc4adce54ca7b4 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 4 Apr 2023 20:25:47 +0100 Subject: [PATCH 09/21] Add exception colors folder --- README.md | 4 +++- .../Contents.json | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/SingleUseExceptionsNotPartOfTheDesignSystem/Contents.json diff --git a/README.md b/README.md index 5e93f5e..cfed9fb 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,14 @@ # DesignResourcesKit ## What is it? -`DesignResourcesKit` is a narrowly scoped Swift package continating the implementation of design system elements for iOS and macOS apps. This currently only includes colors and typography. +`DesignResourcesKit` is a narrowly scoped Swift package containing the implementation of design system elements for iOS and macOS apps. This currently only includes colors and typography. ## Making changes Any changes to the actual content of this package (e.g. values or names of colors, font sizes or leading etc.) should only be made if the changes are applied across the design system. If a design contains typography or colors not in this package, they should either be changed to use something in this package, or those new colors/type styles should be added fully to the design system. +Occasionally it may be necessary to add a color that is used in only one place and isn't part of the design system. For these, there is a deliberately obtusely named folder in the asset catalog called "SingleUseExceptionsNotPartOfTheDesignSystem". You should think carefully before adding a color here, and question with the designer if it should be part of the design system. + ## License DuckDuckGo is distributed under the Apache 2.0 [license](https://github.com/duckduckgo/DesignResourcesKit/blob/main/LICENSE). diff --git a/Sources/DesignResourcesKit/Colors.xcassets/SingleUseExceptionsNotPartOfTheDesignSystem/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/SingleUseExceptionsNotPartOfTheDesignSystem/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/SingleUseExceptionsNotPartOfTheDesignSystem/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} From ed197aa767b288531a0bfde047f148f8951b363f Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Wed, 5 Apr 2023 22:40:29 +0100 Subject: [PATCH 10/21] Add icons color --- .../icons.colorset/Contents.json | 38 +++++++++++++++++++ .../DesignResourcesKit.swift | 1 + 2 files changed, 39 insertions(+) create mode 100644 Sources/DesignResourcesKit/Colors.xcassets/icons.colorset/Contents.json diff --git a/Sources/DesignResourcesKit/Colors.xcassets/icons.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/icons.colorset/Contents.json new file mode 100644 index 0000000..f9e96a6 --- /dev/null +++ b/Sources/DesignResourcesKit/Colors.xcassets/icons.colorset/Contents.json @@ -0,0 +1,38 @@ +{ + "colors" : [ + { + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.840", + "blue" : "0.000", + "green" : "0.000", + "red" : "0.000" + } + }, + "idiom" : "universal" + }, + { + "appearances" : [ + { + "appearance" : "luminosity", + "value" : "dark" + } + ], + "color" : { + "color-space" : "srgb", + "components" : { + "alpha" : "0.600", + "blue" : "1.000", + "green" : "1.000", + "red" : "1.000" + } + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index 6aac693..1578215 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -32,6 +32,7 @@ public enum DesignSystemColor: String { case textSecondary case lines case accent + case icons } public extension Color { From 4a9f83b7ccf3d69d58eea80dc3b7255903e19f66 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Wed, 5 Apr 2023 22:57:12 +0100 Subject: [PATCH 11/21] Add UIColor extension --- Sources/DesignResourcesKit/DesignResourcesKit.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index 1578215..f9a6d9f 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -45,6 +45,12 @@ public extension Color { import UIKit +public extension UIColor { + init(designSystemColor: DesignSystemColor) { + self.init(named: designSystemColor.rawValue, in: bundle) + } +} + public extension UIFont { static func daxTitle1() -> UIFont { From 5e0375393902a1068493d26ecf9aef068db7cc77 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Wed, 5 Apr 2023 22:59:09 +0100 Subject: [PATCH 12/21] Make UIColor init convience --- Sources/DesignResourcesKit/DesignResourcesKit.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index f9a6d9f..5344253 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -46,8 +46,8 @@ public extension Color { import UIKit public extension UIColor { - init(designSystemColor: DesignSystemColor) { - self.init(named: designSystemColor.rawValue, in: bundle) + convenience init(designSystemColor: DesignSystemColor) { + self.init(named: designSystemColor.rawValue, in: bundle, compatibleWith: nil) } } From 1818afa1f17b8ca1c7126787a27ebf8be8aad5aa Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Wed, 5 Apr 2023 23:01:32 +0100 Subject: [PATCH 13/21] Change UIColor init to use Color init --- Sources/DesignResourcesKit/DesignResourcesKit.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index 5344253..83e9298 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -47,7 +47,7 @@ import UIKit public extension UIColor { convenience init(designSystemColor: DesignSystemColor) { - self.init(named: designSystemColor.rawValue, in: bundle, compatibleWith: nil) + self.init(Color(designSystemColor: designSystemColor)) } } From 4f66e9d8d702fd704f86d51750cc578a3d63273a Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Wed, 5 Apr 2023 23:33:10 +0100 Subject: [PATCH 14/21] Change UIColor to not use Color, since it breaks resolvedColor(with: .init(userInterfaceStyle: .dark) --- Sources/DesignResourcesKit/DesignResourcesKit.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index 83e9298..5344253 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -47,7 +47,7 @@ import UIKit public extension UIColor { convenience init(designSystemColor: DesignSystemColor) { - self.init(Color(designSystemColor: designSystemColor)) + self.init(named: designSystemColor.rawValue, in: bundle, compatibleWith: nil) } } From a6ba53699ec53b36d5649ec7772b16b2c7afdf8d Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Wed, 5 Apr 2023 23:35:07 +0100 Subject: [PATCH 15/21] Force the initialiser to succeed or crash --- Sources/DesignResourcesKit/DesignResourcesKit.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index 5344253..96e02d9 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -47,7 +47,7 @@ import UIKit public extension UIColor { convenience init(designSystemColor: DesignSystemColor) { - self.init(named: designSystemColor.rawValue, in: bundle, compatibleWith: nil) + self.init(named: designSystemColor.rawValue, in: bundle, compatibleWith: nil)! } } From d48c2942b7f53655452005a24133c29a38b9eff8 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 11 Apr 2023 18:59:23 +0100 Subject: [PATCH 16/21] Fix DaxFootnoteSemibold typo --- Sources/DesignResourcesKit/DesignResourcesKit.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index 96e02d9..27e8179 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -199,7 +199,7 @@ public struct DaxFootnoteRegular: ViewModifier { } } -public struct daxFootnoteSemibold: ViewModifier { +public struct DaxFootnoteSemibold: ViewModifier { public func body(content: Content) -> some View { content .font(Font(UIFont.daxFootnoteSemibold())) From 0dfffe3776ce984f4534f6380ad155c021c27c8e Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 11 Apr 2023 18:59:36 +0100 Subject: [PATCH 17/21] Add view modifier helpers for text styles --- .../DesignResourcesKit.swift | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/DesignResourcesKit.swift index 27e8179..5c35b4a 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/DesignResourcesKit.swift @@ -213,4 +213,54 @@ public struct DaxCaption: ViewModifier { } } +public extension View { + func daxTitle1() -> some View { + modifier(DaxTitle1()) + } + + func daxTitle2() -> some View { + modifier(DaxTitle2()) + } + + func daxTitle3() -> some View { + modifier(DaxTitle3()) + } + + func daxHeadline() -> some View { + modifier(DaxHeadline()) + } + + func daxBodyRegular() -> some View { + modifier(DaxBodyRegular()) + } + + func daxBodyBold() -> some View { + modifier(DaxBodyBold()) + } + + func daxSubheadRegular() -> some View { + modifier(DaxSubheadRegular()) + } + + func daxSubheadSemibold() -> some View { + modifier(DaxSubheadSemibold()) + } + + func daxButton() -> some View { + modifier(DaxButton()) + } + + func daxFootnoteRegular() -> some View { + modifier(DaxFootnoteRegular()) + } + + func daxFootnoteSemibold() -> some View { + modifier(DaxFootnoteSemibold()) + } + + func daxCaption() -> some View { + modifier(DaxCaption()) + } +} + #endif From 50553738d8a22f7c91325fb8db087dff2d35112f Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 11 Apr 2023 19:07:15 +0100 Subject: [PATCH 18/21] Split code into separate files --- Sources/DesignResourcesKit/Color.swift | 52 ++++++ .../{DesignResourcesKit.swift => Font.swift} | 166 +----------------- .../FontViewModifiers.swift | 158 +++++++++++++++++ 3 files changed, 211 insertions(+), 165 deletions(-) create mode 100644 Sources/DesignResourcesKit/Color.swift rename Sources/DesignResourcesKit/{DesignResourcesKit.swift => Font.swift} (51%) create mode 100644 Sources/DesignResourcesKit/FontViewModifiers.swift diff --git a/Sources/DesignResourcesKit/Color.swift b/Sources/DesignResourcesKit/Color.swift new file mode 100644 index 0000000..d82c36f --- /dev/null +++ b/Sources/DesignResourcesKit/Color.swift @@ -0,0 +1,52 @@ +// +// Color.swift +// +// Copyright © 2023 DuckDuckGo. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation +import SwiftUI + +public let bundle = Bundle.module + +public enum DesignSystemColor: String { + case panel + case background + case surface + case container + case textPrimary + case textSecondary + case lines + case accent + case icons +} + +public extension Color { + init(designSystemColor: DesignSystemColor) { + self.init(designSystemColor.rawValue, bundle: bundle) + } +} + +#if canImport(UIKit) + +import UIKit + +public extension UIColor { + convenience init(designSystemColor: DesignSystemColor) { + self.init(named: designSystemColor.rawValue, in: bundle, compatibleWith: nil)! + } +} + +#endif diff --git a/Sources/DesignResourcesKit/DesignResourcesKit.swift b/Sources/DesignResourcesKit/Font.swift similarity index 51% rename from Sources/DesignResourcesKit/DesignResourcesKit.swift rename to Sources/DesignResourcesKit/Font.swift index 5c35b4a..a7d0201 100644 --- a/Sources/DesignResourcesKit/DesignResourcesKit.swift +++ b/Sources/DesignResourcesKit/Font.swift @@ -1,5 +1,5 @@ // -// DesignResourcesKit.swift +// Font.swift // // Copyright © 2023 DuckDuckGo. All rights reserved. // @@ -16,41 +16,11 @@ // limitations under the License. // - import Foundation import SwiftUI -/// Unsure if I need this, but would mean no changes required if split up targets? -public let bundle = Bundle.module - -public enum DesignSystemColor: String { - case panel - case background - case surface - case container - case textPrimary - case textSecondary - case lines - case accent - case icons -} - -public extension Color { - init(designSystemColor: DesignSystemColor) { - self.init(designSystemColor.rawValue, bundle: bundle) - } -} - #if canImport(UIKit) -import UIKit - -public extension UIColor { - convenience init(designSystemColor: DesignSystemColor) { - self.init(named: designSystemColor.rawValue, in: bundle, compatibleWith: nil)! - } -} - public extension UIFont { static func daxTitle1() -> UIFont { @@ -129,138 +99,4 @@ public extension UIFont { } } -public struct DaxTitle1: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxTitle1())) - } -} - -public struct DaxTitle2: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxTitle2())) - } -} - -public struct DaxTitle3: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxTitle3())) - } -} - -public struct DaxHeadline: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxHeadline())) - } -} - -public struct DaxBodyRegular: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxBodyRegular())) - } -} - -public struct DaxBodyBold: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxBodyBold())) - } -} - -public struct DaxSubheadRegular: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxSubheadRegular())) - } -} - -public struct DaxSubheadSemibold: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxSubheadSemibold())) - } -} - -public struct DaxButton: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxButton())) - } -} - -public struct DaxFootnoteRegular: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxFootnoteRegular())) - } -} - -public struct DaxFootnoteSemibold: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxFootnoteSemibold())) - } -} - -public struct DaxCaption: ViewModifier { - public func body(content: Content) -> some View { - content - .font(Font(UIFont.daxCaption())) - } -} - -public extension View { - func daxTitle1() -> some View { - modifier(DaxTitle1()) - } - - func daxTitle2() -> some View { - modifier(DaxTitle2()) - } - - func daxTitle3() -> some View { - modifier(DaxTitle3()) - } - - func daxHeadline() -> some View { - modifier(DaxHeadline()) - } - - func daxBodyRegular() -> some View { - modifier(DaxBodyRegular()) - } - - func daxBodyBold() -> some View { - modifier(DaxBodyBold()) - } - - func daxSubheadRegular() -> some View { - modifier(DaxSubheadRegular()) - } - - func daxSubheadSemibold() -> some View { - modifier(DaxSubheadSemibold()) - } - - func daxButton() -> some View { - modifier(DaxButton()) - } - - func daxFootnoteRegular() -> some View { - modifier(DaxFootnoteRegular()) - } - - func daxFootnoteSemibold() -> some View { - modifier(DaxFootnoteSemibold()) - } - - func daxCaption() -> some View { - modifier(DaxCaption()) - } -} - #endif diff --git a/Sources/DesignResourcesKit/FontViewModifiers.swift b/Sources/DesignResourcesKit/FontViewModifiers.swift new file mode 100644 index 0000000..0a93c18 --- /dev/null +++ b/Sources/DesignResourcesKit/FontViewModifiers.swift @@ -0,0 +1,158 @@ +// +// FontViewModifiers.swift +// +// Copyright © 2023 DuckDuckGo. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +import Foundation +import SwiftUI + +#if canImport(UIKit) + +public struct DaxTitle1: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxTitle1())) + } +} + +public struct DaxTitle2: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxTitle2())) + } +} + +public struct DaxTitle3: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxTitle3())) + } +} + +public struct DaxHeadline: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxHeadline())) + } +} + +public struct DaxBodyRegular: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxBodyRegular())) + } +} + +public struct DaxBodyBold: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxBodyBold())) + } +} + +public struct DaxSubheadRegular: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxSubheadRegular())) + } +} + +public struct DaxSubheadSemibold: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxSubheadSemibold())) + } +} + +public struct DaxButton: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxButton())) + } +} + +public struct DaxFootnoteRegular: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxFootnoteRegular())) + } +} + +public struct DaxFootnoteSemibold: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxFootnoteSemibold())) + } +} + +public struct DaxCaption: ViewModifier { + public func body(content: Content) -> some View { + content + .font(Font(UIFont.daxCaption())) + } +} + +public extension View { + func daxTitle1() -> some View { + modifier(DaxTitle1()) + } + + func daxTitle2() -> some View { + modifier(DaxTitle2()) + } + + func daxTitle3() -> some View { + modifier(DaxTitle3()) + } + + func daxHeadline() -> some View { + modifier(DaxHeadline()) + } + + func daxBodyRegular() -> some View { + modifier(DaxBodyRegular()) + } + + func daxBodyBold() -> some View { + modifier(DaxBodyBold()) + } + + func daxSubheadRegular() -> some View { + modifier(DaxSubheadRegular()) + } + + func daxSubheadSemibold() -> some View { + modifier(DaxSubheadSemibold()) + } + + func daxButton() -> some View { + modifier(DaxButton()) + } + + func daxFootnoteRegular() -> some View { + modifier(DaxFootnoteRegular()) + } + + func daxFootnoteSemibold() -> some View { + modifier(DaxFootnoteSemibold()) + } + + func daxCaption() -> some View { + modifier(DaxCaption()) + } +} + +#endif From 971979d3dcd95567b9812b800eb22ab1611ce3a5 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 11 Apr 2023 19:07:41 +0100 Subject: [PATCH 19/21] Remove currently unused daxFontOutsideOfTheDesignSystemToFixLegacyLayoutBreakage --- Sources/DesignResourcesKit/Font.swift | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Sources/DesignResourcesKit/Font.swift b/Sources/DesignResourcesKit/Font.swift index a7d0201..07908f6 100644 --- a/Sources/DesignResourcesKit/Font.swift +++ b/Sources/DesignResourcesKit/Font.swift @@ -91,12 +91,6 @@ public extension UIFont { static func daxCaption() -> UIFont { return UIFont.preferredFont(forTextStyle: .caption2) } - - //TODO delete if unused - @available(*, deprecated) - static func daxFontOutsideOfTheDesignSystemToFixLegacyLayoutBreakage(ofSize size: CGFloat, weight: UIFont.Weight) -> UIFont { - UIFont.systemFont(ofSize: size, weight: weight) - } } #endif From cff5db2683c283330bbffca68de2d2d8369971c1 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 11 Apr 2023 19:27:32 +0100 Subject: [PATCH 20/21] Add pull request template --- .github/PULL_REQUEST_TEMPLATE.md | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE.md diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..0d8b02e --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,36 @@ + + +**Description**: + + + +**Why are you changing this repo?** + + + +**Checklist** + +* [ ] Are you changing/adding/removing colors or type styles? +* [ ] If yes to the above, are the changes you're making part of the design system? +* [ ] If no to the previous question, have you challenged it and attempted to either change the designs or have the new thing incorporated into the design system? +⚠️ If no to the above question you probably shouldn't open this PR and should consult with the relevant DRIs. + + +--- +###### Internal references: +[Software Engineering Expectations](https://app.asana.com/0/59792373528535/199064865822552) +[Technical Design Template](https://app.asana.com/0/59792373528535/184709971311943) +**When ready for review, remember to post the PR in MM** From 70e71a28dbf76b9e0a6943afeed520518e190645 Mon Sep 17 00:00:00 2001 From: Elle Sullivan Date: Tue, 18 Apr 2023 19:05:17 +0100 Subject: [PATCH 21/21] Update icons opacity in dark mode --- .../Colors.xcassets/icons.colorset/Contents.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/DesignResourcesKit/Colors.xcassets/icons.colorset/Contents.json b/Sources/DesignResourcesKit/Colors.xcassets/icons.colorset/Contents.json index f9e96a6..5b6223b 100644 --- a/Sources/DesignResourcesKit/Colors.xcassets/icons.colorset/Contents.json +++ b/Sources/DesignResourcesKit/Colors.xcassets/icons.colorset/Contents.json @@ -22,7 +22,7 @@ "color" : { "color-space" : "srgb", "components" : { - "alpha" : "0.600", + "alpha" : "0.840", "blue" : "1.000", "green" : "1.000", "red" : "1.000"