Skip to content

automatically converting Codex color tokens to Compose color values #5690

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: main
Choose a base branch
from

Conversation

Williamrai
Copy link
Collaborator

@Williamrai Williamrai commented Jun 18, 2025

What does this do?

adds a script to generate the following

  1. ComposeColors class with raw colors
  2. WikipediaColor data class consisting the names of the colors that will reference the raw colors
  3. LightColor tokens
  4. DarkColor tokens

Phabricator:
https://phabricator.wikimedia.org/T396880

- adds function extract_colors for raw colors
- adds convert_hex_to_kotlin_color function
- adds a raw color file generator script
@Williamrai Williamrai added the WIP Work in progress label Jun 18, 2025
Williamrai and others added 2 commits June 20, 2025 11:55
- refactor functions and code for better readability
- adds to_camel_case function
- logic fixes
@Williamrai Williamrai added Ready to merge PR passed design signoff and ready to be merged. and removed WIP Work in progress labels Jun 20, 2025
Copy link
Collaborator

@cooltey cooltey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I run ./gradlew ktlint to check the style, it showed me the following message:

ComposeColors.kt:1:1: File must end with a newline (\n) (standard:final-newline)
ComposeColors.kt:5:23: Trailing space(s) (standard:no-trailing-spaces)
WikipediaColor.kt:1:1: File must end with a newline (\n) (standard:final-newline)

Few thoughts:

  1. Can we make this script be able to execute directly without having the python in the command line to execute it? For example, I can run bump-version-code directly.
  2. Would it be possible to include some print event so that we can make sure the script is running in process?

@Williamrai
Copy link
Collaborator Author

When I run ./gradlew ktlint to check the style, it showed me the following message:

ComposeColors.kt:1:1: File must end with a newline (\n) (standard:final-newline)
ComposeColors.kt:5:23: Trailing space(s) (standard:no-trailing-spaces)
WikipediaColor.kt:1:1: File must end with a newline (\n) (standard:final-newline)

Few thoughts:

  1. Can we make this script be able to execute directly without having the python in the command line to execute it? For example, I can run bump-version-code directly.
  2. Would it be possible to include some print event so that we can make sure the script is running in process?
  1. I added#!/usr/bin/envpython at the top so we can run the script directly as scripts/generate-codex-colors.py without needing to prepend it with python.
  2. added

Copy link
Collaborator

@cooltey cooltey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script works for me (even on Windows!), but I noticed the script will generate the ComposeColors in the compose/theme package. Is this something expected?

@Williamrai
Copy link
Collaborator Author

The script works for me (even on Windows!), but I noticed the script will generate the ComposeColors in the compose/theme package. Is this something expected?

Nope that's not expected, i updated the file path. Thank you for pointing this out.

Copy link
Collaborator

@cooltey cooltey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good to me now.

Copy link
Member

@dbrant dbrant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great - just a minor issue.
Also, since this script already starts to generate WikipediaColor.kt, do you think you could make it generate LightColors and maybe even DarkColors?

Williamrai and others added 2 commits June 25, 2025 11:51
- generates raw color, WikipediaColor data class and also light and dark mode color
@Williamrai Williamrai requested review from dbrant and cooltey June 25, 2025 15:52
@dbrant dbrant removed the request for review from voyagerfan July 2, 2025 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready to merge PR passed design signoff and ready to be merged.
Development

Successfully merging this pull request may close these issues.

3 participants