Skip to content

Commit 76f3c62

Browse files
jnm2377tw15egankodiakhq[bot]
authored
fix(DataTable): expand + select padding (#8656)
* fix(DataTable): expand + select padding * fix: expand and select focus styles * fix: center checkbox * fix: checkbox focus size * chore: remove comment Co-authored-by: TJ Egan <tw15egan@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 70c4593 commit 76f3c62

File tree

3 files changed

+71
-19
lines changed

3 files changed

+71
-19
lines changed

packages/components/src/components/data-table/_data-table-core.scss

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -293,20 +293,37 @@
293293
// Select
294294
//----------------------------------------------------------------------------
295295
.#{$prefix}--table-column-checkbox .#{$prefix}--checkbox-label {
296-
padding-left: $spacing-05;
296+
padding-left: 0;
297297
}
298298

299299
.#{$prefix}--data-table th.#{$prefix}--table-column-checkbox {
300300
// Do not use `position: relative`, as its behavior is undefined for many table elements: https://www.w3.org/TR/CSS21/visuren.html#propdef-position
301301
position: static;
302-
// 16px padding left + 8px padding right + 20px checkbox width
303-
width: rem(44px);
304-
padding-right: $spacing-05;
305-
padding-left: $spacing-05;
302+
width: rem(32px);
306303
background: $layer-accent;
307304
transition: background-color $duration--fast-01 motion(entrance, productive);
308305
}
309306

307+
.#{$prefix}--data-table
308+
.#{$prefix}--table-column-checkbox
309+
.#{$prefix}--checkbox:focus
310+
+ .#{$prefix}--checkbox-label::before {
311+
//make checkbox focus larger to match expansion btn focus
312+
outline-offset: rem(6px);
313+
}
314+
315+
.#{$prefix}--data-table--compact
316+
.#{$prefix}--table-column-checkbox
317+
.#{$prefix}--checkbox:focus
318+
+ .#{$prefix}--checkbox-label::before,
319+
.#{$prefix}--data-table--xs
320+
.#{$prefix}--table-column-checkbox
321+
.#{$prefix}--checkbox:focus
322+
+ .#{$prefix}--checkbox-label::before {
323+
//make checkbox match expansion button focus size
324+
outline-offset: rem(2px);
325+
}
326+
310327
.#{$prefix}--data-table thead th.#{$prefix}--table-column-checkbox,
311328
.#{$prefix}--data-table tbody td.#{$prefix}--table-column-checkbox,
312329
.#{$prefix}--data-table thead th.#{$prefix}--table-expand,
@@ -316,18 +333,15 @@
316333

317334
.#{$prefix}--data-table thead th.#{$prefix}--table-column-checkbox,
318335
.#{$prefix}--data-table tbody td.#{$prefix}--table-column-checkbox {
319-
// 16px padding left + 20px checkbox width
320-
width: rem(16px);
321-
// spacing between checkbox / chevron and next cell should be 16px / 1rem
322-
// adjacent cell has 16px / 1rem padding-left though, hence the removal of padding-right here
323-
padding-right: $spacing-05;
324-
padding-left: $spacing-05;
336+
// spacing between checkbox / chevron and next cell should be 8px / 0.5rem
337+
padding-right: rem(4px);
338+
padding-left: 1rem;
325339
}
326340

327341
.#{$prefix}--data-table thead th.#{$prefix}--table-expand,
328342
.#{$prefix}--data-table tbody td.#{$prefix}--table-expand {
329-
width: rem(48px);
330-
height: rem(48px);
343+
width: rem(32px);
344+
height: rem(32px);
331345
}
332346

333347
// V11: Remove compact
@@ -337,6 +351,7 @@
337351
.#{$prefix}--data-table--xs tbody td.#{$prefix}--table-expand {
338352
width: rem(24px);
339353
height: rem(24px);
354+
padding: 0 0 0 0.5rem;
340355
}
341356

342357
// V11: remove short
@@ -346,12 +361,15 @@
346361
.#{$prefix}--data-table--sm tbody td.#{$prefix}--table-expand {
347362
width: rem(32px);
348363
height: rem(32px);
364+
padding: 0;
365+
padding-left: 0.5rem;
349366
}
350367

