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

feat(table): components theming with CSS-vars (#DS-2843) #275

Merged
merged 5 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/guides/theming-2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
- [icon-item](/packages/components/icon/icon-item-tokens.scss)
- [input](/packages/components/input/input-tokens.scss)
- [link](/packages/components/link/link-tokens.scss)
- [table](/packages/components/table/table-tokens.scss)

### Откуда теперь брать значения дизайн-токенов для компонентов?

Expand Down
2 changes: 1 addition & 1 deletion packages/components/badge/badge-tokens.scss
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
--kbq-badge-outline-fade-on-theme-icon: hsla(216, 100%, 50%, 100%);
--kbq-badge-outline-fade-on-contrast-background: transparent;
--kbq-badge-outline-fade-on-contrast-color: hsla(229, 15%, 15%, 100%);
--kbq-badge-outline-fade-on-contrast-border: hsla(229, 15%, 80%, 100%);
--kbq-badge-outline-fade-on-contrast-border: hsla(229, 15%, 70%, 100%);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
--kbq-badge-outline-fade-on-contrast-border: hsla(229, 15%, 70%, 100%);
--kbq-badge-outline-fade-on-contrast-border: hsla(229, 15%, 80%, 100%);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

вот тут не совсем понял, этот же файл с токенами сам генерится)

Copy link
Contributor

Choose a reason for hiding this comment

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

предлагаю просто ревертнуть, чтобы лишних изменений не было

--kbq-badge-outline-fade-on-contrast-caption: hsla(229, 15%, 15%, 100%);
--kbq-badge-outline-fade-on-contrast-icon: hsla(229, 15%, 60%, 100%);
--kbq-badge-outline-fade-on-success-background: transparent;
Expand Down
3 changes: 0 additions & 3 deletions packages/components/core/styles/_koobiq-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
@use '../../tooltip/tooltip-theme' as *;
@use '../../tree-select/tree-select-theme' as *;
@use '../../tree/tree-theme' as *;
@use '../../table/table-theme' as *;
@use '../forms/forms-theme' as *;
@use '../option/option-theme' as *;
@use '../option/optgroup-theme' as *;
Expand Down Expand Up @@ -79,7 +78,6 @@
@include kbq-tooltip-theme($theme);
@include kbq-tree-select-theme($theme);
@include kbq-tree-theme($theme);
@include kbq-table-theme($theme);
}

@mixin koobiq-typography($tokens, $config: null, $md-config: null) {
Expand Down Expand Up @@ -121,7 +119,6 @@
@include kbq-tooltip-typography($config);
@include kbq-tree-select-typography($config);
@include kbq-tree-typography($config);
@include kbq-table-typography($config);

@include kbq-markdown-typography($md-config);
}
22 changes: 7 additions & 15 deletions packages/components/table/_table-theme.scss
Original file line number Diff line number Diff line change
@@ -1,35 +1,27 @@
@use 'sass:meta';
@use 'sass:map';

@use '../core/styles/typography/typography-utils' as *;
@use '../core/styles/common/tokens' as *;

@mixin kbq-table-theme($theme) {
$foreground: map.get($theme, foreground);
$states-background: map.get($theme, states, background);
$line: map.get($theme, line);

@mixin kbq-table-theme() {
.kbq-table {
& > thead {
color: kbq-css-variable(foreground-contrast-secondary, map.get($foreground, contrast-secondary));
color: kbq-css-variable(foreground-contrast-secondary);

& > tr > th {
border-bottom-color: kbq-css-variable(line-contrast-less, map.get($line, contrast-less));
border-bottom-color: kbq-css-variable(line-contrast-less);
}
}

& > tbody {
& > tr {
& > th,
& > td {
color: kbq-css-variable(foreground-contrast, map.get($foreground, contrast));
color: kbq-css-variable(foreground-contrast);
}

&:hover td {
background-color: kbq-css-variable(
states-background-transparent-hover,
map.get($states-background, transparent-hover)
);
background-color: kbq-css-variable(states-background-transparent-hover);
}
}
}
Expand All @@ -38,14 +30,14 @@
& > tbody > tr {
& th,
& td {
border-bottom-color: kbq-css-variable(line-contrast-less, map.get($line, contrast-less));
border-bottom-color: kbq-css-variable(line-contrast-less);
}
}
}
}
}

