Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Component Token Naming #3356

Closed
gfellerph opened this issue Jul 30, 2024 · 2 comments
Closed

Component Token Naming #3356

gfellerph opened this issue Jul 30, 2024 · 2 comments

Comments

@gfellerph
Copy link
Member

In the component token layer (currently exported as one sass file with two maps), components are not consistently named. Notifications and Buttons are two components, but Button tokens are nested in a list mixed with other interactive components while Notification tokens live in their own list.

/** Content of the maps is shortened for demo purposes */
$post-interactives: (
  'post-comp-interactive-color-primary-bg-enabled': var(--post-sem-color-interactive-primary-enabled-bg),
  'post-comp-interactive-button-primary-color-fg-enabled': var(--post-sem-color-interactive-button-primary-enabled-fg),
);

$post-notifications: (
  'post-comp-notification-color-bg-badge': var(--post-sem-color-notification-badge-bg)
);

Potential issues

This approach makes it hard for developers looking at the exported sass files to determine what components the tokens should be used for (are Tabs "interactive"?). While it's possible to look up tokens used in Figma Dev Mode, it's not a guarantee to catch all tokens, especially in deeply nested components. There's no overview of what tokens are used for this component when the outer layer is selected. With the Figma approach, it's easy to miss tokens.

The danger of component tokens that need renaming is also higher when we use shared component names. A renamed component token will most likely be a breaking change for development because they will be documented in Storybook (adding more component tokens would be features, removing component tokens would be a breaking change also).

Proposed solution

Component tokens are the most important interfacing point between Figma and Code. Therefore naming and consistency are most important in this area.

Consistent naming

The naming schema should be consistent across the whole token system.

// Component layer: [namespace] [layer] [group] [component] [variant] [property group] [property] [state]
// Semantic layer:  [namespace] [layer] [property group] [group] [component] [variant] [state] [property]
'post-comp-interactive-button-primary-color-fg-enabled': var(--post-sem-color-interactive-button-primary-enabled-fg),

Naming schema

For component tokens, especially the development will profit from short, memorable token names. Unnecessary categorization should be omitted. The layer naming (-comp-) is good to have an overview in the token system, but is irrelevant to end users of tokens because the only thing they should interact with are the component tokens. As for the grouping of component tokens, it does not provide any benefit if every component has it's own collection of tokens.

/* Comp interactive could be left out */
--post-comp-interactive-button-primary-color-fg-enabled

--post-button-primary-color-fg-enabled

Sass output

Ideally, each component will generate a list of tokens available for this component. This makes it possible to iterate over existing tokens not only in the Styles, but also in the documentation. If lists with tokens for multiple components are used, it's not possible to assign the tokens used to a specific component.

$post-textfield: (
  'post-comp-interactive-textfield-primary-color-bg-enabled': var(--post-sem-color-interactive-primary-enabled-bg),
);

$post-button: (
  'post-comp-interactive-button-primary-color-fg-enabled': var(--post-sem-color-interactive-button-primary-enabled-fg),
);

$post-notifications: (
  'post-comp-notification-color-bg-badge': var(--post-sem-color-notification-badge-bg)
);
@gfellerph gfellerph added 🔮 tokens needs: discussion There is at least one topic in the pattern descussion meeting about the issue labels Jul 30, 2024
This was referenced Aug 2, 2024
@gfellerph
Copy link
Member Author

Proposal accepted, need dev support for renaming.

@gfellerph
Copy link
Member Author

Added new state on the production board and moved affected tickets to this column. Moving to discussions for documentation purposes.

@gfellerph gfellerph removed the needs: discussion There is at least one topic in the pattern descussion meeting about the issue label Aug 22, 2024
@swisspost swisspost locked and limited conversation to collaborators Aug 22, 2024
@gfellerph gfellerph converted this issue into discussion #3450 Aug 22, 2024
@github-project-automation github-project-automation bot moved this from 👀 Triage to 🚀 Done in Design System Production Board Aug 22, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
Development

No branches or pull requests

1 participant