351368
.#{$prefix}--data-table--md thead th.#{$prefix}--table-expand,
352369
.#{$prefix}--data-table--md tbody td.#{$prefix}--table-expand {
353370
width: rem(40px);
354371
height: rem(40px);
372+
padding: rem(4px) 0 rem(4px) rem(8px);
355373
}
356374

357375
// V11: remove tall
@@ -360,6 +378,8 @@
360378
.#{$prefix}--data-table--xl thead th.#{$prefix}--table-expand,
361379
.#{$prefix}--data-table--xl tbody td.#{$prefix}--table-expand {
362380
height: rem(64px);
381+
padding-top: rem(10px);
382+
padding-bottom: rem(22px);
363383
}
364384

365385
// V11: remove tall

packages/components/src/components/data-table/_data-table-expandable.scss

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,25 @@
170170
.#{$prefix}--data-table
171171
td.#{$prefix}--table-expand
172172
+ .#{$prefix}--table-column-checkbox {
173-
padding-right: 0;
173+
padding-right: rem(6px);
174+
padding-left: rem(6px);
175+
}
176+
177+
.#{$prefix}--data-table
178+
th.#{$prefix}--table-expand
179+
+ .#{$prefix}--table-column-checkbox
180+
+ th,
181+
.#{$prefix}--data-table
182+
td.#{$prefix}--table-expand
183+
+ .#{$prefix}--table-column-checkbox
184+
+ td {
185+
padding-left: rem(8px);
174186
}
175187

176188
.#{$prefix}--data-table td.#{$prefix}--table-expand,
177189
.#{$prefix}--data-table th.#{$prefix}--table-expand {
178-
padding: 0;
190+
padding: 0.5rem;
191+
padding-right: 0;
179192
}
180193

181194
.#{$prefix}--data-table
@@ -198,7 +211,7 @@
198211
height: calc(100% + 1px);
199212
align-items: center;
200213
justify-content: center;
201-
padding: 0 1rem;
214+
padding: 0 0.5rem;
202215
vertical-align: inherit;
203216
}
204217

@@ -216,8 +229,8 @@
216229
// V11: remove tall
217230
.#{$prefix}--data-table--tall .#{$prefix}--table-expand__button,
218231
.#{$prefix}--data-table--xl .#{$prefix}--table-expand__button {
219-
padding-top: rem(16px);
220-
padding-bottom: rem(24px);
232+
width: rem(32px);
233+
padding: 0;
221234
}
222235

223236
// fix expanded parent separating border length

packages/react/src/components/DataTable/stories/dynamic-content/DataTable-dynamic-content-story.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import './story.scss';
99

1010
import React from 'react';
11+
import { withKnobs, select } from '@storybook/addon-knobs';
1112
import {
1213
Delete16 as Delete,
1314
Save16 as Save,
@@ -36,8 +37,25 @@ import DataTable, {
3637
} from '../../../DataTable';
3738
import { batchActionClick, rows, headers } from '../shared';
3839

40+
const sizes = {
41+
Compact: 'compact',
42+
Short: 'short',
43+
Medium: 'md',
44+
Default: null,
45+
Tall: 'tall',
46+
};
47+
48+
const tableProps = {
49+
sizeProp: () => {
50+
return {
51+
size: select('Row size (size)', sizes, null),
52+
};
53+
},
54+
};
55+
3956
export default {
4057
title: 'Components/DataTable/Development',
58+
decorators: [withKnobs],
4159
};
4260

4361
export const Example = (props) => {
@@ -102,6 +120,7 @@ export const Example = (props) => {
102120
};
103121

104122
render() {
123+
const sizeProp = tableProps.sizeProp();
105124
return (
106125
<DataTable
107126
rows={this.state.rows}
@@ -157,7 +176,7 @@ export const Example = (props) => {
157176
</TableToolbarMenu>
158177
</TableToolbarContent>
159178
</TableToolbar>
160-
<Table {...getTableProps()}>
179+
<Table {...getTableProps()} {...sizeProp}>
161180
<TableHead>
162181
<TableRow>
163182
<TableExpandHeader />

0 commit comments

Comments
 (0)