-
Notifications
You must be signed in to change notification settings - Fork 3
feat(alert,visual): theming with CSS variables (#DS-2679) #208
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
19b9627
feat(visual): theming with CSS variables (#DS-2679)
NikGurev 4330b82
feat(visual): removed unused arg for style mixin
NikGurev 4a38f71
feat(visual): use css tokens for alert, updated selectors in css file…
NikGurev 73c7bcc
feat(visual): removed back prebuilt usage
NikGurev 1d081bf
feat(visual): added task id for tech debt
NikGurev 30d2d11
feat(visual): removed unnecessary comment
NikGurev c259de4
feat(visual): added guide for new components with css vars only, reve…
NikGurev 98aa7ce
feat(visual): updated new theming guide, used default theme selector …
NikGurev 84d0d62
feat(chore): updated link for common module error
NikGurev 93da721
feat(docs): updated migration guide for components with CSS theming
NikGurev e3fe513
feat(alert): removed alert from koobiq-theme
NikGurev 49f579c
feat(docs): rewrote text
NikGurev dc8c489
feat(docs): rewrote text
NikGurev a44798b
feat(docs): text review
NikGurev 754c14c
feat(docs): added link to alert
NikGurev 84d6ac9
feat(docs): changed to relative for themeService
NikGurev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
### Что нового? | ||
|
||
Теперь использование компонентов стало проще! Мы движемся к полной изоляции компонентов, что позволит вам легко подключать и использовать их. Кроме того, мы убрали необходимость пробрасывать токены для задания цветов компонентам. | ||
|
||
### Как использовать? | ||
|
||
1. Импортируйте компонент | ||
2. Добавьте `kbq-theme-light` селектор к элементу `<body>` вашего HTML-документа для использования светлой темы и `kbq-theme-dark` для темной темы. | ||
|
||
Для переключения тем используйте [ThemeService.](/packages/components/core/services/theme.service.ts) | ||
|
||
### Доступные селекторы для темной и светлой темы | ||
|
||
Вот таблица доступных селекторов для темной и светлой тем: | ||
|
||
| Тема | Селекторы | | ||
| ------- | ------------------------------------------ | | ||
| Темная | .kbq-dark, .theme-dark, .kbq-theme-dark | | ||
| Светлая | .kbq-light, .theme-light, .kbq-theme-light | | ||
|
||
Мы рекомендуем использовать те селекторы, которые указаны в сервисе `ThemeService` (`kbq-theme-dark` для темной и `kbq-theme-light` для светлой). | ||
|
||
### Как задать кастомные значения компоненту дизайн-системы? | ||
|
||
Изменить цвета, размеры и шрифты можно задав соответствующие значения CSS-переменным компонента. | ||
Например: | ||
|
||
```css | ||
.kbq-theme-dark { | ||
--kbq-alert-default-contrast-container-background: custom-color; | ||
--kbq-alert-default-contrast-container-title: custom-color; | ||
} | ||
``` | ||
|
||
### Совместимость | ||
|
||
Работает стабильно с `@koobiq/design-tokens@3.4.0`. | ||
|
||
### Как применить уже имеющиеся кастомные дизайн-токены? | ||
|
||
Темы, где значения дизайн-токенов были перезаписаны с помощью Style-Dictionary, | ||
применяются аналогично [заданию кастомных значений компонентам.](#как-задать-кастомные-значения-компоненту-дизайн-системы) | ||
|
||
### Нужно ли что-то делать, если уже используются CSS-переменные из пакета @koobiq/design-tokens? | ||
|
||
Да, необходимо удалить CSS-переменные для компонентов, которые уже используют стандартные значения из коробки. | ||
|
||
В каких файлы необходимо внести изменения: | ||
|
||
- css-tokens.css - размеры компонента | ||
- css-tokens-light.css - цвета компонента для светлой темы | ||
- css-tokens-dark.css - цвета компонента для темной темы | ||
- css-tokens-font.css - шрифт, его размеры и параметры для компонента | ||
|
||
Для каких компонентов удалить CSS-переменные (в них используются значения по умолчанию): | ||
|
||
- [alert](/packages/components/alert/alert-tokens.scss) | ||
|
||
### Откуда теперь брать значения дизайн-токенов для компонентов? | ||
|
||
Все актуальные значения для компонентов хранятся в репозитории [@koobiq/design-tokens](https://github.com/koobiq/design-tokens). | ||
Сгенерированные на основе дизайн-токенов CSS-переменные компонентов позволяют сделать их использование более удобным, а также ускорить их разработку, в том числе проведение дизайн-ревью. | ||
|
||
### Что планируется сделать дальше? | ||
|
||
Мы планируем применить эти улучшения ко всем компонентам и использовать семантические значения для CSS-переменных компонентов, такие как `var(--kbq-size-m)` вместо `12px`. | ||
Это сделает код более читаемым и поддерживаемым. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
.kbq-alert { | ||
--kbq-alert-size-normal-container-border-radius: 12px; | ||
--kbq-alert-size-normal-container-padding-top: 0; | ||
--kbq-alert-size-normal-container-padding-right: 8px; | ||
--kbq-alert-size-normal-container-padding-bottom: 0; | ||
--kbq-alert-size-normal-container-padding-left: 8px; | ||
--kbq-alert-size-normal-content-padding-top: 16px; | ||
--kbq-alert-size-normal-content-padding-right: 8px; | ||
--kbq-alert-size-normal-content-padding-bottom: 16px; | ||
--kbq-alert-size-normal-content-padding-left: 12px; | ||
--kbq-alert-size-normal-icon-margin-top: 16px; | ||
--kbq-alert-size-normal-icon-margin-right: 0; | ||
--kbq-alert-size-normal-icon-margin-bottom: 16px; | ||
--kbq-alert-size-normal-icon-margin-left: 12px; | ||
--kbq-alert-size-normal-icon-padding-top: 4px; | ||
--kbq-alert-size-normal-title-margin-bottom: 4px; | ||
--kbq-alert-size-normal-close-button-margin-top: 8px; | ||
--kbq-alert-size-normal-close-button-margin-left: 2px; | ||
--kbq-alert-size-normal-button-stack-padding-top: 8px; | ||
--kbq-alert-size-normal-button-stack-padding-bottom: 2px; | ||
--kbq-alert-size-normal-no-title-icon-margin-top: 16px; | ||
--kbq-alert-size-normal-no-title-icon-padding-top: 2px; | ||
--kbq-alert-size-compact-container-border-radius: 12px; | ||
--kbq-alert-size-compact-container-padding-top: 0; | ||
--kbq-alert-size-compact-container-padding-right: 8px; | ||
--kbq-alert-size-compact-container-padding-bottom: 0; | ||
--kbq-alert-size-compact-container-padding-left: 16px; | ||
--kbq-alert-size-compact-content-padding-top: 12px; | ||
--kbq-alert-size-compact-content-padding-right: 8px; | ||
--kbq-alert-size-compact-content-padding-bottom: 12px; | ||
--kbq-alert-size-compact-content-padding-left: 0; | ||
--kbq-alert-size-compact-icon-margin-top: 12px; | ||
--kbq-alert-size-compact-icon-margin-right: 8px; | ||
--kbq-alert-size-compact-icon-padding-top: 4px; | ||
--kbq-alert-size-compact-title-margin-bottom: 2px; | ||
--kbq-alert-size-compact-close-button-margin-top: 8px; | ||
--kbq-alert-size-compact-close-button-margin-left: 2px; | ||
--kbq-alert-size-compact-button-stack-padding-top: 8px; | ||
--kbq-alert-size-compact-button-stack-padding-bottom: 2px; | ||
--kbq-alert-size-compact-no-title-icon-margin-top: 12px; | ||
--kbq-alert-size-compact-no-title-icon-padding-top: 2px; | ||
--kbq-alert-font-title-font-size: 18px; | ||
--kbq-alert-font-title-line-height: 26px; | ||
--kbq-alert-font-title-letter-spacing: normal; | ||
--kbq-alert-font-title-font-weight: 600; | ||
--kbq-alert-font-title-font-family: 'TT-Positive', Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', | ||
'Helvetica Neue', Arial, sans-serif; | ||
--kbq-alert-font-title-text-transform: null; | ||
--kbq-alert-font-title-font-feature-settings: 'calt', 'kern', 'liga'; | ||
--kbq-alert-font-title-compact-font-size: 16px; | ||
--kbq-alert-font-title-compact-line-height: 24px; | ||
--kbq-alert-font-title-compact-letter-spacing: -0.011em; | ||
--kbq-alert-font-title-compact-font-weight: 600; | ||
--kbq-alert-font-title-compact-font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', | ||
Arial, sans-serif; | ||
--kbq-alert-font-title-compact-text-transform: null; | ||
--kbq-alert-font-title-compact-font-feature-settings: 'calt', 'kern', 'liga', 'ss01', 'ss04'; | ||
--kbq-alert-font-text-font-size: 14px; | ||
--kbq-alert-font-text-line-height: 20px; | ||
--kbq-alert-font-text-letter-spacing: -0.006em; | ||
--kbq-alert-font-text-font-weight: normal; | ||
--kbq-alert-font-text-font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, | ||
sans-serif; | ||
--kbq-alert-font-text-text-transform: null; | ||
--kbq-alert-font-text-font-feature-settings: 'calt', 'kern', 'liga', 'ss01', 'ss04'; | ||
} | ||
|
||
:where(.kbq-light, .theme-light, .kbq-theme-light) { | ||
--kbq-alert-default-contrast-container-background: hsla(229, 15%, 92%, 100%); | ||
--kbq-alert-default-contrast-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-default-contrast-container-text: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-default-error-container-background: hsla(229, 15%, 92%, 100%); | ||
--kbq-alert-default-error-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-default-error-container-text: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-default-warning-container-background: hsla(229, 15%, 92%, 100%); | ||
--kbq-alert-default-warning-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-default-warning-container-text: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-default-success-container-background: hsla(229, 15%, 92%, 100%); | ||
--kbq-alert-default-success-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-default-success-container-text: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-default-theme-container-background: hsla(229, 15%, 92%, 100%); | ||
--kbq-alert-default-theme-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-default-theme-container-text: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-contrast-container-background: hsla(229, 15%, 92%, 100%); | ||
--kbq-alert-colored-contrast-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-contrast-container-text: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-error-container-background: hsla(7, 97%, 90%, 100%); | ||
--kbq-alert-colored-error-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-error-container-text: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-warning-container-background: hsla(38, 100%, 85%, 100%); | ||
--kbq-alert-colored-warning-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-warning-container-text: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-success-container-background: hsla(104, 64%, 80%, 100%); | ||
--kbq-alert-colored-success-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-success-container-text: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-theme-container-background: hsla(216, 100%, 85%, 100%); | ||
--kbq-alert-colored-theme-container-title: hsla(229, 15%, 15%, 100%); | ||
--kbq-alert-colored-theme-container-text: hsla(229, 15%, 15%, 100%); | ||
} | ||
|
||
:where(.kbq-dark, .theme-dark, .kbq-theme-dark) { | ||
--kbq-alert-default-contrast-container-background: hsla(229, 15%, 25%, 100%); | ||
--kbq-alert-default-contrast-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-default-contrast-container-text: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-default-error-container-background: hsla(229, 15%, 25%, 100%); | ||
--kbq-alert-default-error-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-default-error-container-text: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-default-warning-container-background: hsla(229, 15%, 25%, 100%); | ||
--kbq-alert-default-warning-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-default-warning-container-text: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-default-success-container-background: hsla(229, 15%, 25%, 100%); | ||
--kbq-alert-default-success-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-default-success-container-text: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-default-theme-container-background: hsla(229, 15%, 25%, 100%); | ||
--kbq-alert-default-theme-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-default-theme-container-text: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-contrast-container-background: hsla(229, 15%, 25%, 100%); | ||
--kbq-alert-colored-contrast-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-contrast-container-text: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-error-container-background: hsla(7, 97%, 15%, 100%); | ||
--kbq-alert-colored-error-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-error-container-text: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-warning-container-background: hsla(38, 100%, 14%, 100%); | ||
--kbq-alert-colored-warning-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-warning-container-text: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-success-container-background: hsla(104, 64%, 12%, 100%); | ||
--kbq-alert-colored-success-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-success-container-text: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-theme-container-background: hsla(216, 100%, 20%, 100%); | ||
--kbq-alert-colored-theme-container-title: hsla(229, 15%, 80%, 100%); | ||
--kbq-alert-colored-theme-container-text: hsla(229, 15%, 80%, 100%); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
"инпуте", | ||
"кастомизируемых", | ||
"кастомное", | ||
"кастомные", | ||
"кликает", | ||
"контрол", | ||
"контролам", | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.