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

Why is typography.secondary explicitly placed before primary in the output CSS? #2562

Closed
unekinn opened this issue Oct 3, 2024 · 2 comments
Assignees
Labels
🕵️ investigate Needs investigation

Comments

@unekinn
Copy link
Contributor

unekinn commented Oct 3, 2024

In #2560 I found this sorting function used when concatenating the different generated css files into one entry file per theme.

const sortLightmodeFirst = R.sortWith<string>([R.descend(R.includes('light')), R.descend(R.includes('secondary'))]);

The PR changed this to a deterministic order:

const sortOrder = [
  'color-mode/light',
  'typography/secondary',
  'semantic',
  'color-mode/dark',
  'color-mode/contrast',
  'typography/primary',
];

This sort order keeps the brand css files unchanged from the existing commited files when running yarn build:tokens. But is there a reason for this exact ordering? The old sorting function would be equivalent to this:

const sortOrder = [
  'color-mode/light',
  'typography/secondary',
];

That is to say, these two would always come first, and then the rest in an unspecified — but usually the same — order.

However, wouldn't it make more sense for the things that are added to :root -- color-mode/light, typography/primary, and semantic, to be first, and then other color modes, then typography/secondary?

@unekinn
Copy link
Contributor Author

unekinn commented Nov 4, 2024

I will check if the order can now be

  'semantic',
  'color-mode/light',
  'color-mode/dark',
  'color-mode/contrast',
  'color/',
  'builtin-colors',
  'typography/primary',
  'typography/secondary',

There should be no conflicting rules that rely on the order of definition to ensure correctness, so I'm pretty sure this should work 😄

@mimarz
Copy link
Collaborator

mimarz commented Dec 9, 2024

I can't remember why, but it seems to still work fine now, so lets reopen this if it becomes a problem again :)

@mimarz mimarz closed this as completed Dec 9, 2024
@github-project-automation github-project-automation bot moved this from 🔵 Inbox to ✅ Done in Team Design System Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕵️ investigate Needs investigation
Projects
Status: ✅ Done
Development

No branches or pull requests

2 participants