-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Move AppColor to DesignSystem #24227
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 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
7 changes: 4 additions & 3 deletions
7
Modules/Sources/BuildSettingsKit/BuildSettingsEnvironment.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
import UIKit | ||
import SwiftUI | ||
import ColorStudio | ||
import BuildSettingsKit | ||
|
||
public enum UIAppColor { | ||
/// A tint color used in places like navigation bars. | ||
/// | ||
/// - note: The Jetpack app uses | ||
public static var tint: UIColor { | ||
switch AppBrand.current { | ||
case .wordpress: primary | ||
case .jetpack: UIColor.label | ||
} | ||
} | ||
|
||
public static var primary: UIColor { | ||
switch AppBrand.current { | ||
case .wordpress: UIColor(light: CSColor.Blue.base, dark: primary(.shade40)) | ||
case .jetpack: UIColor(light: CSColor.JetpackGreen.shade(.shade40), dark: CSColor.JetpackGreen.shade(.shade30)) | ||
} | ||
} | ||
|
||
public static func primary(_ shade: ColorStudioShade) -> UIColor { | ||
switch AppBrand.current { | ||
case .wordpress: CSColor.Blue.shade(shade) | ||
case .jetpack: CSColor.JetpackGreen.shade(shade) | ||
} | ||
} | ||
} | ||
|
||
extension UIAppColor { | ||
public static func accent(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Pink.shade(shade) | ||
} | ||
|
||
public static func error(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Red.shade(shade) | ||
} | ||
|
||
public static func warning(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Yellow.shade(shade) | ||
} | ||
|
||
public static func success(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Green.shade(shade) | ||
} | ||
|
||
public static func gray(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Gray.shade(shade) | ||
} | ||
|
||
public static func blue(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Blue.shade(shade) | ||
} | ||
|
||
public static func green(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Green.shade(shade) | ||
} | ||
|
||
public static func red(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Red.shade(shade) | ||
} | ||
|
||
public static func pink(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Pink.shade(shade) | ||
} | ||
|
||
public static func yellow(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Yellow.shade(shade) | ||
} | ||
|
||
public static func purple(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Purple.shade(shade) | ||
} | ||
|
||
public static func orange(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Orange.shade(shade) | ||
} | ||
|
||
public static func celadon(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.Celadon.shade(shade) | ||
} | ||
|
||
public static func wordPressBlue(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.WordPressBlue.shade(shade) | ||
} | ||
|
||
public static func jetpackGreen(_ shade: ColorStudioShade) -> UIColor { | ||
CSColor.JetpackGreen.shade(shade) | ||
} | ||
|
||
public static let primaryLight: UIColor = primary(.shade30) | ||
public static let primaryDark: UIColor = primary(.shade70) | ||
|
||
public static func neutral(_ shade: ColorStudioShade) -> UIColor { | ||
return switch shade { | ||
case .shade0: UIColor(light: gray(.shade0), dark: gray(.shade100)) | ||
case .shade5: UIColor(light: gray(.shade5), dark: gray(.shade90)) | ||
case .shade10: UIColor(light: gray(.shade10), dark: gray(.shade80)) | ||
case .shade20: UIColor(light: gray(.shade20), dark: gray(.shade70)) | ||
case .shade30: UIColor(light: gray(.shade30), dark: gray(.shade60)) | ||
case .shade40: UIColor(light: gray(.shade40), dark: gray(.shade50)) | ||
case .shade50: UIColor(light: gray(.shade50), dark: gray(.shade40)) | ||
case .shade60: UIColor(light: gray(.shade60), dark: gray(.shade30)) | ||
case .shade70: UIColor(light: gray(.shade70), dark: gray(.shade20)) | ||
case .shade80: UIColor(light: gray(.shade80), dark: gray(.shade10)) | ||
case .shade90: UIColor(light: gray(.shade90), dark: gray(.shade5)) | ||
case .shade100: UIColor(light: gray(.shade100), dark: gray(.shade0)) | ||
} | ||
} | ||
|
||
public static let accent = CSColor.Pink.base | ||
public static let divider = CSColor.Gray.shade(.shade10) | ||
public static let error = CSColor.Red.base | ||
public static let gray = CSColor.Gray.base | ||
public static let blue = CSColor.Blue.base | ||
|
||
public static let success = CSColor.Green.base | ||
public static let text = CSColor.Gray.shade(.shade80) | ||
public static let textSubtle = CSColor.Gray.shade(.shade50) | ||
public static let warning = CSColor.Yellow.base | ||
public static let jetpackGreen = CSColor.JetpackGreen.base | ||
public static let editorPrimary = CSColor.Blue.base | ||
public static let neutral = CSColor.Gray.base | ||
|
||
public static let statsPrimaryHighlight = UIColor(light: accent(.shade30), dark: accent(.shade60)) | ||
public static let statsSecondaryHighlight = UIColor(light: accent(.shade60), dark: accent(.shade30)) | ||
|
||
// TODO : These should be customized for WP and JP | ||
public static let appBarTint = UIColor.systemOrange | ||
public static let appBarText = UIColor.systemOrange | ||
|
||
public static let placeholderElement = UIColor(light: .systemGray5, dark: .systemGray4) | ||
public static let placeholderElementFaded: UIColor = UIColor(light: .systemGray6, dark: .systemGray5) | ||
|
||
public static let prologueBackground = UIColor(light: blue(.shade0), dark: .systemBackground) | ||
|
||
public static let switchStyle: SwitchToggleStyle = SwitchToggleStyle(tint: Color(UIAppColor.primary)) | ||
} | ||
|
||
public enum AppColor { | ||
public static var tint: Color { Color(UIAppColor.tint) } | ||
public static var primary: Color { Color(UIAppColor.primary) } | ||
} | ||
|
||
private extension UIColor { | ||
convenience init(light: UIColor, dark: UIColor) { | ||
self.init { traitCollection in | ||
if traitCollection.userInterfaceStyle == .dark { | ||
return dark | ||
} else { | ||
return light | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Modules/Sources/DesignSystem/Foundation/BuildSettings+Brand.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,12 @@ | ||
import Foundation | ||
import BuildSettingsKit | ||
|
||
extension AppBrand { | ||
static var current: AppBrand { | ||
// TODO: remove this when unit tests not longer rely on `BuildSettings.current`. | ||
if BuildSettingsEnvironment.current == .test { | ||
return .jetpack | ||
} | ||
return BuildSettings.current.brand | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
@_exported import DesignSystem | ||
@_exported import AsyncImageKit | ||
@_exported import WordPressShared |
3 changes: 3 additions & 0 deletions
3
WordPress/Classes/Extensions/Colors and Styles/UIColor+MurielColorsObjC.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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import UIKit | ||
import WordPressUI | ||
|
||
/// Objective-C *only* API for the Muriel colors | ||
@objc extension UIColor { | ||
|
||
|
3 changes: 3 additions & 0 deletions
3
WordPress/Classes/Extensions/Colors and Styles/UIColor+Notice.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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import UIKit | ||
import WordPressUI | ||
|
||
extension UIColor { | ||
|
||
static var invertedSystem5: UIColor { | ||
|
2 changes: 1 addition & 1 deletion
2
WordPress/Classes/Extensions/Colors and Styles/WPStyleGuide+Aztec.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
1 change: 1 addition & 0 deletions
1
WordPress/Classes/Extensions/Colors and Styles/WPStyleGuide+FilterTabBar.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
2 changes: 2 additions & 0 deletions
2
WordPress/Classes/Extensions/UITableViewCell+enableDisable.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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import UIKit | ||
import WordPressShared | ||
import WordPressUI | ||
|
||
extension UITableViewCell { | ||
/// Enable cell interaction | ||
|
3 changes: 3 additions & 0 deletions
3
WordPress/Classes/Models/Notifications/Actions/ApproveComment.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
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
3 changes: 3 additions & 0 deletions
3
WordPress/Classes/Models/Notifications/Actions/NotificationAction.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
3 changes: 3 additions & 0 deletions
3
WordPress/Classes/Models/Notifications/Actions/TrashComment.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
3 changes: 3 additions & 0 deletions
3
WordPress/Classes/Models/Revisions/DiffAbstractValue+Attributes.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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I had to add this as there are too many unit tests that test UI components in the app.