Skip to content
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

Generate the Semantic Colours as class members in Swift. #86

Merged
merged 4 commits into from
Jul 9, 2024

Conversation

pixlwave
Copy link
Member

@pixlwave pixlwave commented Jul 9, 2024

The PR makes 2 changes to the Swift colour token generation (and can be reviewed commit-by-commit):

  • Strips the color prefix from the colour tokens given they're all namespaced anyway.
  • Splits up the generated Core/Semantic tokens and uses class members for the Semantic tokens instead of them being static.

import: ["SwiftUI"],
objectType: "class",
accessControl: "public",
referenceClass: "CompoundCoreColorTokens"
Copy link
Member Author

Choose a reason for hiding this comment

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

This is somewhat of a hack…

}).join('\n')
%>

<%= options.accessControl %> <%= options.objectType %> <%= file.className %> {
<%= allProperties.map(function(prop) {
return options.accessControl + ' let ' + formatProperty(prop);
let formatted = formatProperty(prop);
if (options.referenceClass) {
Copy link
Member Author

Choose a reason for hiding this comment

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

… but it works well enough to access the references from the correct class.

Comment on lines +318 to +319
public static let bgSubtleSecondaryLevel0 = themeBg
public static let bgCanvasDefaultLevel1 = gray300
Copy link
Member Author

Choose a reason for hiding this comment

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

These 2 aren't used in the app as they're asymmetric and we still need to figure out how to generate them correctly.

Copy link
Member

@robintown robintown left a comment

Choose a reason for hiding this comment

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

Looks good, and sorry that these little things aren't caught automatically by a linter. Hopefully I can get linting set up today!

src/transforms/swift/tokenTICamel.ts Outdated Show resolved Hide resolved
src/configs/getIOSConfig.ts Outdated Show resolved Hide resolved
pixlwave and others added 2 commits July 9, 2024 16:46
Co-authored-by: Robin <robin@robin.town>
Co-authored-by: Robin <robin@robin.town>
@pixlwave pixlwave merged commit b1e0643 into main Jul 9, 2024
@pixlwave pixlwave deleted the doug/colours-as-class-members branch July 9, 2024 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants