Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

linux:
name: Linux
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Ruby
Expand Down
4 changes: 4 additions & 0 deletions Demo/.figmagen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ shadowStyles:

tokens:
file: https://www.figma.com/file/W6dy4CFSZWUVpVnSzNZIxA/FigmaGen-Tokens-Demo
themes:
- hh-day
- hh-night
fallbackTheme: hh-day
templates:
colors:
- destination: FigmaGenDemo/Generated/ColorTokens.swift
Expand Down
142 changes: 1 addition & 141 deletions Demo/FigmaGenDemo/Generated/BorderTokens.swift
Original file line number Diff line number Diff line change
@@ -1,143 +1,3 @@
// swiftlint:disable all
// Generated using FigmaGen - https://github.com/hhru/FigmaGen

#if canImport(UIKit)
import UIKit
#else
import AppKit
#endif

public struct BorderToken: Hashable {
public let width: CGFloat
public let style: String

public init(width: CGFloat, style: String) {
self.width = width
self.style = style
}
}

internal struct BorderTokens {
// MARK: - Instance Properties

/// semantic.border.applied
///
/// Width: 2
/// Style: solid
internal var semanticBorderApplied: BorderToken {
BorderToken(
width: 2,
style: "solid"
)
}

/// semantic.border.checkable
///
/// Width: 1.5
/// Style: solid
internal var semanticBorderCheckable: BorderToken {
BorderToken(
width: 1.5,
style: "solid"
)
}

/// semantic.border.dashed-default
///
/// Width: 2
/// Style: dashed
internal var semanticBorderDashedDefault: BorderToken {
BorderToken(
width: 2,
style: "dashed"
)
}

/// semantic.border.dashed-focused
///
/// Width: 2
/// Style: dashed
internal var semanticBorderDashedFocused: BorderToken {
BorderToken(
width: 2,
style: "dashed"
)
}

/// semantic.border.default
///
/// Width: 1
/// Style: solid
internal var semanticBorderDefault: BorderToken {
BorderToken(
width: 1,
style: "solid"
)
}

/// semantic.border.disabled
///
/// Width: 1
/// Style: solid
internal var semanticBorderDisabled: BorderToken {
BorderToken(
width: 1,
style: "solid"
)
}

/// semantic.border.focused
///
/// Width: 2
/// Style: solid
internal var semanticBorderFocused: BorderToken {
BorderToken(
width: 2,
style: "solid"
)
}

/// semantic.border.hovered
///
/// Width: 1
/// Style: solid
internal var semanticBorderHovered: BorderToken {
BorderToken(
width: 1,
style: "solid"
)
}

/// semantic.border.invalid
///
/// Width: 1
/// Style: solid
internal var semanticBorderInvalid: BorderToken {
BorderToken(
width: 1,
style: "solid"
)
}

/// semantic.border.selected
///
/// Width: 2
/// Style: solid
internal var semanticBorderSelected: BorderToken {
BorderToken(
width: 2,
style: "solid"
)
}

/// semantic.border.tab-focused
///
/// Width: 4
/// Style: solid
internal var semanticBorderTabFocused: BorderToken {
BorderToken(
width: 4,
style: "solid"
)
}
}
// No border tokens found
39 changes: 24 additions & 15 deletions Demo/FigmaGenDemo/Generated/BoxShadowTokens.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,34 @@ import AppKit

public struct BoxShadowTokens {

/// level-1
///
/// Offset: day – x 0; y 4 / night – x 0; y 4
/// Radius: day – 12 / night – 12
/// Color: day – #7090b029 / night – #7090b029
/// - hh-day:
/// Offset: x 0; y 4
/// Radius: 12
/// Color: #7090b029
/// - hh-night:
/// Offset: x 0; y 4
/// Radius: 12
/// Color: #7090b029
public let level1: ShadowToken

/// level-2
///
/// Offset: day – x 0; y 8 / night – x 0; y 8
/// Radius: day – 16 / night – 16
/// Color: day – #7090b03d / night – #7090b03d
/// - hh-day:
/// Offset: x 0; y 8
/// Radius: 16
/// Color: #7090b03d
/// - hh-night:
/// Offset: x 0; y 8
/// Radius: 16
/// Color: #7090b03d
public let level2: ShadowToken

/// level-3
///
/// Offset: day – x 0; y 12 / night – x 0; y 12
/// Radius: day – 24 / night – 24
/// Color: day – #7090b052 / night – #7090b052
/// - hh-day:
/// Offset: x 0; y 12
/// Radius: 24
/// Color: #7090b052
/// - hh-night:
/// Offset: x 0; y 12
/// Radius: 24
/// Color: #7090b052
public let level3: ShadowToken
}

