Skip to content

Commit 3b26b9e

Browse files
committed
fix: tile css parts
1 parent 9d8ca4a commit 3b26b9e

File tree

3 files changed

+81
-18
lines changed

3 files changed

+81
-18
lines changed

src/components/tile-manager/themes/tile.base.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
:host {
55
display: block;
66
position: relative;
7+
grid-column: var(--ig-col-start, auto) / span var(--ig-col-span, 1);
8+
grid-row: var(--ig-row-start, auto) / span var(--ig-row-span, 1);
79
}
810

911
[part~='base'] {
1012
// resize: both;
1113
// overflow: auto;
1214
width: 100%;
1315
height: 100%;
14-
grid-column: var(--ig-col-start, unset) / span(var(--ig-col-span, 1));
15-
grid-row: var(--ig-row-start, unset) / span(var(--ig-row-span, 1));
1616
}
1717

1818
[part='content-container'] {

src/components/tile-manager/tile.ts

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ export default class IgcTileComponent extends EventEmitterMixin<
6060

6161
private static readonly increment = createCounter();
6262
private _dragController: TileDragAndDropController;
63+
private _colSpan = 1;
64+
private _rowSpan = 1;
65+
private _colStart: number | null = null;
66+
private _rowStart: number | null = null;
6367
private _position = -1;
6468
private _disableDrag = false;
6569
private _fullscreen = false;
@@ -83,16 +87,84 @@ export default class IgcTileComponent extends EventEmitterMixin<
8387
public tileId: string | null = null;
8488

8589
@property({ type: Number })
86-
public colSpan = 1; // review
90+
public set colSpan(value: number) {
91+
const oldValue = this._colSpan;
92+
93+
if (value <= 0) {
94+
this._colSpan = 1;
95+
} else {
96+
this._colSpan = value;
97+
}
98+
99+
if (oldValue !== this._colSpan) {
100+
this.style.setProperty('--ig-col-span', `${value}`);
101+
this.requestUpdate('colSpan', oldValue);
102+
}
103+
}
104+
105+
public get colSpan(): number {
106+
return this._colSpan;
107+
}
87108

88109
@property({ type: Number })
89-
public rowSpan = 1; // review
110+
public set rowSpan(value: number) {
111+
const oldValue = this._rowSpan;
112+
113+
if (value <= 0) {
114+
this._rowSpan = 1;
115+
} else {
116+
this._rowSpan = value;
117+
}
118+
119+
if (oldValue !== this._rowSpan) {
120+
this.style.setProperty('--ig-row-span', `${value}`);
121+
this.requestUpdate('rowSpan', oldValue);
122+
}
123+
}
124+
125+
public get rowSpan(): number {
126+
return this._rowSpan;
127+
}
90128

91129
@property({ type: Number })
92-
public colStart: number | null = null;
130+
public set colStart(value: number) {
131+
const oldValue = this._colStart;
132+
133+
if (value <= 0) {
134+
this._colStart = null;
135+
} else {
136+
this._colStart = value;
137+
}
138+
139+
if (oldValue !== this._colStart) {
140+
this.style.setProperty('--ig-col-start', `${value}`);
141+
this.requestUpdate('colStart', oldValue);
142+
}
143+
}
144+
145+
public get colStart(): number | null {
146+
return this._colStart;
147+
}
93148

94149
@property({ type: Number })
95-
public rowStart: number | null = null;
150+
public set rowStart(value: number) {
151+
const oldValue = this._rowStart;
152+
153+
if (value <= 0) {
154+
this._rowStart = null;
155+
} else {
156+
this._rowStart = value;
157+
}
158+
159+
if (oldValue !== this._rowStart) {
160+
this.style.setProperty('--ig-row-start', `${value}`);
161+
this.requestUpdate('rowStart', oldValue);
162+
}
163+
}
164+
165+
public get rowStart(): number | null {
166+
return this._rowStart;
167+
}
96168

97169
@property({ type: Boolean, reflect: true })
98170
public set fullscreen(value: boolean) {

stories/tile-manager.stories.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ const metadata: Meta<IgcTileManagerComponent> = {
7878
control: { type: 'inline-radio' },
7979
table: { defaultValue: { summary: 'slide' } },
8080
},
81-
columnCount: {
82-
type: 'number',
83-
control: 'number',
84-
table: { defaultValue: { summary: '10' } },
85-
},
81+
columnCount: { type: 'string', control: 'text' },
8682
minColumnWidth: {
8783
type: 'number',
8884
control: 'number',
@@ -94,20 +90,15 @@ const metadata: Meta<IgcTileManagerComponent> = {
9490
table: { defaultValue: { summary: '200' } },
9591
},
9692
},
97-
args: {
98-
dragMode: 'slide',
99-
columnCount: 10,
100-
minColumnWidth: 150,
101-
minRowHeight: 200,
102-
},
93+
args: { dragMode: 'slide', minColumnWidth: 150, minRowHeight: 200 },
10394
};
10495

10596
export default metadata;
10697

10798
interface IgcTileManagerArgs {
10899
/** Determines whether the tiles slide or swap on drop. */
109100
dragMode: 'slide' | 'swap';
110-
columnCount: number;
101+
columnCount: string;
111102
minColumnWidth: number;
112103
minRowHeight: number;
113104
}

0 commit comments

Comments
 (0)