@mixin kbq-table-typography($config) {
@mixin kbq-table-typography() {
.kbq-table {
& > thead {
& > tr > th {
Expand Down
37 changes: 37 additions & 0 deletions packages/components/table/table-tokens.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.kbq-table {
--kbq-table-size-border-width: 1px;
--kbq-table-size-row-padding-vertical: 10px;
--kbq-table-size-row-padding-horizontal: 8px;
--kbq-table-font-header-font-size: 14px;
--kbq-table-font-header-line-height: 20px;
--kbq-table-font-header-letter-spacing: -0.006em;
--kbq-table-font-header-font-weight: normal;
--kbq-table-font-header-font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial,
sans-serif;
--kbq-table-font-header-text-transform: null;
--kbq-table-font-header-font-feature-settings: 'calt', 'kern', 'liga', 'ss01', 'ss04';
--kbq-table-font-body-font-size: 14px;
--kbq-table-font-body-line-height: 20px;
--kbq-table-font-body-letter-spacing: -0.006em;
--kbq-table-font-body-font-weight: normal;
--kbq-table-font-body-font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial,
sans-serif;
--kbq-table-font-body-text-transform: null;
--kbq-table-font-body-font-feature-settings: 'calt', 'ss01', 'ss04', 'tnum';
}

:where(.kbq-light, .theme-light, .kbq-theme-light) {
--kbq-foreground-contrast: hsla(229, 15%, 15%, 100%);
--kbq-foreground-contrast-secondary: hsla(229, 15%, 50%, 100%);
--kbq-foreground-contrast-tertiary: hsla(229, 15%, 60%, 100%);
--kbq-line-contrast-less: hsla(229, 15%, 6%, 12%);
--kbq-states-background-transparent-hover: hsla(229, 15%, 50%, 8%);
}

:where(.kbq-dark, .theme-dark, .kbq-theme-dark) {
--kbq-foreground-contrast: hsla(229, 15%, 80%, 100%);
--kbq-foreground-contrast-secondary: hsla(229, 15%, 60%, 100%);
--kbq-foreground-contrast-tertiary: hsla(229, 15%, 45%, 100%);
--kbq-line-contrast-less: hsla(229, 15%, 22%, 100%);
--kbq-states-background-transparent-hover: hsla(229, 15%, 50%, 16%);
}
2 changes: 1 addition & 1 deletion packages/components/table/table.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { KbqButton } from '@koobiq/components/button';
@Component({
selector: 'table[kbq-table]',
exportAs: 'kbqTable',
styleUrls: ['table.scss'],
styleUrls: ['table.scss', 'table-tokens.scss'],
template: '<ng-content />',
host: {
class: 'kbq-table',
Expand Down
5 changes: 4 additions & 1 deletion packages/components/table/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

@use '../core/styles/common/tokens' as *;

$tokens: meta.module-variables(tokens) !default;
@use './table-theme' as *;

.kbq-table {
border-spacing: 0;
Expand Down Expand Up @@ -73,3 +73,6 @@ $tokens: meta.module-variables(tokens) !default;
}
}
}

@include kbq-table-theme();
@include kbq-table-typography();
3 changes: 2 additions & 1 deletion tools/tokens/build-each-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ const componentsWithCss = [
'icon-button',
'icon-item',
'input',
'link'
'link',
'table'
];

const styleDictionaryConfig = {
Expand Down
3 changes: 2 additions & 1 deletion tools/tokens/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const filter = {
'pseudo-checkbox': 'checkbox',
datepicker: 'states-foreground-disabled',
dropdown: ['kbq-list', 'foreground-contrast-secondary'],
'icon-button': 'states-focused-color'
'icon-button': 'states-focused-color',
table: ['states-background-transparent-hover', 'line-contrast-less', 'foreground-contrast']
};

const componentNameMapping = {
Expand Down