Skip to content

Commit 9d8ca4a

Browse files
committed
fix: set component props in stories + add setter to columnCount
1 parent 52c42db commit 9d8ca4a

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

src/components/tile-manager/tile-manager.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export default class IgcTileManagerComponent extends EventEmitterMixin<
4848
private draggedItem: IgcTileComponent | null = null;
4949
private finalOrder: IgcTileComponent[] = [];
5050
private positionedTiles: IgcTileComponent[] = [];
51+
private _columnCount = 10;
5152

5253
// @query('[part="base"]', true)
5354
// private _baseWrapper!: HTMLDivElement;
@@ -89,7 +90,23 @@ export default class IgcTileManagerComponent extends EventEmitterMixin<
8990
public dragMode: 'slide' | 'swap' = 'slide';
9091

9192
@property({ type: Number })
92-
public columnCount = 10;
93+
public set columnCount(value: number) {
94+
const oldValue = this._columnCount;
95+
96+
if (value <= 0) {
97+
this._columnCount = 10;
98+
} else {
99+
this._columnCount = value;
100+
}
101+
102+
if (oldValue !== this._columnCount) {
103+
this.requestUpdate('columnCount', oldValue);
104+
}
105+
}
106+
107+
public get columnCount() {
108+
return this._columnCount;
109+
}
93110

94111
@property({ type: Number })
95112
public minColumnWidth = 150;

stories/tile-manager.stories.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const date = new Date();
150150

151151
export const AutoInfer: Story = {
152152
argTypes: disableStoryControls(metadata),
153-
render: () => html`
153+
render: (args) => html`
154154
<style>
155155
:root {
156156
--ig-min-col-width: 600px;
@@ -168,7 +168,12 @@ export const AutoInfer: Story = {
168168
}
169169
}
170170
</style>
171-
<igc-tile-manager>
171+
<igc-tile-manager
172+
.dragMode=${args.dragMode}
173+
.columnCount=${args.columnCount}
174+
.minColumnWidth=${args.minColumnWidth}
175+
.minRowHeight=${args.minRowHeight}
176+
>
172177
${pictures.map(
173178
({ width, height }) => html`
174179
<igc-tile>
@@ -187,7 +192,12 @@ export const AutoInfer: Story = {
187192

188193
export const FinDashboard: Story = {
189194
render: (args) => html`
190-
<igc-tile-manager>
195+
<igc-tile-manager
196+
.dragMode=${args.dragMode}
197+
.columnCount=${args.columnCount}
198+
.minColumnWidth=${args.minColumnWidth}
199+
.minRowHeight=${args.minRowHeight}
200+
>
191201
<igc-tile
192202
.colSpan=${3}
193203
.rowSpan=${5}
@@ -350,7 +360,7 @@ export const FinDashboard: Story = {
350360

351361
export const FinDashboard1: Story = {
352362
render: (args) => html`
353-
<igc-tile-manager>
363+
<igc-tile-manager .dragMode=${args.dragMode} .columnCount=${args.columnCount} .minColumnWidth=${args.minColumnWidth} .minRowHeight=${args.minRowHeight}>
354364
<igc-tile .colSpan=${3} .rowSpan=${2}>
355365
<igc-tile-header slot="header">
356366
<span slot="title">Good morning, John</span>
@@ -582,6 +592,8 @@ export const Default: Story = {
582592
<igc-tile-manager
583593
.dragMode=${args.dragMode}
584594
.columnCount=${args.columnCount}
595+
.minColumnWidth=${args.minColumnWidth}
596+
.minRowHeight=${args.minRowHeight}
585597
>
586598
<p>This text won't be displayed in Tile Manager</p>
587599
${tiles}
@@ -609,7 +621,7 @@ function cancelStateChangeEvent(e: CustomEvent) {
609621
}
610622

611623
export const Maximized: Story = {
612-
render: () => html`
624+
render: (args) => html`
613625
<style>
614626
igc-tile-manager {
615627
margin: 0 auto;
@@ -618,7 +630,12 @@ export const Maximized: Story = {
618630
}
619631
</style>
620632
621-
<igc-tile-manager>
633+
<igc-tile-manager
634+
.dragMode=${args.dragMode}
635+
.columnCount=${args.columnCount}
636+
.minColumnWidth=${args.minColumnWidth}
637+
.minRowHeight=${args.minRowHeight}
638+
>
622639
<igc-tile
623640
id="max-tile"
624641
maximized

0 commit comments

Comments
 (0)