Skip to content

Conversation

m-thompson-code
Copy link
Contributor

@m-thompson-code m-thompson-code commented Sep 12, 2025

  1. Updated process function to make node a required argument instead of an optional one. Simplified all uses
  2. Removed rounding when calculating rem. This resolves inconsistent styles where values are off. 1px -> 0.62rem is actually 0.992px and not 1px. 1px -> 0.625rem (which is 1px)
  3. Updated all unit tests to verify both template vs combinatorial styles
  4. Updated CSS transformer to handle template vs combinatorial styles, added type safety to prevent this issue in the future

Note: The snapshots doubled in size due to testing both template and combinatorial. So there's a lot of new lines added, but the core changes are still verifiable if you look pass all the added lines and just the changed lines

This comment has been minimized.

@@ -285,7 +285,7 @@ const tailwindClassGenerators: Record<string, Generator> = {
opacity: (token) => generateTailwindOpacityClass(token),
};

export function createTailwindClasses(tokens: NonNullableStyleToken[]): string[] {
export function createTailwindClasses(tokens: GeneratorToken[]): string[] {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

GeneratorToken is a subset of NonNullableStyleToken. Generators don't require all the properties that NonNullableStyleToken has, this will allow for easier refactor later.


const cssByVariantCombinations = generateCombinatorialStyles(mixins);
return Object.entries(cssByVariantCombinations).map(([, cssByVariantCombination]) => {
const path = cssByVariantCombination.path;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this original was a bug where all of the components within this component set shared the same path (implying they all had the same variant property and values)

Updated the flow to include path up until this point to correct this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a unit test to verify that this behavior stays this way

@@ -1,6 +1,6 @@
export interface PathNode {
name: string;
type: SceneNode['type'];
type: (BaseNode | (BaseNode & ChildrenMixin))['type'];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the actual type. We use SceneNode a lot in the code base through type assertion. We should find a type safe way to confirm this instead of casting.

unit: true,
};

const rounded = (value: number, precision: number): number => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rounding when converting from px to rem causes styling issues where things are off slightly:

1px -> 0.62rem is actually 0.992px and not 1px

without rounding we get the proper conversion:

1px -> 0.625rem (which is 1px)

@@ -66,11 +66,11 @@ $spacing-9: 0.48;
background: #ffffff;
opacity: 0.5;
}
@mixin opacity-custom-group_opacity-custom {
@mixin opacity-custom-group-opacity-custom {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

selectors using the default config (css and scss) only use _ for separating variant property and value. Shouldn't be used unless both are present.

@m-thompson-code m-thompson-code marked this pull request as ready for review September 12, 2025 21:58
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.

1 participant