Skip to content

Commit bf8961d

Browse files
committed
feature(table): add sticky variables
1 parent 5100a1b commit bf8961d

File tree

1 file changed

+52
-16
lines changed

1 file changed

+52
-16
lines changed

src/assets/scss/components/_table.scss

Lines changed: 52 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
/* @docs */
2-
$table-head-bg: var(--#{$prefix}body-bg) !default;
2+
$table-head-bg: initial !default;
33
$table-head-color: initial !default;
44
$table-head-border-width: var(--#{$prefix}border-width) !default;
55
$table-sticky-zindex: 1 !default;
6+
$table-sticky-bg: initial !default;
7+
$table-sticky-color: initial !default;
68
$table-detail-padding: 0.5rem 0.75rem !default;
79
$table-detail-bg: var(--#{$prefix}gray-light) !default;
810
$table-sortable-hover-border-color: var(--#{$prefix}secondary) !default;
@@ -55,31 +57,62 @@ $table-card-spacer: $spacer;
5557
position: relative;
5658

5759
.table-wrapper {
58-
--#{$prefix}table-sticky-zindex: #{$table-sticky-zindex};
5960
--#{$prefix}table-sortable-hover-border-color: #{$table-sortable-hover-border-color};
6061
--#{$prefix}table-current-sort-bg: #{$table-current-sort-bg};
6162
--#{$prefix}table-focus-color: #{$table-focus-color};
6263

6364
.table {
65+
--#{$prefix}table-head-bg: #{$table-head-bg};
66+
--#{$prefix}table-head-color: #{$table-head-color};
67+
--#{$prefix}table-head-border-width: #{$table-head-border-width};
68+
--#{$prefix}table-sticky-zindex: #{$table-sticky-zindex};
69+
--#{$prefix}table-sticky-bg: #{$table-sticky-bg};
70+
--#{$prefix}table-sticky-color: #{$table-sticky-color};
71+
6472
th,
6573
td {
74+
vertical-align: middle;
75+
6676
&.sticky {
6777
position: -webkit-sticky;
6878
position: sticky;
6979
left: 0;
7080
z-index: var(--#{$prefix}table-sticky-zindex);
81+
--#{$prefix}table-accent-color: var(--#{$prefix}table-sticky-color);
82+
--#{$prefix}table-accent-bg: var(--#{$prefix}table-sticky-bg);
7183
}
7284
}
7385

74-
thead {
75-
--#{$prefix}table-head-bg: #{$table-head-bg};
76-
--#{$prefix}table-head-color: #{$table-head-color};
77-
--#{$prefix}table-head-border-width: #{$table-head-border-width};
86+
// override sticky hover values
87+
&.table-hover > tbody > tr:hover > .sticky {
88+
--#{$prefix}table-color-state: var(
89+
--#{$prefix}table-sticky-color,
90+
var(--#{$prefix}table-hover-color)
91+
);
92+
--#{$prefix}table-bg-state: var(
93+
--#{$prefix}table-sticky-bg,
94+
var(--#{$prefix}table-hover-bg)
95+
);
96+
}
97+
98+
// override sticky striped values
99+
&.table-striped > tbody > tr:nth-of-type(odd) > .sticky {
100+
--#{$prefix}table-color-type: var(
101+
--#{$prefix}table-sticky-color,
102+
var(--#{$prefix}table-striped-color)
103+
);
104+
--#{$prefix}table-bg-type: var(
105+
--#{$prefix}table-sticky-bg,
106+
var(--#{$prefix}table-striped-bg)
107+
);
108+
}
78109

110+
thead {
79111
th {
112+
--#{$prefix}table-color-state: var(--#{$prefix}table-head-color);
113+
--#{$prefix}table-bg-state: var(--#{$prefix}table-head-bg);
114+
80115
position: relative;
81-
color: var(--#{$prefix}table-head-color);
82-
background-color: var(--#{$prefix}table-head-bg);
83116
border-bottom-width: var(--#{$prefix}table-head-border-width);
84117

85118
&.sortable {
@@ -96,7 +129,7 @@ $table-card-spacer: $spacer;
96129
}
97130

98131
&.current-sort {
99-
--#{$prefix}table-bg: var(--#{$prefix}table-current-sort-bg);
132+
--#{$prefix}table-bg-type: var(--#{$prefix}table-current-sort-bg);
100133
}
101134

102135
.sort-icon {
@@ -106,14 +139,17 @@ $table-card-spacer: $spacer;
106139
}
107140
}
108141

109-
tr {
110-
&.table-detail {
111-
--#{$prefix}table-detail-bg: #{$table-detail-bg};
112-
--#{$prefix}table-detail-padding: #{$table-detail-padding};
142+
tbody {
143+
tr {
144+
&.table-detail {
145+
--#{$prefix}table-detail-bg: #{$table-detail-bg};
146+
--#{$prefix}table-detail-padding: #{$table-detail-padding};
113147

114-
td {
115-
background: var(--#{$prefix}table-detail-bg);
116-
padding: var(--#{$prefix}table-detail-padding);
148+
td {
149+
background-color: var(--#{$prefix}table-detail-bg);
150+
padding: var(--#{$prefix}table-detail-padding);
151+
box-shadow: unset;
152+
}
117153
}
118154
}
119155
}

0 commit comments

Comments
 (0)