Skip to content

Commit df9afc7

Browse files
authored
feat(table): components theming with CSS-vars (#DS-2843) (#275)
1 parent 5977376 commit df9afc7

File tree

9 files changed

+53
-21
lines changed

9 files changed

+53
-21
lines changed

docs/guides/theming-2.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
- [icon-item](/packages/components/icon/icon-item-tokens.scss)
7171
- [input](/packages/components/input/input-tokens.scss)
7272
- [link](/packages/components/link/link-tokens.scss)
73+
- [table](/packages/components/table/table-tokens.scss)
7374
- [toast](/packages/components/toast/toast-tokens.scss)
7475
- [toggle](/packages/components/toggle/toggle-tokens.scss)
7576

packages/components/badge/badge-tokens.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@
100100
--kbq-badge-outline-fade-on-theme-icon: hsla(216, 100%, 50%, 100%);
101101
--kbq-badge-outline-fade-on-contrast-background: transparent;
102102
--kbq-badge-outline-fade-on-contrast-color: hsla(229, 15%, 15%, 100%);
103-
--kbq-badge-outline-fade-on-contrast-border: hsla(229, 15%, 80%, 100%);
103+
--kbq-badge-outline-fade-on-contrast-border: hsla(229, 15%, 70%, 100%);
104104
--kbq-badge-outline-fade-on-contrast-caption: hsla(229, 15%, 15%, 100%);
105105
--kbq-badge-outline-fade-on-contrast-icon: hsla(229, 15%, 60%, 100%);
106106
--kbq-badge-outline-fade-on-success-background: transparent;

packages/components/core/styles/_koobiq-theme.scss

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
@use '../../tooltip/tooltip-theme' as *;
3131
@use '../../tree-select/tree-select-theme' as *;
3232
@use '../../tree/tree-theme' as *;
33-
@use '../../table/table-theme' as *;
3433
@use '../forms/forms-theme' as *;
3534
@use '../option/option-theme' as *;
3635
@use '../option/optgroup-theme' as *;
@@ -73,7 +72,6 @@
7372
@include kbq-tooltip-theme($theme);
7473
@include kbq-tree-select-theme($theme);
7574
@include kbq-tree-theme($theme);
76-
@include kbq-table-theme($theme);
7775
}
7876

7977
@mixin koobiq-typography($tokens, $config: null, $md-config: null) {
@@ -113,7 +111,6 @@
113111
@include kbq-tooltip-typography($config);
114112
@include kbq-tree-select-typography($config);
115113
@include kbq-tree-typography($config);
116-
@include kbq-table-typography($config);
117114

118115
@include kbq-markdown-typography($md-config);
119116
}

packages/components/table/_table-theme.scss

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,27 @@
11
@use 'sass:meta';
22
@use 'sass:map';
33

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

7-
@mixin kbq-table-theme($theme) {
8-
$foreground: map.get($theme, foreground);
9-
$states-background: map.get($theme, states, background);
10-
$line: map.get($theme, line);
11-
6+
@mixin kbq-table-theme() {
127
.kbq-table {
138
& > thead {
14-
color: kbq-css-variable(foreground-contrast-secondary, map.get($foreground, contrast-secondary));
9+
color: kbq-css-variable(foreground-contrast-secondary);
1510

1611
& > tr > th {
17-
border-bottom-color: kbq-css-variable(line-contrast-less, map.get($line, contrast-less));
12+
border-bottom-color: kbq-css-variable(line-contrast-less);
1813
}
1914
}
2015

2116
& > tbody {
2217
& > tr {
2318
& > th,
2419
& > td {
25-
color: kbq-css-variable(foreground-contrast, map.get($foreground, contrast));
20+
color: kbq-css-variable(foreground-contrast);
2621
}
2722

2823
&:hover td {
29-
background-color: kbq-css-variable(
30-
states-background-transparent-hover,
31-
map.get($states-background, transparent-hover)
32-
);
24+
background-color: kbq-css-variable(states-background-transparent-hover);
3325
}
3426
}
3527
}
@@ -38,14 +30,14 @@
3830
& > tbody > tr {
3931
& th,
4032
& td {
41-
border-bottom-color: kbq-css-variable(line-contrast-less, map.get($line, contrast-less));
33+
border-bottom-color: kbq-css-variable(line-contrast-less);
4234
}
4335
}
4436
}
4537
}
4638
}
4739

