-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Theme dark mode support + loading colors from xcassets file (#8)
1. Added dark mode support. 2. Loading colors from xcassets file. 3. A way to add more Themes either from App's Bundle or from Package's Bundle (module)."
- Loading branch information
1 parent
ebf5427
commit cde16fc
Showing
27 changed files
with
737 additions
and
123 deletions.
There are no files selected for viewing
This file contains 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 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 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.
This file contains 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,15 @@ | ||
import Foundation | ||
import AppKit | ||
|
||
extension Theme { | ||
|
||
public static let `default` = Theme( | ||
colors: Colors(bundle: Bundle.module, name: "neon.plugin.default"), | ||
tokensCustomFontDict: [ | ||
"default": NSFont.monospacedSystemFont(ofSize: 0, weight: .regular), | ||
"keyword": NSFont.monospacedSystemFont(ofSize: 0, weight: .bold), | ||
"constructor": NSFont.monospacedSystemFont(ofSize: 0, weight: .bold) | ||
|
||
] | ||
) | ||
} |
This file contains 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,49 @@ | ||
import Cocoa | ||
|
||
public struct Theme { | ||
|
||
// MARK: - Props | ||
let colors: Colors | ||
let tokensCustomFontDict: [TokenName: NSFont] | ||
|
||
// MARK: - Lifecycle | ||
public init(colors: Colors, tokensCustomFontDict: [TokenName: NSFont] = [:]) { | ||
self.colors = colors | ||
self.tokensCustomFontDict = tokensCustomFontDict | ||
} | ||
|
||
public var defaultFont: NSFont? { | ||
return tokensCustomFontDict["default"] | ||
} | ||
|
||
public var defaultColor: NSColor? { | ||
return color(forToken: "default") | ||
} | ||
|
||
public func color(forToken tokenName: TokenName) -> NSColor? { | ||
return colors.color(forToken: tokenName) | ||
} | ||
|
||
public func font(forToken tokenName: TokenName) -> NSFont? { | ||
return tokensCustomFontDict[tokenName] | ||
} | ||
} | ||
|
||
extension Theme { | ||
|
||
public struct Colors { | ||
|
||
let bundle: Bundle | ||
let name: String | ||
|
||
public init(bundle: Bundle, name: String) { | ||
self.bundle = bundle | ||
self.name = name | ||
} | ||
|
||
func color(forToken tokenName: TokenName) -> NSColor? { | ||
let colorName = "\(name)/\(tokenName)" | ||
return NSColor(named: colorName, bundle: bundle) | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Sources/NeonPlugin/Themes.xcassets/neon.plugin.default/Contents.json
This file contains 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,9 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
}, | ||
"properties" : { | ||
"provides-namespace" : true | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Sources/NeonPlugin/Themes.xcassets/neon.plugin.default/boolean.colorset/Contents.json
This file contains 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,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "147", | ||
"green" : "35", | ||
"red" : "155" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "108", | ||
"green" : "220", | ||
"red" : "100" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Sources/NeonPlugin/Themes.xcassets/neon.plugin.default/comment.colorset/Contents.json
This file contains 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,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "0.500", | ||
"blue" : "0x00", | ||
"green" : "0x00", | ||
"red" : "0x00" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "0.550", | ||
"blue" : "255", | ||
"green" : "255", | ||
"red" : "255" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Sources/NeonPlugin/Themes.xcassets/neon.plugin.default/constructor.colorset/Contents.json
This file contains 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,38 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "147", | ||
"green" : "35", | ||
"red" : "155" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
}, | ||
{ | ||
"appearances" : [ | ||
{ | ||
"appearance" : "luminosity", | ||
"value" : "dark" | ||
} | ||
], | ||
"color" : { | ||
"color-space" : "srgb", | ||
"components" : { | ||
"alpha" : "1.000", | ||
"blue" : "108", | ||
"green" : "220", | ||
"red" : "100" | ||
} | ||
}, | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Oops, something went wrong.