From 63345368b7b8d231dedfd21e47f0cced9faf124d Mon Sep 17 00:00:00 2001 From: Vladislavl Date: Mon, 3 Jul 2023 18:42:11 +0300 Subject: [PATCH] merging issues --- Cargo.toml | 2 +- assets/design_tokens_config.yaml | 124 +++++----- assets/figma/variables/color-dark.json | 179 +++----------- assets/generated_styles/color-dark.json | 225 +++++------------- assets/generated_templates/DSButtonLg.swift | 13 - assets/generated_templates/DSButtonMd.swift | 1 - assets/generated_templates/DSButtonSm.swift | 1 - assets/generated_templates/DSColorDark.swift | 75 ++---- assets/generated_templates/DSColorLight.swift | 49 ---- src/general.rs | 38 +-- src/main.rs | 2 +- src/setup.rs | 6 +- 12 files changed, 210 insertions(+), 505 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b2589ed..b72faac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "design_token_parser" -version = "3.1.1" +version = "3.1.2" edition = "2021" repository = "https://github.com/vrrashkov/TokenParser" readme = "README.md" diff --git a/assets/design_tokens_config.yaml b/assets/design_tokens_config.yaml index 51947d6..8495c5a 100644 --- a/assets/design_tokens_config.yaml +++ b/assets/design_tokens_config.yaml @@ -23,15 +23,15 @@ global: files: - "assets/figma/variables/button-sm.json" - "assets/figma/variables/core-.json" - - combine: - file_name: "color-light" - files: - - "assets/figma/variables/color-accent-primary.json" - - "assets/figma/variables/color-accent-secondary.json" - - "assets/figma/variables/color-status-success.json" - - "assets/figma/variables/color-status-danger.json" - - "assets/figma/variables/color-light.json" - - "assets/figma/variables/palette-.json" + # - combine: + # file_name: "color-light" + # files: + # - "assets/figma/variables/color-accent-primary.json" + # - "assets/figma/variables/color-accent-secondary.json" + # - "assets/figma/variables/color-status-success.json" + # - "assets/figma/variables/color-status-danger.json" + # - "assets/figma/variables/color-light.json" + # - "assets/figma/variables/palette-.json" - combine: file_name: "color-dark" files: @@ -56,20 +56,20 @@ global: file_name: "button-sm" files: - path: "assets/figma/variables/button-sm.json" - - combine: - file_name: "color-light" - files: - - path: "assets/figma/variables/color-accent-primary.json" - # if mode is set this will wrap the whole json object with a parent of the mode's value - # this helps if you have similar trees in multiple files - mode: "primary" - - path: "assets/figma/variables/color-accent-secondary.json" - mode: "secondary" - - path: "assets/figma/variables/color-status-success.json" - mode: "success" - - path: "assets/figma/variables/color-status-danger.json" - mode: "danger" - - path: "assets/figma/variables/color-light.json" + # - combine: + # file_name: "color-light" + # files: + # - path: "assets/figma/variables/color-accent-primary.json" + # # if mode is set this will wrap the whole json object with a parent of the mode's value + # # this helps if you have similar trees in multiple files + # mode: "primary" + # - path: "assets/figma/variables/color-accent-secondary.json" + # mode: "secondary" + # - path: "assets/figma/variables/color-status-success.json" + # mode: "success" + # - path: "assets/figma/variables/color-status-danger.json" + # mode: "danger" + # - path: "assets/figma/variables/color-light.json" - combine: file_name: "color-dark" files: @@ -102,46 +102,50 @@ templates: # For themes - type: color value: "public static let {{variable_name | camel}} = {{value | color: 'Color(red: rgb_r_v1, green: rgb_g_v1, blue: rgb_b_v1, opacity: rgb_a_v1)'}} {{description | optional: '// desc = %value'}}" - # For Core - - type: string - value: "public static let {{variable_name | camel}} = {{value}} {{description | optional: '// desc = %value'}}" - - type: float - value: "public static let {{variable_name | camel}} = CGFloat({{value | as_text_or_number}}) {{description | optional: '// desc = %value'}}" - - type: boolean - value: "public static let {{variable_name | camel}} = {{value}} {{description | optional: '// desc = %value'}}" - # More complex templates - # Object - # {{easingFunction | empty}} use empty filter to initialize variable if you need it in the scope of the template without printing it - - type: "custom-transition" - value: "public static let {{variable_name | camel}} = CustomTransition(duration: {{duration}}, - {{easingFunction | empty}} - x1: CGFloat({{easingFunction.x1}}), - x2: CGFloat({{easingFunction.x2}}), - y1: CGFloat({{easingFunction.y1}}), - y2: CGFloat({{easingFunction.y2}})) - " - # Array - # {{stops | empty}} use empty filter to initialize variable if you need it in the scope of the template without printing it - - type: "custom-gradient" - value: "public static let {{variable_name | camel}} = CustomGradient(gradientType: {{gradientType}}, rotation: {{rotation}}, - {{stops | empty}} + - type: boxShadow + value: + - "public static let {{variable_name | camel}} = Shadow(x: CGFloat({{x-0}}), y: CGFloat({{y-0}}), color: Color(hex: \"{{color-0 | color: 'hex'}}\"), radius: CGFloat({{blur-0}}))" + - "public static let {{variable_name | camel}} = [Shadow(x: CGFloat({{x-0}}), y: CGFloat({{y-0}}), color: Color(hex: \"{{color-0 | color: 'hex'}}\"), radius: CGFloat({{blur-0}})), Shadow(x: CGFloat({{x-1}}), y: CGFloat({{y-1}}), color: Color(hex: \"{{color-1 | color: 'hex'}}\"), radius: CGFloat({{blur-1}}))]" + # # For Core + # - type: string + # value: "public static let {{variable_name | camel}} = {{value}} {{description | optional: '// desc = %value'}}" + # - type: float + # value: "public static let {{variable_name | camel}} = CGFloat({{value | as_text_or_number}}) {{description | optional: '// desc = %value'}}" + # - type: boolean + # value: "public static let {{variable_name | camel}} = {{value}} {{description | optional: '// desc = %value'}}" + # # More complex templates + # # Object + # # {{easingFunction | empty}} use empty filter to initialize variable if you need it in the scope of the template without printing it + # - type: "custom-transition" + # value: "public static let {{variable_name | camel}} = CustomTransition(duration: {{duration}}, + # {{easingFunction | empty}} + # x1: CGFloat({{easingFunction.x1}}), + # x2: CGFloat({{easingFunction.x2}}), + # y1: CGFloat({{easingFunction.y1}}), + # y2: CGFloat({{easingFunction.y2}})) + # " + # # Array + # # {{stops | empty}} use empty filter to initialize variable if you need it in the scope of the template without printing it + # - type: "custom-gradient" + # value: "public static let {{variable_name | camel}} = CustomGradient(gradientType: {{gradientType}}, rotation: {{rotation}}, + # {{stops | empty}} - color1: Style1( - {% for stop in stops %} + # color1: Style1( + # {% for stop in stops %} - {{stop.color | color: 'Color(red: rgb_r_v1, green: rgb_g_v1, blue: rgb_b_v1, opacity: rgb_a_v1)'}} - {% if forloop.last == false -%}, {% endif %} - {% endfor -%} - ), + # {{stop.color | color: 'Color(red: rgb_r_v1, green: rgb_g_v1, blue: rgb_b_v1, opacity: rgb_a_v1)'}} + # {% if forloop.last == false -%}, {% endif %} + # {% endfor -%} + # ), - color2: Style2( - {% assign colors = stops | map: 'color' %} - {% for item in colors %} + # color2: Style2( + # {% assign colors = stops | map: 'color' %} + # {% for item in colors %} - {{item | color: 'Color(red: rgb_r_v2, green: rgb_g_v2, blue: rgb_b_v2, opacity: rgb_a_v2)'}} - {% if forloop.last == false -%}, {% endif %} - {% endfor %} - ) - " + # {{item | color: 'Color(red: rgb_r_v2, green: rgb_g_v2, blue: rgb_b_v2, opacity: rgb_a_v2)'}} + # {% if forloop.last == false -%}, {% endif %} + # {% endfor %} + # ) + # " \ No newline at end of file diff --git a/assets/figma/variables/color-dark.json b/assets/figma/variables/color-dark.json index f005af8..f785d10 100644 --- a/assets/figma/variables/color-dark.json +++ b/assets/figma/variables/color-dark.json @@ -1,153 +1,38 @@ { - "success": { - "hover": { - "bg": { - "type": "color", - "value": "{dark.success.success}", - "description": "" - }, - "text": { - "type": "color", - "value": "{dark.success.fr.l60}", - "description": "" - } - }, - "disabled": { - "bg": { - "type": "color", - "value": "{dark.success.fr.l45}", - "description": "" - }, - "text": { - "type": "color", - "value": "{dark.success.bg}", - "description": "" - } - }, - "text": { - "type": "color", - "value": "{dark.success.fr.l60}", - "description": "" - }, - "bg": { - "type": "color", - "value": "{dark.success.bg}", - "description": "" - } - }, - "danger": { - "hover": { - "bg": { - "type": "color", - "value": "{dark.danger.hover}", - "description": "" - }, - "text": { - "type": "color", - "value": "{dark.danger.fr.l60}", - "description": "" - } - }, - "disabled": { - "bg": { - "type": "color", - "value": "{dark.danger.fr.l30}", - "description": "" - }, - "text": { - "type": "color", - "value": "{dark.danger.bg}", - "description": "" - } - }, - "text": { - "type": "color", - "value": "{dark.danger.fr.l60}", - "description": "" - }, - "bg": { - "type": "color", - "value": "{dark.danger.bg}", - "description": "" - } - }, - "secondary": { - "hover": { - "bg": { - "type": "color", - "value": "{dark.accent2.hover}", - "description": "" - }, - "text": { - "type": "color", - "value": "{dark.accent2.fr.l75}", - "description": "" - } - }, - "disabled": { - "bg": { - "type": "color", - "value": "{dark.accent2.fr.l60}", - "description": "" - }, - "text": { - "type": "color", - "value": "{dark.accent2.bg}", - "description": "" - } - }, - "bg": { - "type": "color", - "value": "{dark.accent2.bg}", - "description": "" - }, - "text": { - "type": "color", - "value": "{dark.accent2.fr.l75}", - "description": "" - } - }, - "primary": { - "hover": { - "bg": { - "type": "color", - "value": "{dark.accent1.hover}", - "description": "" - }, - "text": { - "type": "color", - "value": "{dark.accent1.fr.l60}", - "description": "" - } - }, - "disabled": { - "text": { - "type": "color", - "value": "{dark.accent1.bg}", - "description": "" - }, - "bg": { - "type": "color", - "value": "{dark.accent1.fr.l60}", - "description": "" - } - }, - "text": { - "type": "color", - "value": "{dark.accent1.fr.l60}", - "description": "" - }, - "bg": { - "type": "color", - "value": "{dark.accent1.bg}", - "description": "" + "reg": { + "home": { + "card": { + "type": "boxShadow", + "value": { + "blur": "10", + "color": "rgba(0,0,0,0.25)", + "spread": "0", + "type": "dropShadow", + "x": "0", + "y": "4" + } } + } }, - "box": { - "neutral1": { - "type": "color", - "value": "{dark.n1.bg}", - "description": "" + "tabBar": { + "type": "boxShadow", + "value": [ + { + "blur": "20", + "color": "rgba(0,0,0,0.1)", + "spread": "0", + "type": "dropShadow", + "x": "0", + "y": "0" + }, + { + "blur": "8", + "color": "rgba(0,0,0,0.1)", + "spread": "0", + "type": "dropShadow", + "x": "0", + "y": "4" } + ] } } \ No newline at end of file diff --git a/assets/generated_styles/color-dark.json b/assets/generated_styles/color-dark.json index 4f9d9ac..bc3ff02 100644 --- a/assets/generated_styles/color-dark.json +++ b/assets/generated_styles/color-dark.json @@ -1,81 +1,40 @@ { - "box": { - "neutral1": { - "description": "", - "type": "color", - "value": "#1a1a1a" - } - }, "danger": { - "bg": { - "description": "", - "type": "color", - "value": "#ea3e3e" - }, - "disabled": { - "bg": { - "description": "", - "type": "color", - "value": "#f6acac" - }, - "text": { - "description": "", - "type": "color", - "value": "#ea3e3e" - } - }, - "hover": { - "bg": { - "description": "", - "type": "color", - "value": "#ed5959" - }, - "text": { - "description": "", - "type": "color", - "value": "#fdeded" - } - }, "status": { "bg": { "description": "", "type": "color", - "value": "#ea3e3e" + "value": "{danger.bg}" }, "disabled": { "bg": { "description": "", "type": "color", - "value": "#f6acac" + "value": "{danger.disabled.bg}" }, "text": { "description": "", "type": "color", - "value": "#ea3e3e" + "value": "{danger.disabled.text}" } }, "hover": { "bg": { "description": "", "type": "color", - "value": "#ed5959" + "value": "{danger.hover.bg}" }, "text": { "description": "", "type": "color", - "value": "#fdeded" + "value": "{danger.hover.text}" } }, "text": { "description": "", "type": "color", - "value": "#fdeded" + "value": "{danger.text}" } - }, - "text": { - "description": "", - "type": "color", - "value": "#fdeded" } }, "primary": { @@ -83,71 +42,52 @@ "bg": { "description": "", "type": "color", - "value": "#fafafa" + "value": "{secondary.bg}" }, "disabled": { "bg": { "description": "", "type": "color", - "value": "#85878a" + "value": "{secondary.disabled.bg}" }, "text": { "description": "", "type": "color", - "value": "#fafafa" + "value": "{secondary.disabled.text}" } }, "hover": { "bg": { "description": "", "type": "color", - "value": "#e0e0e0" + "value": "{secondary.hover.bg}" }, "text": { "description": "", "type": "color", - "value": "#646668" + "value": "{secondary.hover.text}" } }, "text": { "description": "", "type": "color", - "value": "#646668" + "value": "{secondary.text}" } - }, - "bg": { - "description": "", - "type": "color", - "value": "#3e71ea" - }, - "disabled": { - "bg": { - "description": "", - "type": "color", - "value": "#e8e9ee" - }, - "text": { - "description": "", - "type": "color", - "value": "#3e71ea" - } - }, - "hover": { - "bg": { - "description": "", - "type": "color", - "value": "#5985ed" - }, - "text": { - "description": "", - "type": "color", - "value": "#e8e9ee" + } + }, + "reg": { + "home": { + "card": { + "type": "boxShadow", + "value": { + "blur": "10", + "color": "rgba(0,0,0,0.25)", + "spread": "0", + "type": "dropShadow", + "x": "0", + "y": "4" + } } - }, - "text": { - "description": "", - "type": "color", - "value": "#e8e9ee" } }, "secondary": { @@ -155,143 +95,96 @@ "bg": { "description": "", "type": "color", - "value": "#fafafa" + "value": "{secondary.bg}" }, "disabled": { "bg": { "description": "", "type": "color", - "value": "#85878a" + "value": "{secondary.disabled.bg}" }, "text": { "description": "", "type": "color", - "value": "#fafafa" + "value": "{secondary.disabled.text}" } }, "hover": { "bg": { "description": "", "type": "color", - "value": "#e0e0e0" + "value": "{secondary.hover.bg}" }, "text": { "description": "", "type": "color", - "value": "#646668" + "value": "{secondary.hover.text}" } }, "text": { "description": "", "type": "color", - "value": "#646668" - } - }, - "bg": { - "description": "", - "type": "color", - "value": "#fafafa" - }, - "disabled": { - "bg": { - "description": "", - "type": "color", - "value": "#85878a" - }, - "text": { - "description": "", - "type": "color", - "value": "#fafafa" + "value": "{secondary.text}" } - }, - "hover": { - "bg": { - "description": "", - "type": "color", - "value": "#e0e0e0" - }, - "text": { - "description": "", - "type": "color", - "value": "#646668" - } - }, - "text": { - "description": "", - "type": "color", - "value": "#646668" } }, "success": { - "bg": { - "description": "", - "type": "color", - "value": "#18cd64" - }, - "disabled": { - "bg": { - "description": "", - "type": "color", - "value": "#0b5b2c" - }, - "text": { - "description": "", - "type": "color", - "value": "#18cd64" - } - }, - "hover": { - "bg": { - "description": "", - "type": "color", - "value": "#2de67b" - }, - "text": { - "description": "", - "type": "color", - "value": "#0f2418" - } - }, "status": { "bg": { "description": "", "type": "color", - "value": "#ea3e3e" + "value": "{danger.bg}" }, "disabled": { "bg": { "description": "", "type": "color", - "value": "#f6acac" + "value": "{danger.disabled.bg}" }, "text": { "description": "", "type": "color", - "value": "#ea3e3e" + "value": "{danger.disabled.text}" } }, "hover": { "bg": { "description": "", "type": "color", - "value": "#ed5959" + "value": "{danger.hover.bg}" }, "text": { "description": "", "type": "color", - "value": "#fdeded" + "value": "{danger.hover.text}" } }, "text": { "description": "", "type": "color", - "value": "#fdeded" + "value": "{danger.text}" } - }, - "text": { - "description": "", - "type": "color", - "value": "#0f2418" } + }, + "tabBar": { + "type": "boxShadow", + "value": [ + { + "blur": "20", + "color": "rgba(0,0,0,0.1)", + "spread": "0", + "type": "dropShadow", + "x": "0", + "y": "0" + }, + { + "blur": "8", + "color": "rgba(0,0,0,0.1)", + "spread": "0", + "type": "dropShadow", + "x": "0", + "y": "4" + } + ] } } \ No newline at end of file diff --git a/assets/generated_templates/DSButtonLg.swift b/assets/generated_templates/DSButtonLg.swift index 8a8ba9e..a3a336a 100644 --- a/assets/generated_templates/DSButtonLg.swift +++ b/assets/generated_templates/DSButtonLg.swift @@ -1,16 +1,3 @@ import SwiftUI public class DSCoreButtonLg { -public static let defaultHeight = CGFloat(20) // desc = test desc -public static let defaultDissolve = CustomTransition(duration: 0.45, x1: CGFloat(0.6968395709991455), x2: CGFloat(0.06683959811925888), y1: CGFloat(0.05232666060328483), y2: CGFloat(0.9323266744613647)) -public static let defaultGradientSingleWithMultipleColorStops = CustomGradient(gradientType: radial, rotation: 180, -color1: Style1( -Color(red: 1.000, green: 0.722, blue: 0.000, opacity: 1.000) , -Color(red: 1.000, green: 0.541, blue: 0.000, opacity: 1.000) , -Color(red: 1.000, green: 0.180, blue: 0.000, opacity: 1.000) , -Color(red: 1.000, green: 0.000, blue: 0.000, opacity: 1.000) ), -color2: Style2( -Color(red: 255, green: 184, blue: 0, opacity: 184) , -Color(red: 255, green: 138, blue: 0, opacity: 138) , -Color(red: 255, green: 46, blue: 0, opacity: 46) , -Color(red: 255, green: 0, blue: 0, opacity: 0) ) } diff --git a/assets/generated_templates/DSButtonMd.swift b/assets/generated_templates/DSButtonMd.swift index f0f55ef..fcb4c93 100644 --- a/assets/generated_templates/DSButtonMd.swift +++ b/assets/generated_templates/DSButtonMd.swift @@ -1,4 +1,3 @@ import SwiftUI public class DSCoreButtonMd { -public static let defaultHeight = CGFloat(48) } diff --git a/assets/generated_templates/DSButtonSm.swift b/assets/generated_templates/DSButtonSm.swift index 85b703b..ef36ad9 100644 --- a/assets/generated_templates/DSButtonSm.swift +++ b/assets/generated_templates/DSButtonSm.swift @@ -1,4 +1,3 @@ import SwiftUI public class DSCoreButtonSm { -public static let defaultHeight = CGFloat(40) } diff --git a/assets/generated_templates/DSColorDark.swift b/assets/generated_templates/DSColorDark.swift index 0eef2e4..7c9da9d 100644 --- a/assets/generated_templates/DSColorDark.swift +++ b/assets/generated_templates/DSColorDark.swift @@ -1,52 +1,29 @@ import SwiftUI public class DSCoreColorDark { -public static let boxNeutral1 = Color(red: 0.102, green: 0.102, blue: 0.102, opacity: 1.000) -public static let dangerBg = Color(red: 0.918, green: 0.243, blue: 0.243, opacity: 1.000) -public static let dangerDisabledBg = Color(red: 0.965, green: 0.675, blue: 0.675, opacity: 1.000) -public static let dangerDisabledText = Color(red: 0.918, green: 0.243, blue: 0.243, opacity: 1.000) -public static let dangerHoverBg = Color(red: 0.929, green: 0.349, blue: 0.349, opacity: 1.000) -public static let dangerHoverText = Color(red: 0.992, green: 0.929, blue: 0.929, opacity: 1.000) -public static let dangerStatusBg = Color(red: 0.918, green: 0.243, blue: 0.243, opacity: 1.000) -public static let dangerStatusDisabledBg = Color(red: 0.965, green: 0.675, blue: 0.675, opacity: 1.000) -public static let dangerStatusDisabledText = Color(red: 0.918, green: 0.243, blue: 0.243, opacity: 1.000) -public static let dangerStatusHoverBg = Color(red: 0.929, green: 0.349, blue: 0.349, opacity: 1.000) -public static let dangerStatusHoverText = Color(red: 0.992, green: 0.929, blue: 0.929, opacity: 1.000) -public static let dangerStatusText = Color(red: 0.992, green: 0.929, blue: 0.929, opacity: 1.000) -public static let dangerText = Color(red: 0.992, green: 0.929, blue: 0.929, opacity: 1.000) -public static let primaryAccentBg = Color(red: 0.980, green: 0.980, blue: 0.980, opacity: 1.000) -public static let primaryAccentDisabledBg = Color(red: 0.522, green: 0.529, blue: 0.541, opacity: 1.000) -public static let primaryAccentDisabledText = Color(red: 0.980, green: 0.980, blue: 0.980, opacity: 1.000) -public static let primaryAccentHoverBg = Color(red: 0.878, green: 0.878, blue: 0.878, opacity: 1.000) -public static let primaryAccentHoverText = Color(red: 0.392, green: 0.400, blue: 0.408, opacity: 1.000) -public static let primaryAccentText = Color(red: 0.392, green: 0.400, blue: 0.408, opacity: 1.000) -public static let primaryBg = Color(red: 0.243, green: 0.443, blue: 0.918, opacity: 1.000) -public static let primaryDisabledBg = Color(red: 0.910, green: 0.914, blue: 0.933, opacity: 1.000) -public static let primaryDisabledText = Color(red: 0.243, green: 0.443, blue: 0.918, opacity: 1.000) -public static let primaryHoverBg = Color(red: 0.349, green: 0.522, blue: 0.929, opacity: 1.000) -public static let primaryHoverText = Color(red: 0.910, green: 0.914, blue: 0.933, opacity: 1.000) -public static let primaryText = Color(red: 0.910, green: 0.914, blue: 0.933, opacity: 1.000) -public static let secondaryAccentBg = Color(red: 0.980, green: 0.980, blue: 0.980, opacity: 1.000) -public static let secondaryAccentDisabledBg = Color(red: 0.522, green: 0.529, blue: 0.541, opacity: 1.000) -public static let secondaryAccentDisabledText = Color(red: 0.980, green: 0.980, blue: 0.980, opacity: 1.000) -public static let secondaryAccentHoverBg = Color(red: 0.878, green: 0.878, blue: 0.878, opacity: 1.000) -public static let secondaryAccentHoverText = Color(red: 0.392, green: 0.400, blue: 0.408, opacity: 1.000) -public static let secondaryAccentText = Color(red: 0.392, green: 0.400, blue: 0.408, opacity: 1.000) -public static let secondaryBg = Color(red: 0.980, green: 0.980, blue: 0.980, opacity: 1.000) -public static let secondaryDisabledBg = Color(red: 0.522, green: 0.529, blue: 0.541, opacity: 1.000) -public static let secondaryDisabledText = Color(red: 0.980, green: 0.980, blue: 0.980, opacity: 1.000) -public static let secondaryHoverBg = Color(red: 0.878, green: 0.878, blue: 0.878, opacity: 1.000) -public static let secondaryHoverText = Color(red: 0.392, green: 0.400, blue: 0.408, opacity: 1.000) -public static let secondaryText = Color(red: 0.392, green: 0.400, blue: 0.408, opacity: 1.000) -public static let successBg = Color(red: 0.094, green: 0.804, blue: 0.392, opacity: 1.000) -public static let successDisabledBg = Color(red: 0.043, green: 0.357, blue: 0.173, opacity: 1.000) -public static let successDisabledText = Color(red: 0.094, green: 0.804, blue: 0.392, opacity: 1.000) -public static let successHoverBg = Color(red: 0.176, green: 0.902, blue: 0.482, opacity: 1.000) -public static let successHoverText = Color(red: 0.059, green: 0.141, blue: 0.094, opacity: 1.000) -public static let successStatusBg = Color(red: 0.918, green: 0.243, blue: 0.243, opacity: 1.000) -public static let successStatusDisabledBg = Color(red: 0.965, green: 0.675, blue: 0.675, opacity: 1.000) -public static let successStatusDisabledText = Color(red: 0.918, green: 0.243, blue: 0.243, opacity: 1.000) -public static let successStatusHoverBg = Color(red: 0.929, green: 0.349, blue: 0.349, opacity: 1.000) -public static let successStatusHoverText = Color(red: 0.992, green: 0.929, blue: 0.929, opacity: 1.000) -public static let successStatusText = Color(red: 0.992, green: 0.929, blue: 0.929, opacity: 1.000) -public static let successText = Color(red: 0.059, green: 0.141, blue: 0.094, opacity: 1.000) +public static let dangerStatusBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let dangerStatusDisabledBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let dangerStatusDisabledText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let dangerStatusHoverBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let dangerStatusHoverText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let dangerStatusText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let primaryAccentBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let primaryAccentDisabledBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let primaryAccentDisabledText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let primaryAccentHoverBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let primaryAccentHoverText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let primaryAccentText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let secondaryAccentBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let secondaryAccentDisabledBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let secondaryAccentDisabledText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let secondaryAccentHoverBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let secondaryAccentHoverText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let secondaryAccentText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let successStatusBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let successStatusDisabledBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let successStatusDisabledText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let successStatusHoverBg = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let successStatusHoverText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let successStatusText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) +public static let regHomeCard = Shadow(x: CGFloat(0), y: CGFloat(4), color: Color(hex: "#0000003F"), radius: CGFloat(10)) +public static let tabBar = [Shadow(x: CGFloat(0), y: CGFloat(0), color: Color(hex: "#00000019"), radius: CGFloat(20)), Shadow(x: CGFloat(0), y: CGFloat(4), color: Color(hex: "#00000019"), radius: CGFloat(8))] } diff --git a/assets/generated_templates/DSColorLight.swift b/assets/generated_templates/DSColorLight.swift index 80073b3..bee3bb3 100644 --- a/assets/generated_templates/DSColorLight.swift +++ b/assets/generated_templates/DSColorLight.swift @@ -1,52 +1,3 @@ import SwiftUI public class DSCoreColorLight { -public static let boxNeutral1 = Color(red: 0.980, green: 0.980, blue: 0.980, opacity: 1.000) -public static let dangerBg = Color(red: 0.835, green: 0.165, blue: 0.165, opacity: 1.000) -public static let dangerDisabledBg = Color(red: 0.898, green: 0.624, blue: 0.624, opacity: 1.000) -public static let dangerDisabledText = Color(red: 0.835, green: 0.165, blue: 0.165, opacity: 1.000) -public static let dangerHoverBg = Color(red: 0.667, green: 0.133, blue: 0.133, opacity: 1.000) -public static let dangerHoverText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) -public static let dangerStatusBg = Color(red: 0.835, green: 0.165, blue: 0.165, opacity: 1.000) -public static let dangerStatusDisabledBg = Color(red: 0.898, green: 0.624, blue: 0.624, opacity: 1.000) -public static let dangerStatusDisabledText = Color(red: 0.835, green: 0.165, blue: 0.165, opacity: 1.000) -public static let dangerStatusHoverBg = Color(red: 0.667, green: 0.133, blue: 0.133, opacity: 1.000) -public static let dangerStatusHoverText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) -public static let dangerStatusText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) -public static let dangerText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) -public static let primaryAccentBg = Color(red: 0.149, green: 0.149, blue: 0.149, opacity: 1.000) -public static let primaryAccentDisabledBg = Color(red: 0.722, green: 0.722, blue: 0.722, opacity: 1.000) -public static let primaryAccentDisabledText = Color(red: 0.149, green: 0.149, blue: 0.149, opacity: 1.000) -public static let primaryAccentHoverBg = Color(red: 0.102, green: 0.102, blue: 0.102, opacity: 1.000) -public static let primaryAccentHoverText = Color(red: 0.922, green: 0.922, blue: 0.922, opacity: 1.000) -public static let primaryAccentText = Color(red: 0.922, green: 0.922, blue: 0.922, opacity: 1.000) -public static let primaryBg = Color(red: 0.149, green: 0.357, blue: 0.851, opacity: 1.000) -public static let primaryDisabledBg = Color(red: 0.847, green: 0.855, blue: 0.875, opacity: 1.000) -public static let primaryDisabledText = Color(red: 0.149, green: 0.357, blue: 0.851, opacity: 1.000) -public static let primaryHoverBg = Color(red: 0.122, green: 0.286, blue: 0.678, opacity: 1.000) -public static let primaryHoverText = Color(red: 0.945, green: 0.949, blue: 0.953, opacity: 1.000) -public static let primaryText = Color(red: 0.945, green: 0.949, blue: 0.953, opacity: 1.000) -public static let secondaryAccentBg = Color(red: 0.149, green: 0.149, blue: 0.149, opacity: 1.000) -public static let secondaryAccentDisabledBg = Color(red: 0.722, green: 0.722, blue: 0.722, opacity: 1.000) -public static let secondaryAccentDisabledText = Color(red: 0.149, green: 0.149, blue: 0.149, opacity: 1.000) -public static let secondaryAccentHoverBg = Color(red: 0.102, green: 0.102, blue: 0.102, opacity: 1.000) -public static let secondaryAccentHoverText = Color(red: 0.922, green: 0.922, blue: 0.922, opacity: 1.000) -public static let secondaryAccentText = Color(red: 0.922, green: 0.922, blue: 0.922, opacity: 1.000) -public static let secondaryBg = Color(red: 0.149, green: 0.149, blue: 0.149, opacity: 1.000) -public static let secondaryDisabledBg = Color(red: 0.722, green: 0.722, blue: 0.722, opacity: 1.000) -public static let secondaryDisabledText = Color(red: 0.149, green: 0.149, blue: 0.149, opacity: 1.000) -public static let secondaryHoverBg = Color(red: 0.102, green: 0.102, blue: 0.102, opacity: 1.000) -public static let secondaryHoverText = Color(red: 0.922, green: 0.922, blue: 0.922, opacity: 1.000) -public static let secondaryText = Color(red: 0.922, green: 0.922, blue: 0.922, opacity: 1.000) -public static let successBg = Color(red: 0.161, green: 0.639, blue: 0.361, opacity: 1.000) -public static let successDisabledBg = Color(red: 0.729, green: 0.933, blue: 0.812, opacity: 1.000) -public static let successDisabledText = Color(red: 0.161, green: 0.639, blue: 0.361, opacity: 1.000) -public static let successHoverBg = Color(red: 0.122, green: 0.478, blue: 0.271, opacity: 1.000) -public static let successHoverText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) -public static let successStatusBg = Color(red: 0.835, green: 0.165, blue: 0.165, opacity: 1.000) -public static let successStatusDisabledBg = Color(red: 0.898, green: 0.624, blue: 0.624, opacity: 1.000) -public static let successStatusDisabledText = Color(red: 0.835, green: 0.165, blue: 0.165, opacity: 1.000) -public static let successStatusHoverBg = Color(red: 0.667, green: 0.133, blue: 0.133, opacity: 1.000) -public static let successStatusHoverText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) -public static let successStatusText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) -public static let successText = Color(red: 1.000, green: 1.000, blue: 1.000, opacity: 1.000) } diff --git a/src/general.rs b/src/general.rs index f684bff..2f1ecf8 100644 --- a/src/general.rs +++ b/src/general.rs @@ -34,22 +34,33 @@ pub fn generate_tokens(tokens_config: &deserializer::TokensConfig) -> Vec Vec serde_json::Value { - println!("path: {}", path); + let data = fs::read_to_string(path).expect("Unable to read file"); let res: serde_json::Value = serde_json::from_str(&data).expect("Unable to parse"); @@ -120,7 +130,6 @@ pub fn filter_properties(json: &serde_json::Value) -> Vec { } } - token_data_list } @@ -144,6 +153,7 @@ pub fn filter_sub_properties(key: String, val: &serde_json::Value, token_data_li listEnum = val.as_object().iter().flat_map(|f| f.iter()).collect::>(); } + for (ikey, ival) in listEnum { let template_type = ival["type"].as_str(); diff --git a/src/main.rs b/src/main.rs index da62226..98442ea 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,7 +31,7 @@ fn main() { // Covert to usable code let matches: clap::ArgMatches = Command::new("Design Tokens") - .version("3.1.1") + .version("3.1.2") .author("Vladislav R. ") .about("Parses figma design tokens to usable code") .arg(Arg::new("config").short('c').long("config").action(ArgAction::Set).required(true)) diff --git a/src/setup.rs b/src/setup.rs index 95175ac..c54e990 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -24,7 +24,7 @@ pub fn init(token_config: &deserializer::TokensConfig) { let file_data_name = "custom"; let template_content = template_content_custom(template_config, token_data_wrapper, token_config, file_data_name, &token_data_wrapper.token_data); - + general::create_template(template_config, &token_data_wrapper.style_name, file_data_name, &template_content); } @@ -49,12 +49,13 @@ fn template_content_custom( for template in &custom_template.template_type { let template_type = &template.t_type; + match &template.value { deserializer::CustomConfigTempalteTypeValue::Value(value) => { template_update_list_values(file_data_list, &mut current_template, template_type.to_owned(), value); }, deserializer::CustomConfigTempalteTypeValue::Values(values) => { - + template_list_replaced_values(file_data_list, &mut current_template, template_type.to_owned(),values); }, } @@ -142,7 +143,6 @@ pub fn template_set_values(index: usize, data: &template::TokenValue, pure_templ let token_value = data; let mut template: Option = Some(pure_template.to_string()); - for field_data in fields { let field_name = field_data.key_full.as_str(); let field_name_without_index = field_data.key_without_index.as_str();