Skip to content

Commit a007ad1

Browse files
author
bllizard22
committed
Updated color type in stencil
1 parent 9bfcf22 commit a007ad1

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

PaletteGenerator

32 Bytes
Binary file not shown.

Project/Sources/PaletteGenerator/Generator.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ final class Generator {
6161
case "SOLID":
6262
output.append(getRenderedSolid(from: styles))
6363
case "GRADIENT_LINEAR", "GRADIENT_ANGULAR":
64-
output.append(getRenderedGradient(from: styles))
64+
output.append(getRenderedGradient(from: styles, type: .uiColor))
6565
default:
6666
prettyPrint("Error with style - \(style)")
6767
}
@@ -197,7 +197,7 @@ final class Generator {
197197
return output
198198
}
199199

200-
private func getRenderedGradient(from dict: [String: Any]) -> String {
200+
private func getRenderedGradient(from dict: [String: Any], type: ColorType) -> String {
201201
var newdict = dict
202202
guard let colors = dict["colors"] as? [[String: Any]] else {
203203
prettyPrint("Error with colors in \(dict)")
@@ -210,9 +210,11 @@ final class Generator {
210210
if index != colors.endIndex-1 {
211211
value["separator"] = ","
212212
}
213-
colorsRaw.append(getColor(from: value, withType: .uiColor))
213+
colorsRaw.append(getColor(from: value, withType: type))
214214
}
215215
colorsRaw.indices.last.map { colorsRaw[$0] = String(colorsRaw[$0].dropLast(1)) }
216+
217+
newdict["type"] = type.rawValue
216218
newdict["colors"] = colorsRaw
217219
newdict["positions"] = (dict["positions"] as! [String]).joined(separator: ", ")
218220
let context = Context(dictionary: newdict)

Project/Sources/PaletteGenerator/Stencils/GradientColor.stencil

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// {{ style }}
2-
public static var colors: [UIColor] {
2+
public static var colors: [{{ type }}] {
33
[
44
{% for color in colors %} {{ color }}{% endfor %}
55
]

tools/sources/figma_api.py

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Example made with copy of Uber Base Design System
77
# https://www.figma.com/file/hYiSlGpd2dHIQjfWqSgfDA/
88
FIGMA_FILE_NAME = "hYiSlGpd2dHIQjfWqSgfDA"
9+
# https://www.figma.com/developers/api#access-tokens -> '+ Get personal access token'
910
FIGMA_TOKEN = {"X-Figma-Token": ""} # <--- insert your token here
1011

1112

0 commit comments

Comments
 (0)