48-
@mixin kbq-table-typography($config) {
40+
@mixin kbq-table-typography() {
4941
.kbq-table {
5042
& > thead {
5143
& > tr > th {
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
.kbq-table {
2+
--kbq-table-size-border-width: 1px;
3+
--kbq-table-size-row-padding-vertical: 10px;
4+
--kbq-table-size-row-padding-horizontal: 8px;
5+
--kbq-table-font-header-font-size: 14px;
6+
--kbq-table-font-header-line-height: 20px;
7+
--kbq-table-font-header-letter-spacing: -0.006em;
8+
--kbq-table-font-header-font-weight: normal;
9+
--kbq-table-font-header-font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial,
10+
sans-serif;
11+
--kbq-table-font-header-text-transform: null;
12+
--kbq-table-font-header-font-feature-settings: 'calt', 'kern', 'liga', 'ss01', 'ss04';
13+
--kbq-table-font-body-font-size: 14px;
14+
--kbq-table-font-body-line-height: 20px;
15+
--kbq-table-font-body-letter-spacing: -0.006em;
16+
--kbq-table-font-body-font-weight: normal;
17+
--kbq-table-font-body-font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial,
18+
sans-serif;
19+
--kbq-table-font-body-text-transform: null;
20+
--kbq-table-font-body-font-feature-settings: 'calt', 'ss01', 'ss04', 'tnum';
21+
}
22+
23+
:where(.kbq-light, .theme-light, .kbq-theme-light) {
24+
--kbq-foreground-contrast: hsla(229, 15%, 15%, 100%);
25+
--kbq-foreground-contrast-secondary: hsla(229, 15%, 50%, 100%);
26+
--kbq-foreground-contrast-tertiary: hsla(229, 15%, 60%, 100%);
27+
--kbq-line-contrast-less: hsla(229, 15%, 6%, 12%);
28+
--kbq-states-background-transparent-hover: hsla(229, 15%, 50%, 8%);
29+
}
30+
31+
:where(.kbq-dark, .theme-dark, .kbq-theme-dark) {
32+
--kbq-foreground-contrast: hsla(229, 15%, 80%, 100%);
33+
--kbq-foreground-contrast-secondary: hsla(229, 15%, 60%, 100%);
34+
--kbq-foreground-contrast-tertiary: hsla(229, 15%, 45%, 100%);
35+
--kbq-line-contrast-less: hsla(229, 15%, 22%, 100%);
36+
--kbq-states-background-transparent-hover: hsla(229, 15%, 50%, 16%);
37+
}

packages/components/table/table.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { KbqButton } from '@koobiq/components/button';
44
@Component({
55
selector: 'table[kbq-table]',
66
exportAs: 'kbqTable',
7-
styleUrls: ['table.scss'],
7+
styleUrls: ['table.scss', 'table-tokens.scss'],
88
template: '<ng-content />',
99
host: {
1010
class: 'kbq-table',

packages/components/table/table.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

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

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

88
.kbq-table {
99
border-spacing: 0;
@@ -73,3 +73,6 @@ $tokens: meta.module-variables(tokens) !default;
7373
}
7474
}
7575
}
76+
77+
@include kbq-table-theme();
78+
@include kbq-table-typography();

tools/tokens/build-each-component.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const componentsWithCss = [
3030
'icon-item',
3131
'input',
3232
'link',
33+
'table',
3334
'toast',
3435
'toggle'
3536
];

tools/tokens/utils.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const filter = {
99
datepicker: 'states-foreground-disabled',
1010
dropdown: ['kbq-list', 'foreground-contrast-secondary'],
1111
'icon-button': 'states-focused-color',
12+
table: ['states-background-transparent-hover', 'line-contrast-less', 'foreground-contrast'],
1213
toggle: 'foreground-text-disabled'
1314
};
1415

0 commit comments

Comments
 (0)