diff --git a/output.json b/output.json index 3011102..1402041 100644 --- a/output.json +++ b/output.json @@ -1,31 +1,36 @@ { - "blueprints": [{ - "invoke": "borders.pr", - "write_to": "Styles/BorderExtension.swift" - }, - { - "invoke": "colors.pr", - "write_to": "Styles/ColorExtension.swift" - }, - { - "invoke": "gradients.pr", - "write_to": "Styles/GradientExtension.swift" - }, - { - "invoke": "measures.pr", - "write_to": "Styles/AppMeasures.swift" - }, - { - "invoke": "radius.pr", - "write_to": "Styles/RadiusExtension.swift" - }, - { - "invoke": "shadows.pr", - "write_to": "Styles/ShadowExtension.swift" - }, - { - "invoke": "typography.pr", - "write_to": "Styles/FontExtension.swift" - } - ] + "blueprints": [ + { + "invoke": "borders.pr", + "write_to": "Styles/SwiftUI/BorderExtension.swift" + }, + { + "invoke": "colors.pr", + "write_to": "Styles/SwiftUI/ColorExtension.swift" + }, + { + "invoke": "gradients.pr", + "write_to": "Styles/SwiftUI/GradientExtension.swift" + }, + { + "invoke": "measures.pr", + "write_to": "Styles/SwiftUI/AppMeasures.swift" + }, + { + "invoke": "radius.pr", + "write_to": "Styles/SwiftUI/RadiusExtension.swift" + }, + { + "invoke": "shadows.pr", + "write_to": "Styles/SwiftUI/ShadowExtension.swift" + }, + { + "invoke": "typography.pr", + "write_to": "Styles/SwiftUI/FontExtension.swift" + }, + { + "invoke": "ui_colors.pr", + "write_to": "Styles/UIKit/UIColorExtension.swift" + } + ] } \ No newline at end of file diff --git a/src/exported_files/colors.pr b/src/exported_files/colors.pr index e76c330..c148843 100644 --- a/src/exported_files/colors.pr +++ b/src/exported_files/colors.pr @@ -22,7 +22,7 @@ extension Color { {{ createDocumentationComment(token.description, " ") }} {[/]} - let {[ inject "token_name" context this /]} = {[ inject "color" context token.value /]} + let {[ inject "token_name" context this /]} = Color(UIColor.Token.{[ inject "token_name" context this /]}) {[/]} {[/]} {[/]} diff --git a/src/exported_files/ui_colors.pr b/src/exported_files/ui_colors.pr new file mode 100644 index 0000000..1db7b55 --- /dev/null +++ b/src/exported_files/ui_colors.pr @@ -0,0 +1,30 @@ +import UIKit + +// Generated by Supernova - do not modify manually +extension UIColor { + + static let Token = UIColor.TokenColor() + + struct TokenColor { + {[ let brand = ds.currentBrand() /]} + {[ for group in ds.tokenGroupsOfType("Color", brand.id) ]} + {[ if !(group.tokenIds.count() === 0 && group.subgroups.count() === 0) ]} + {[ if !group.isRoot ]} + + // {{ group.name }} + {[/]} + {[ const tokens = ds.tokensByGroupId(group.id) /]} + {[ if (group.tokenIds.count() !== 0 && (tokens.first() && tokens.first().description === 0)) ]} + + {[/]} + {[ for token in tokens ]} + {[ if (token.description && token.description.count() !== 0) ]} + + {{ createDocumentationComment(token.description, " ") }} + {[/]} + let {[ inject "token_name" context this /]} = {[ inject "ui_color" context token.value /]} + {[/]} + {[/]} + {[/]} + } +} \ No newline at end of file diff --git a/src/utility/ui_color.pr b/src/utility/ui_color.pr new file mode 100644 index 0000000..0fa5bd7 --- /dev/null +++ b/src/utility/ui_color.pr @@ -0,0 +1 @@ +UIColor(red: {{ context.r }}/255, green: {{ context.g }}/255, blue: {{ context.b }}/255, alpha: {{ (context.a / 255).rounded(2) }}) \ No newline at end of file