diff --git a/.idea/markdown.xml b/.idea/markdown.xml new file mode 100644 index 0000000..c61ea33 --- /dev/null +++ b/.idea/markdown.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/scripts/colorparser/ColorParser.kts b/scripts/colorparser/ColorParser.kts index 2478c18..7d9391c 100755 --- a/scripts/colorparser/ColorParser.kts +++ b/scripts/colorparser/ColorParser.kts @@ -36,7 +36,7 @@ val themeWriters = listOf( val colorAssignmentPattern = " = Color\\(0x[0-9a-fA-F]{8}\\)".toRegex() fun FileWriter.appendInterfaceFieldLineIfMatches(inputLine: String, inputColorNameSuffix: String) { - if (inputLine.trim().endsWith(inputColorNameSuffix)) { + if (inputLine.contains(inputColorNameSuffix)) { appendLine( " " + inputLine.replace(inputColorNameSuffix, "") .replace(colorAssignmentPattern, ": Color") @@ -45,7 +45,7 @@ fun FileWriter.appendInterfaceFieldLineIfMatches(inputLine: String, inputColorNa } fun ThemeWriter.appendLineIfMatches(line: String) { - if (line.trim().endsWith(inputColorNameSuffix)) { + if (line.contains(inputColorNameSuffix)) { writer.append(" override ") // Indentation + override keyword writer.appendLine(line.replace(inputColorNameSuffix, "")) } @@ -115,4 +115,4 @@ themeWriters.forEach { themeWriter -> writeAppColorsFooter() writer.close() } -} \ No newline at end of file +} diff --git a/scripts/colorparser/README.md b/scripts/colorparser/README.md index d9ffc1d..fe22006 100644 --- a/scripts/colorparser/README.md +++ b/scripts/colorparser/README.md @@ -11,21 +11,19 @@ figma 'Color2Code' plugin, which exports the Color Tokens. ## Usage -1. Open - the [Color Tokens page](https://www.figma.com/file/jTFWg6tZjCWwcxqwkKmykZ/app-foundation?type=design&node-id=1259-12&mode=design&t=BcdgPKHmtGLKMZL8-11) - in Figma. -1. Run the [Color2Code](https://www.figma.com/community/plugin/1262830857362718014) plugin in Figma. - Note: you need edit rights for this, perhaps you need to do +1. Open the Color Tokens page in Figma. +2. Run the [Color2Code](https://www.figma.com/community/plugin/1262830857362718014) plugin in Figma. + Note: you need Design or Dewv Mode for this, perhaps you need to do this in collaboration with a designer. -2. Export the Color Tokens using the plugin. Disable `Remove group names`; enable - `Camel case naming` select `Android` and `Semantics`. +3. Export the Color Tokens using the plugin. Select `Android` and format `Compose`. Disable `Remove group names`; enable + `Camel case naming`. ![Color 2 Code settings](color_parser_color_2_code.png) -3. Copy the output of the plugin and paste it into the `color_parser_input.txt` file. -4. Run the `ColorParser.kts` script by clicking the play button in the file or running +4. Copy the output of the plugin and paste it into the `color_parser_input.txt` file. +5. Run the `ColorParser.kts` script by clicking the play button in the file or running - `./scripts/colorparser/ColorParser.kts` + `(cd ./scripts/colorparser && ./ColorParser.kts)` -5. The script will update the `AppColorScheme.kt` file and the corresponding files for both the +6. The script will update the `AppColorScheme.kt` file and the corresponding files for both the light and dark themes. ## File Structure diff --git a/scripts/colorparser/color_parser_color_2_code.png b/scripts/colorparser/color_parser_color_2_code.png new file mode 100644 index 0000000..adc5ec9 Binary files /dev/null and b/scripts/colorparser/color_parser_color_2_code.png differ