-
Notifications
You must be signed in to change notification settings - Fork 94
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
docs: Oryx design tokens #2025
docs: Oryx design tokens #2025
Changes from all commits
679ce2e
159ff20
fd01a3f
7d16c12
6b5aa9c
c79fc55
93913df
9bf0238
411115d
6176318
a8b916b
98ebdd5
d0c0211
1440fcb
d843ea0
1d1fc2c
db8c137
5247d3d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please, update this document in 202307.0 as well. |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you create a new document in 202212, not in 202307? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
title: "Oryx: Design tokens" | ||
description: Design tokens provide a centralized and consistent approach for styling components in Oryx applications. | ||
last_updated: July 24, 2023 | ||
template: concept-topic-template | ||
--- | ||
|
||
Design tokens provide a powerful system for achieving consistent and customizable styles throughout an Oryx application. They are extensively used inside the [color system](/docs/scos/dev/front-end-development/{{page.version}}/oryx/styling/oryx-color-system.html), typography, icons, and many more. Ensuring a clean separation between styles and components, design tokens make it easier to manage and maintain the application's design system. This document focuses on the structure and usage of design tokens in Oryx. | ||
|
||
## CSS variables | ||
|
||
Design tokens are provided as CSS variables in the application code. The variables follow a structured naming convention to ensure consistency. To avoid naming conflicts with third-party variables, they are prefixed with `oryx` and are written in kebab-case. | ||
|
||
The variables are written in the root element of the application, the `oryx-app` component by default. The variables are inherited by all descendants of the root component. This makes it convenient to access the variables throughout the entire application. At the same time, they can be overridden at any element in the application. | ||
|
||
If you like to reuse the variables outside the root element of the application, or if you are not using the `oryx-app` as the root, you can bootstrap the application using an alternative root: | ||
|
||
```ts | ||
import { appBuilder } from "@spryker-oryx/core"; | ||
|
||
appBuilder().withAppOptions({ components: { root: "body" } }); | ||
``` | ||
|
||
## Usage of design tokens | ||
|
||
Design tokens are used extensively throughout Oryx components to achieve a consistent and cohesive visual experience. Instead of hardcoding style values directly in component CSS, design tokens are used as CSS variables to define the styles. This way, you can easily change the visual appearance of the entire application by adjusting the corresponding design token values. | ||
|
||
The following example shows how to avoid hardcoded style values by using design tokens: | ||
|
||
```css | ||
.button { | ||
background-color: var(--oryx-color-primary-9); | ||
font-size: var(--oryx-typography-h1-size); | ||
} | ||
``` | ||
|
||
The CSS variables are inherited throughout all descendants, but you can override the value anywhere in the DOM tree. The following example shows how to override a design token anywhere in the DOM. | ||
|
||
```html | ||
<div style="--oryx-color-primary-9: red"> | ||
<button>Primary 9 color has become red</button> | ||
</div> | ||
``` | ||
|
||
## Themes | ||
|
||
Design tokens are organized in themes. The Oryx [preset package](/docs/scos/dev/front-end-development/{{page.version}}/oryx/oryx-presets.html) provides standard themes to get you started. You can use a standard theme, customize a standard theme, or create your own. | ||
|
||
<!-- TODO: add a note link to the theme docs once its ready --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add these changes to 202307 please