Expand Down
40 changes: 20 additions & 20 deletions Demo/FigmaGenDemo/Generated/ColorTokens.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,65 +11,65 @@ public struct ColorTokens {
public struct Accent {
/// accent.bg
///
/// Day: #c3dafe
/// Night: #434190
/// hh-day: #c3dafe
/// hh-night: #434190
public let bg: UIColor
/// accent.default
///
/// Day: #7f9cf5
/// Night: #5a67d8
/// hh-day: #7f9cf5
/// hh-night: #5a67d8
public let `default`: UIColor
/// accent.onAccent
///
/// Day: #ffffff
/// Night: #ffffff
/// hh-day: #ffffff
/// hh-night: #ffffff
public let onAccent: UIColor
}

public let accent: Accent
public struct Bg {
/// bg.default
///
/// Day: #ffffff
/// Night: #1a202c
/// hh-day: #ffffff
/// hh-night: #1a202c
public let `default`: UIColor
/// bg.muted
///
/// Day: #f7fafc
/// Night: #4a5568
/// hh-day: #f7fafc
/// hh-night: #4a5568
public let muted: UIColor
/// bg.subtle
///
/// Day: #edf2f7
/// Night: #718096
/// hh-day: #edf2f7
/// hh-night: #718096
public let subtle: UIColor
}

public let bg: Bg
public struct Fg {
/// fg.default
///
/// Day: #000000
/// Night: #ffffff
/// hh-day: #000000
/// hh-night: #ffffff
public let `default`: UIColor
/// fg.muted
///
/// Day: #4a5568
/// Night: #e2e8f0
/// hh-day: #4a5568
/// hh-night: #e2e8f0
public let muted: UIColor
/// fg.subtle
///
/// Day: #a0aec0
/// Night: #a0aec0
/// hh-day: #a0aec0
/// hh-night: #a0aec0
public let subtle: UIColor
}

public let fg: Fg
public struct Shadows {
/// shadows.default
///
/// Day: #1a202c
/// Night: #00000000
/// hh-day: #1a202c
/// hh-night: #00000000
public let `default`: UIColor
}

Expand Down
5 changes: 2 additions & 3 deletions Demo/FigmaGenDemo/Generated/Theme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public struct Theme {

extension Theme {

public static let defaultLight = Self(
public static let hhDay = Self(
colors: ColorTokens(
accent: ColorTokens.Accent(
bg: UIColor(hex: 0xC3DAFEFF),
Expand Down Expand Up @@ -68,8 +68,7 @@ extension Theme {
)
)
)

public static let defaultDark = Self(
public static let hhNight = Self(
colors: ColorTokens(
accent: ColorTokens.Accent(
bg: UIColor(hex: 0x434190FF),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct DefaultGradientTokensContextProvider: ColorTokensContextProvider {
let ty = usin == 0 ? nil : (yedge - 0.5) / usin

let t = [tx, ty]
.compactMap(\.self)
.compactMap { $0 }
.filter { $0 > 0 }
.min()

Expand Down
21 changes: 13 additions & 8 deletions Templates/BoxShadowTokens.stencil
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% include "FileHeader.stencil" %}
{% if boxShadows %}
{% if dictThemedBoxShadows[fallbackTheme] %}
{% set accessModifier %}{% if options.publicAccess %}public{% else %}internal{% endif %}{% endset %}
{% set tokenTypeName %}{{ options.tokenTypeName|default:"BoxShadowTokens" }}{% endset %}
{% set shadowTypeName %}{{ options.shadowTypeName|default:"Shadow" }}{% endset %}
Expand All @@ -14,13 +14,18 @@ import AppKit
#endif

{{ accessModifier }} struct {{ tokenTypeName }} {
{% for boxShadow in boxShadows %}

/// {{ boxShadow.path|dropFirst|join:" " }}
///
/// Offset: day – x {{ boxShadow.dayTheme.x }}; y {{ boxShadow.nightTheme.y }} / night – x {{ boxShadow.nightTheme.x }}; y {{ boxShadow.nightTheme.y }}
/// Radius: day – {{ boxShadow.dayTheme.blur }} / night – {{ boxShadow.nightTheme.blur }}
/// Color: day – {{ boxShadow.dayTheme.color }} / night – {{ boxShadow.nightTheme.color }}
{% outer: for boxShadow in dictThemedBoxShadows[fallbackTheme] %}

{% for themedValue in themedBoxShadows %}
{% for shadowToken in themedValue.value %}
{% if forloop.outer.counter == forloop.counter %}
/// - {{ themedValue.themeName }}:
/// Offset: x {{ shadowToken.x }}; y {{ shadowToken.y }}
/// Radius: {{ shadowToken.blur }}
/// Color: {{ shadowToken.color }}
{% endif %}
{% endfor %}
{% endfor %}
{{ accessModifier }} let {% call propertyName boxShadow.path.last %}: {{ shadowTypeName }}
{% endfor %}
}
Expand Down
6 changes: 3 additions & 3 deletions Templates/ColorTokens.stencil
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% include "FileHeader.stencil" %}
{% if colors %}
{% if dictThemedColors[fallbackTheme] %}
{% set colorTypeName %}{{ options.colorTypeName|default:"UIColor" }}{% endset %}
{% set accessModifier %}{% if options.publicAccess %}public{% else %}internal{% endif %}{% endset %}
{% set tokenTypeName %}{{ options.tokenTypeName|default:"ColorTokens" }}{% endset %}
Expand All @@ -9,7 +9,7 @@
{% for color in item.colors %}
/// {{ color.name }}
///
{% for theme, token in color.themedValue %}
{% for theme, token in dictThemedColors|findTokenInThemes:color.name,"colors" %}
/// {{ theme }}: {{ token.value }}
{% endfor %}
{{ accessModifier }} let {% call propertyName color.path.last %}: {{ colorTypeName }}
Expand All @@ -32,7 +32,7 @@ import AppKit
#endif

{{ accessModifier }} struct {{ tokenTypeName }} {
{% call recursiveBlock colors %}
{% call recursiveBlock dictThemedColors[fallbackTheme] %}
}
{% else %}
// No color tokens found
Expand Down
Loading
Loading