diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d862b33..8ca95b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: linux: name: Linux - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 - name: Ruby diff --git a/Demo/.figmagen.yml b/Demo/.figmagen.yml index 40c3d07..a027a90 100644 --- a/Demo/.figmagen.yml +++ b/Demo/.figmagen.yml @@ -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 diff --git a/Demo/FigmaGenDemo/Generated/BorderTokens.swift b/Demo/FigmaGenDemo/Generated/BorderTokens.swift index 54f1d0c..93c9748 100644 --- a/Demo/FigmaGenDemo/Generated/BorderTokens.swift +++ b/Demo/FigmaGenDemo/Generated/BorderTokens.swift @@ -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 diff --git a/Demo/FigmaGenDemo/Generated/BoxShadowTokens.swift b/Demo/FigmaGenDemo/Generated/BoxShadowTokens.swift index 83bf8dd..99d68fc 100644 --- a/Demo/FigmaGenDemo/Generated/BoxShadowTokens.swift +++ b/Demo/FigmaGenDemo/Generated/BoxShadowTokens.swift @@ -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 } diff --git a/Demo/FigmaGenDemo/Generated/ColorTokens.swift b/Demo/FigmaGenDemo/Generated/ColorTokens.swift index edb82ef..5d84619 100644 --- a/Demo/FigmaGenDemo/Generated/ColorTokens.swift +++ b/Demo/FigmaGenDemo/Generated/ColorTokens.swift @@ -11,18 +11,18 @@ 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 } @@ -30,18 +30,18 @@ public struct ColorTokens { 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 } @@ -49,18 +49,18 @@ public struct ColorTokens { 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 } @@ -68,8 +68,8 @@ public struct ColorTokens { public struct Shadows { /// shadows.default /// - /// Day: #1a202c - /// Night: #00000000 + /// hh-day: #1a202c + /// hh-night: #00000000 public let `default`: UIColor } diff --git a/Demo/FigmaGenDemo/Generated/Theme.swift b/Demo/FigmaGenDemo/Generated/Theme.swift index b5b9966..c159b81 100644 --- a/Demo/FigmaGenDemo/Generated/Theme.swift +++ b/Demo/FigmaGenDemo/Generated/Theme.swift @@ -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), @@ -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), diff --git a/Sources/FigmaGen/Generators/Tokens/Providers/ColorTokensContext/Gradient/DefaultGradientTokensContextProvider.swift b/Sources/FigmaGen/Generators/Tokens/Providers/ColorTokensContext/Gradient/DefaultGradientTokensContextProvider.swift index 64666d2..dedc523 100644 --- a/Sources/FigmaGen/Generators/Tokens/Providers/ColorTokensContext/Gradient/DefaultGradientTokensContextProvider.swift +++ b/Sources/FigmaGen/Generators/Tokens/Providers/ColorTokensContext/Gradient/DefaultGradientTokensContextProvider.swift @@ -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() diff --git a/Templates/BoxShadowTokens.stencil b/Templates/BoxShadowTokens.stencil index 42e2364..4f02db5 100644 --- a/Templates/BoxShadowTokens.stencil +++ b/Templates/BoxShadowTokens.stencil @@ -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 %} @@ -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 %} } diff --git a/Templates/ColorTokens.stencil b/Templates/ColorTokens.stencil index 95c0cc4..f947781 100644 --- a/Templates/ColorTokens.stencil +++ b/Templates/ColorTokens.stencil @@ -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 %} @@ -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 }} @@ -32,7 +32,7 @@ import AppKit #endif {{ accessModifier }} struct {{ tokenTypeName }} { - {% call recursiveBlock colors %} + {% call recursiveBlock dictThemedColors[fallbackTheme] %} } {% else %} // No color tokens found diff --git a/Templates/GradientTokens.stencil b/Templates/GradientTokens.stencil index 8f1a445..7f25690 100644 --- a/Templates/GradientTokens.stencil +++ b/Templates/GradientTokens.stencil @@ -1,5 +1,5 @@ {% include "FileHeader.stencil" %} -{% if gradients %} +{% if dictThemedGradients[fallbackTheme] %} {% set gradientTypeName %}{{ options.colorTypeName|default:"LinearGradient" }}{% endset %} {% macro propertyName name %}{{ name|swiftIdentifier:"pretty"|lowerFirstWord|escapeReservedKeywords }}{% endmacro %} {% macro typeName name %}{{ name|swiftIdentifier:"pretty"|upperFirstLetter|escapeReservedKeywords }}{% endmacro %} @@ -8,13 +8,11 @@ /// {{ gradient.name }} /// - /// Day Theme: - {% for stop in gradient.dayTheme.stops %} - /// - {{ stop.color }} {{ stop.percentage }}% + {% for theme, token in dictThemedGradients|findTokenInThemes:gradient.name,"gradients" %} + /// {{ theme }}: + {% for stop in token.stops %} + /// - {{ stop.color }} {{ stop.percentage }} {% endfor %} - /// Night Theme: - {% for stop in gradient.nightTheme.stops %} - /// - {{ stop.color }} {{ stop.percentage }}% {% endfor %} public let {% call propertyName gradient.path.last %}: {{ gradientTypeName }} {% endfor %} @@ -36,7 +34,7 @@ import SwiftUI public struct Gradients { - {% call recursiveBlock gradients %} + {% call recursiveBlock dictThemedGradients[fallbackTheme] %} } {% else %} // No color tokens found diff --git a/Templates/Theme.stencil b/Templates/Theme.stencil index b43e647..4311be6 100644 --- a/Templates/Theme.stencil +++ b/Templates/Theme.stencil @@ -11,11 +11,7 @@ {% macro hexColor color %}{{ color|fullHex|uppercase|replace:"#","0x" }}{% endmacro %} {% macro argumentsBlock item theme parentTypeName %} {% for color in item.colors %} -{% if color.themedValue[theme] %} -{% call propertyName color.path.last %}: {{ colorTypeName }}(hex: {% call hexColor color.themedValue[theme].value %}){% if not forloop.last %},{% endif %} -{% else %} - {% continue %} -{% endif %} +{% call propertyName color.path.last %}: {{ colorTypeName }}(hex: {% call hexColor color.value %}){% if not forloop.last %},{% endif %} {% endfor %} {% for child in item.children %} {% set childTypeName %}{% if parentTypeName %}{{ parentTypeName }}.{% endif %}{% call typeName child.name %}{% endset %} @@ -39,16 +35,12 @@ colors: {{ colorTokensTypeName }}( {% if boxShadows %} shadows: {{ boxShadowTokensTypeName }}( {% for boxShadow in boxShadows %} - {% if boxShadow.themedValue[theme] %} {% call propertyName boxShadow.path.last %}: {{ shadowTypeName }}( - offset: CGSize(width: {{ boxShadow.themedValue[theme].x }}, height: {{ boxShadow.themedValue[theme].y }}), - radius: {{ boxShadow[theme].blur }}, - color: {{ colorTypeName }}(hex: {% call hexColor boxShadow.themedValue[theme].color %}), + offset: CGSize(width: {{ boxShadow.x }}, height: {{ boxShadow.y }}), + radius: {{ boxShadow.blur }}, + color: {{ colorTypeName }}(hex: {% call hexColor boxShadow.color %}), opacity: 1.0 ){% if not forloop.last %},{% endif %} - {% else %} - {% continue %} - {% endif %} {% endfor %} ) {% endif %} @@ -62,27 +54,27 @@ import AppKit {{ accessModifier }} struct {{ themeTypeName }} { - {% if colors %} + {% if dictThemedColors[fallbackTheme] %} {{ accessModifier }} let colors: {{ colorTokensTypeName }} {% endif %} - {% if boxShadows %} + {% if dictThemedBoxShadows[fallbackTheme] %} {{ accessModifier }} let shadows: {{ boxShadowTokensTypeName }} {% endif %} {{ accessModifier }} let typographies: {{ typographyTokensTypeName }} init( - {% if colors %} + {% if dictThemedColors[fallbackTheme] %} colors: {{ colorTokensTypeName }}, {% endif %} - {% if boxShadows %} + {% if dictThemedBoxShadows[fallbackTheme] %} shadows: {{ boxShadowTokensTypeName }}, {% endif %} typographies: {{ typographyTokensTypeName }} = {{ typographyTokensTypeName }}() ) { - {% if colors %} + {% if dictThemedColors[fallbackTheme] %} self.colors = colors {% endif %} - {% if boxShadows %} + {% if dictThemedBoxShadows[fallbackTheme] %} self.shadows = shadows {% endif %} self.typographies = typographies @@ -92,17 +84,17 @@ import AppKit extension {{ themeTypeName }} { {% for theme in themes %} - {% set themePropertyName %}{{ theme||swiftIdentifier:"pretty"|lowerFirstWord }}{% endset %} + {% set themePropertyName %}{{ theme.name||swiftIdentifier:"pretty"|lowerFirstWord }}{% endset %} {{ accessModifier }} static let {{ themePropertyName }} = Self( {% filter indent:8 %} - {% call colorsArgumentsBlock colors theme %} - {% call shadowsArgumentsBlock boxShadows theme %} + {% call colorsArgumentsBlock dictThemedColors[theme.name] theme.name %} + {% call shadowsArgumentsBlock dictThemedBoxShadows[theme.name] theme.name %} {% endfilter %} ) {% endfor %} } -{% if colors or boxShadows %} +{% if dictThemedColors or dictThemedBoxShadows %} private extension {{ colorTypeName }} { convenience init(hex: UInt32) { diff --git a/Tests/FigmaGenTests/TokensResolverTests.swift b/Tests/FigmaGenTests/TokensResolverTests.swift index 8957fbd..84f1b58 100644 --- a/Tests/FigmaGenTests/TokensResolverTests.swift +++ b/Tests/FigmaGenTests/TokensResolverTests.swift @@ -20,15 +20,13 @@ final class TokensResolverTests: XCTestCase { semantic: [], colors: [], typography: [], - hhDay: [], - hhNight: [], - zpDay: [] + themedTokens: [:] ) let value = "{core.space.1-x} + {core.space.1-x} / 2" let expectedValue = "6" - let actualValue = try tokensResolver.resolveValue(value, tokenValues: tokenValues, theme: .day) + let actualValue = try tokensResolver.resolveValue(value, tokenValues: tokenValues, theme: .light) XCTAssertEqual(actualValue, expectedValue) } @@ -40,11 +38,11 @@ final class TokensResolverTests: XCTestCase { let pixelValue = "0px" let colorValue = "#ffffff" - let actualNumberValue = try tokensResolver.resolveValue(numberValue, tokenValues: .empty, theme: .day) - let actualPercentValue = try tokensResolver.resolveValue(percentValue, tokenValues: .empty, theme: .day) - let actualTextValue = try tokensResolver.resolveValue(textValue, tokenValues: .empty, theme: .day) - let actualPixelValue = try tokensResolver.resolveValue(pixelValue, tokenValues: .empty, theme: .day) - let actualColorValue = try tokensResolver.resolveValue(colorValue, tokenValues: .empty, theme: .day) + let actualNumberValue = try tokensResolver.resolveValue(numberValue, tokenValues: .empty, theme: .light) + let actualPercentValue = try tokensResolver.resolveValue(percentValue, tokenValues: .empty, theme: .light) + let actualTextValue = try tokensResolver.resolveValue(textValue, tokenValues: .empty, theme: .light) + let actualPixelValue = try tokensResolver.resolveValue(pixelValue, tokenValues: .empty, theme: .light) + let actualColorValue = try tokensResolver.resolveValue(colorValue, tokenValues: .empty, theme: .light) XCTAssertEqual(actualNumberValue, numberValue) XCTAssertEqual(actualPercentValue, percentValue) @@ -65,15 +63,13 @@ final class TokensResolverTests: XCTestCase { TokenValue(type: .core(value: "#ffffff"), name: "color.base.white") ], typography: [], - hhDay: [], - hhNight: [], - zpDay: [] + themedTokens: [:] ) let value = "rgba({color.base.white}, {semantic.opacity.disabled})" let expectedColor = Color(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.48) - let actualColor = try tokensResolver.resolveRGBAColorValue(value, tokenValues: tokenValues, theme: .day) + let actualColor = try tokensResolver.resolveRGBAColorValue(value, tokenValues: tokenValues, theme: .light) XCTAssertEqual(actualColor, expectedColor) } @@ -82,7 +78,7 @@ final class TokensResolverTests: XCTestCase { let value = "rgba(#FFFFFF, 48%)" let expectedColor = Color(red: 1.0, green: 1.0, blue: 1.0, alpha: 0.48) - let actualColor = try tokensResolver.resolveRGBAColorValue(value, tokenValues: .empty, theme: .day) + let actualColor = try tokensResolver.resolveRGBAColorValue(value, tokenValues: .empty, theme: .light) XCTAssertEqual(actualColor, expectedColor) } @@ -99,9 +95,7 @@ final class TokensResolverTests: XCTestCase { TokenValue(type: .color(value: "#d64030"), name: "color.base.red.50") ], typography: [], - hhDay: [], - hhNight: [], - zpDay: [] + themedTokens: [:] ) let firstColor = "rgba({color.base.red.50}, {semantic.opacity.transparent})" @@ -135,7 +129,7 @@ final class TokensResolverTests: XCTestCase { let actualLinearGradient = try tokensResolver.resolveLinearGradientValue( value, tokenValues: tokenValues, - theme: .day + theme: .light ) XCTAssertEqual(actualLinearGradient, expectedLinearGradient) @@ -171,7 +165,7 @@ final class TokensResolverTests: XCTestCase { let actualLinearGradient = try tokensResolver.resolveLinearGradientValue( value, tokenValues: .empty, - theme: .day + theme: .light ) XCTAssertEqual(actualLinearGradient, expectedLinearGradient) @@ -190,9 +184,7 @@ final class TokensResolverTests: XCTestCase { TokenValue(type: .color(value: "#111"), name: "color.base.gray.5") ], typography: [], - hhDay: [], - hhNight: [], - zpDay: [] + themedTokens: [:] ) let value1 = "rgba({color.base.white}, {semantic.opacity.disabled})" @@ -201,8 +193,8 @@ final class TokensResolverTests: XCTestCase { let value2 = "rgba( {color.base.gray.5} , {semantic.opacity.disabled})" let expectedHexColor2 = "#1111117A" - let actualHexColor1 = try tokensResolver.resolveHexColorValue(value1, tokenValues: tokenValues, theme: .day) - let actualHexColor2 = try tokensResolver.resolveHexColorValue(value2, tokenValues: tokenValues, theme: .day) + let actualHexColor1 = try tokensResolver.resolveHexColorValue(value1, tokenValues: tokenValues, theme: .light) + let actualHexColor2 = try tokensResolver.resolveHexColorValue(value2, tokenValues: tokenValues, theme: .light) XCTAssertEqual(actualHexColor1, expectedHexColor1) XCTAssertEqual(actualHexColor2, expectedHexColor2) @@ -212,7 +204,7 @@ final class TokensResolverTests: XCTestCase { let value = "rgba(#FFFFFF, 48%)" let expectedHexColor = "#FFFFFF7A" - let actualHexColor = try tokensResolver.resolveHexColorValue(value, tokenValues: .empty, theme: .day) + let actualHexColor = try tokensResolver.resolveHexColorValue(value, tokenValues: .empty, theme: .light) XCTAssertEqual(actualHexColor, expectedHexColor) } @@ -225,18 +217,18 @@ final class TokensResolverTests: XCTestCase { TokenValue(type: .color(value: "#000000"), name: "color.base.black") ], typography: [], - hhDay: [], - hhNight: [ - TokenValue(type: .color(value: "{color.base.black}"), name: "color.background.primary"), - TokenValue(type: .color(value: "{color.background.primary}"), name: "color.background.primary.nested") - ], - zpDay: [] + themedTokens: [ + .dark: [ + TokenValue(type: .color(value: "{color.base.black}"), name: "color.background.primary"), + TokenValue(type: .color(value: "{color.background.primary}"), name: "color.background.primary.nested") + ] + ] ) let value = "{color.background.primary.nested}" let expectedBaseReference = "{color.base.black}" - let actualBaseReference = try tokensResolver.resolveBaseReference(value, tokenValues: tokenValues.hhNight) + let actualBaseReference = try tokensResolver.resolveBaseReference(value, tokenValues: tokenValues.tokens(for: .dark)) XCTAssertEqual(actualBaseReference, expectedBaseReference) } @@ -253,18 +245,18 @@ final class TokensResolverTests: XCTestCase { TokenValue(type: .color(value: "#000000"), name: "color.base.black") ], typography: [], - hhDay: [], - hhNight: [ - TokenValue(type: .color(value: "{color.base.black}"), name: "color.background.primary"), - TokenValue(type: .color(value: "{color.background.primary}"), name: "color.background.primary.nested") - ], - zpDay: [] + themedTokens: [ + .dark: [ + TokenValue(type: .color(value: "{color.base.black}"), name: "color.background.primary"), + TokenValue(type: .color(value: "{color.background.primary}"), name: "color.background.primary.nested") + ] + ] ) let value = "rgba( {color.background.primary.nested}, {semantic.opacity.disabled})" let expectedBaseReference = "rgba( {color.base.black}, {semantic.opacity.disabled})" - let actualBaseReference = try tokensResolver.resolveBaseReference(value, tokenValues: tokenValues.hhNight) + let actualBaseReference = try tokensResolver.resolveBaseReference(value, tokenValues: tokenValues.tokens(for: .dark)) XCTAssertEqual(actualBaseReference, expectedBaseReference) } @@ -279,9 +271,7 @@ extension TokenValues { semantic: [], colors: [], typography: [], - hhDay: [], - hhNight: [], - zpDay: [] + themedTokens: [:] ) } #endif