Skip to content

Commit 9bd84b3

Browse files
committed
requiring widths for resize
1 parent 4a6505e commit 9bd84b3

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

packages/components/src/components/hds/advanced-table/models/column.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { tracked } from '@glimmer/tracking';
22

33
import type { HdsAdvancedTableColumn as HdsAdvancedTableColumnType } from '../types';
44
import type { HdsAdvancedTableHorizontalAlignment } from '../types';
5+
import { assert } from '@ember/debug';
56

67
function getNumericalWidth(width: string | undefined): number {
78
if (width === undefined) {
@@ -13,11 +14,12 @@ function getNumericalWidth(width: string | undefined): number {
1314
}
1415
export default class HdsAdvancedTableColumn {
1516
@tracked label: string = '';
17+
@tracked _isResizable: boolean = false;
18+
1619
@tracked align?: HdsAdvancedTableHorizontalAlignment = 'left';
1720
@tracked key?: string = undefined;
1821
@tracked isExpandable?: boolean = false;
1922
@tracked isReorderable?: boolean = false;
20-
@tracked isResizable?: boolean = false;
2123
@tracked isSortable?: boolean = false;
2224
@tracked isVisuallyHidden?: boolean = false;
2325
@tracked tooltip?: string = undefined;
@@ -27,6 +29,16 @@ export default class HdsAdvancedTableColumn {
2729

2830
@tracked sortingFunction?: (a: unknown, b: unknown) => number = undefined;
2931

32+
get isResizable(): boolean | undefined {
33+
if (!this._isResizable) {
34+
return false;
35+
}
36+
37+
assert('width must be set to use isResizable', this.width !== undefined);
38+
39+
return this._isResizable;
40+
}
41+
3042
get numericalWidth(): number {
3143
return getNumericalWidth(this.width);
3244
}
@@ -46,7 +58,7 @@ export default class HdsAdvancedTableColumn {
4658
this.label = args.label;
4759
this.align = args.align;
4860
this.key = args.key;
49-
this.isResizable = args.isResizable;
61+
this._isResizable = args.isResizable ?? false;
5062
this.isSortable = args.isSortable;
5163
this.isVisuallyHidden = args.isVisuallyHidden;
5264
this.tooltip = args.tooltip;

packages/components/src/components/hds/advanced-table/th.hbs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,12 @@
6565

6666
{{#if this.isResizeSliderVisible}}
6767
<div class="hds-advanced-table__th-resize-slider">
68-
{{@column.numericalWidth}}
68+
<Hds::Form::Label @controlId="{{this._labelId}}-resize-slider">
69+
{{@column.label}}
70+
column width
71+
</Hds::Form::Label>
6972
<Hds::Form::RangeSlider::Base
73+
id="{{this._labelId}}-resize-slider"
7074
@min={{@column.numericalMinWidth}}
7175
@max={{@column.numericalMaxWidth}}
7276
@value={{@column.numericalWidth}}

packages/components/src/styles/components/form/range-slider.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
input[type="range"].hds-form-range-slider {
22
width: 100%;
33
height: 4px;
4+
margin-top: 16px;
45
border-radius: 2px;
56
cursor: pointer;
67
// stylelint-disable-next-line property-no-vendor-prefix

showcase/app/controllers/components/advanced-table.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,18 +364,21 @@ export default class ComponentsTableController extends Controller {
364364
key: 'artist',
365365
label: 'Artist',
366366
tooltip: 'More information.',
367+
width: '200px',
367368
isResizable: true,
368369
},
369370
{
370371
key: 'album',
371372
label: 'Album',
372373
tooltip: 'More information.',
374+
width: '300px',
373375
isResizable: true,
374376
},
375377
{
376378
key: 'year',
377379
label: 'Release Year',
378380
tooltip: 'More information.',
381+
width: '200px',
379382
isResizable: true,
380383
},
381384
{

0 commit comments

Comments
 (0)