Skip to content

Commit a6e265e

Browse files
committed
refactor: Improved API documentation & minor code clean-ups
1 parent 6ad6aab commit a6e265e

File tree

4 files changed

+60
-20
lines changed

4 files changed

+60
-20
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ import IgcTileComponent from './tile.js';
2727
*
2828
* @element igc-tile-manager
2929
*
30+
* @slot - Default slot for the tile manager. Only `igc-tile` elements will be projected inside the CSS grid container.
31+
*
32+
* @csspart base - The tile manager CSS Grid container.
33+
*
34+
* @cssproperty --column-count - The number of columns for the tile manager. The `column-count` attribute sets this variable.
35+
* @cssproperty --row-count - The number of rows for the tile manager. The `row-count` attribute sets this variable.
36+
* @cssproperty --min-col-width - The minimum size of the columns in the tile-manager. The `min-column-width` attribute sets this variable.
37+
* @cssproperty --min-row-height - The minimum size of the rows in the tile-manager. The `min-row-height` attribute sets this variable.
38+
* @cssproperty --grid-gap - The gap size of the underlying CSS grid container. The `gap` attributes sts this variable.
39+
*
3040
*/
3141
@themes(all)
3242
export default class IgcTileManagerComponent extends LitElement {
@@ -186,7 +196,7 @@ export default class IgcTileManagerComponent extends LitElement {
186196
}
187197

188198
/**
189-
* Sets the gap size of the the tile manager.
199+
* Sets the gap size between tiles in the tile manager.
190200
*
191201
* @attr gap
192202
*/
@@ -261,10 +271,20 @@ export default class IgcTileManagerComponent extends LitElement {
261271

262272
// #region Public API
263273

274+
/**
275+
* Returns the properties of the current tile collections as a JSON payload.
276+
*
277+
* @remarks
278+
* The content of the tiles is not serialized or saved. Only tile properties
279+
* are serialized.
280+
*/
264281
public saveLayout(): string {
265282
return this._serializer.saveAsJSON();
266283
}
267284

285+
/**
286+
* Restores a previously serialized state produced by `saveLayout`.
287+
*/
268288
public loadLayout(data: string): void {
269289
this._serializer.loadFromJSON(data);
270290
}

src/components/tile-manager/tile.ts

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { all } from './themes/tile.js';
4242
import { createTileDragGhost, createTileGhost } from './tile-ghost-util.js';
4343
import type IgcTileManagerComponent from './tile-manager.js';
4444

45-
type IgcTileChangeState = {
45+
export type IgcTileChangeState = {
4646
tile: IgcTileComponent;
4747
state: boolean;
4848
};
@@ -75,11 +75,11 @@ export interface IgcTileComponentEventMap {
7575
* @fires igcTileResizeEnd - Fired when a resize operation on a tile is successfully completed.
7676
* @fires igcTileResizeCancel - Fired when a resize operation on a tile is canceled by the user.
7777
*
78+
* @slot - Default slot for the tile's content.
7879
* @slot title - Renders the title of the tile header.
7980
* @slot maximize-action - Renders the maximize action element.
8081
* @slot fullscreen-action - Renders the fullscreen action element.
8182
* @slot actions - Renders items after the default actions.
82-
* @slot Default slot for the tile's content.
8383
* @slot side-adorner - Renders the side resize handle.
8484
* @slot corner-adorner - Renders the corner resize handle.
8585
* @slot bottom-adorner - Renders the bottom resize handle.
@@ -222,9 +222,11 @@ export default class IgcTileComponent extends EventEmitterMixin<
222222
* The number of columns the tile will span.
223223
*
224224
* @remarks
225-
* Values <= 1 will be coerced to 1.
225+
* When setting a value that is less than 1, it will be
226+
* coerced to 1.
226227
*
227228
* @attr col-span
229+
* @default 1
228230
*/
229231
@property({ type: Number, attribute: 'col-span' })
230232
public set colSpan(value: number) {
@@ -240,9 +242,11 @@ export default class IgcTileComponent extends EventEmitterMixin<
240242
* The number of rows the tile will span.
241243
*
242244
* @remarks
243-
* Values <= 1 will be coerced to 1.
245+
* When setting a value that is less than 1, it will be
246+
* coerced to 1.
244247
*
245248
* @attr row-span
249+
* @default 1
246250
*/
247251
@property({ type: Number, attribute: 'row-span' })
248252
public set rowSpan(value: number) {
@@ -318,30 +322,38 @@ export default class IgcTileComponent extends EventEmitterMixin<
318322
}
319323

320324
/**
321-
* Indicates whether the tile can be resized.
325+
* Indicates whether to disable tile resize behavior regardless
326+
* ot its tile manager parent settings.
327+
*
322328
* @attr disable-resize
329+
* @default false
323330
*/
324331
@property({ type: Boolean, reflect: true, attribute: 'disable-resize' })
325332
public disableResize = false;
326333

327334
/**
328-
* Indicates whether the fullscreen action is displayed.
335+
* Whether to disable the rendering of the tile `fullscreen-action` slot and its
336+
* default fullscreen action button.
337+
*
329338
* @attr disable-fullscreen
339+
* @default false
330340
*/
331341
@property({ type: Boolean, reflect: true, attribute: 'disable-fullscreen' })
332342
public disableFullscreen = false;
333343

334344
/**
335-
* Indicates whether the maximize action is displayed.
345+
* Whether to disable the rendering of the tile `maximize-action` slot and its
346+
* default maximize action button.
347+
*
336348
* @attr disable-maximize
349+
* @default false
337350
*/
338351
@property({ type: Boolean, reflect: true, attribute: 'disable-maximize' })
339352
public disableMaximize = false;
340353

341354
/**
342355
* Gets/sets the tile's visual position in the layout.
343-
*
344-
* Corresponds to the CSS order property.
356+
* Corresponds to the CSS `order` property.
345357
*
346358
* @attr position
347359
*/
@@ -595,21 +607,28 @@ export default class IgcTileComponent extends EventEmitterMixin<
595607
this.disableMaximize &&
596608
this.disableFullscreen;
597609

610+
const hasMaximizeSlot = !(this.disableMaximize || this.fullscreen);
611+
const hasFullscreenSlot = !this.disableFullscreen;
612+
598613
return html`
599614
<section part="header" ?hidden=${hideHeader} ${ref(this._headerRef)}>
600615
<header part="title">
601616
<slot name="title"></slot>
602617
</header>
603618
<section id="tile-actions" part="actions">
604-
${!this.disableMaximize && !this.fullscreen
605-
? html`<slot name="maximize-action"
606-
>${this._renderDefaultAction('maximize')}</slot
607-
>`
619+
${hasMaximizeSlot
620+
? html`
621+
<slot name="maximize-action">
622+
${this._renderDefaultAction('maximize')}
623+
</slot>
624+
`
608625
: nothing}
609-
${!this.disableFullscreen
610-
? html`<slot name="fullscreen-action"
611-
>${this._renderDefaultAction('fullscreen')}</slot
612-
>`
626+
${hasFullscreenSlot
627+
? html`
628+
<slot name="fullscreen-action">
629+
${this._renderDefaultAction('fullscreen')}
630+
</slot>
631+
`
613632
: nothing}
614633
615634
<slot name="actions"></slot>

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export type {
120120
TileManagerDragMode,
121121
TileManagerResizeMode,
122122
} from './components/types.js';
123+
export type { IgcTileChangeState } from './components/tile-manager/tile.js';
123124
export type {
124125
DateRangeDescriptor,
125126
WeekDays,

stories/tile-manager.stories.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const metadata: Meta<IgcTileManagerComponent> = {
115115
},
116116
gap: {
117117
type: 'string',
118-
description: 'Sets the gap size of the the tile manager.',
118+
description: 'Sets the gap size between tiles in the tile manager.',
119119
control: 'text',
120120
},
121121
},
@@ -143,7 +143,7 @@ interface IgcTileManagerArgs {
143143
minColumnWidth: string;
144144
/** Sets the minimum height for a row unit in the tile manager. */
145145
minRowHeight: string;
146-
/** Sets the gap size of the the tile manager. */
146+
/** Sets the gap size between tiles in the tile manager. */
147147
gap: string;
148148
}
149149
type Story = StoryObj<IgcTileManagerArgs>;

0 commit comments

Comments
 (0)