11import { ContextProvider } from '@lit/context' ;
22import { LitElement , html } from 'lit' ;
33import { property , state } from 'lit/decorators.js' ;
4+ import { styleMap } from 'lit/directives/style-map.js' ;
45import { tileContext } from '../common/context.js' ;
5- import { watch } from '../common/decorators/watch.js' ;
66import { registerComponent } from '../common/definitions/register.js' ;
77import type { Constructor } from '../common/mixins/constructor.js' ;
88import { EventEmitterMixin } from '../common/mixins/event-emitter.js' ;
@@ -48,7 +48,6 @@ export default class IgcTileComponent extends EventEmitterMixin<
4848> ( LitElement ) {
4949 public static readonly tagName = 'igc-tile' ;
5050 public static styles = [ styles , shared ] ;
51- private _emitMaximizedEvent = false ;
5251
5352 /* blazorSuppress */
5453 public static register ( ) {
@@ -64,6 +63,7 @@ export default class IgcTileComponent extends EventEmitterMixin<
6463 private _position = - 1 ;
6564 private _disableDrag = false ;
6665 private _fullscreen = false ;
66+ private _maximized = false ;
6767 private _context = new ContextProvider ( this , {
6868 context : tileContext ,
6969 initialValue : this ,
@@ -112,7 +112,14 @@ export default class IgcTileComponent extends EventEmitterMixin<
112112 * @attr
113113 */
114114 @property ( { type : Boolean , reflect : true } )
115- public maximized = false ;
115+ public set maximized ( value : boolean ) {
116+ this . _maximized = value ;
117+ this . _context . setValue ( this , true ) ;
118+ }
119+
120+ public get maximized ( ) {
121+ return this . _maximized ;
122+ }
116123
117124 /**
118125 * Indicates whether the tile can be dragged.
@@ -151,45 +158,25 @@ export default class IgcTileComponent extends EventEmitterMixin<
151158 return this . _position ;
152159 }
153160
154- @watch ( 'maximized' )
155- protected maximizedChanged ( ) {
156- if ( this . _emitMaximizedEvent && ! this . emitMaximizedEvent ( ) ) {
157- this . maximized = ! this . maximized ;
158- return ;
159- }
160-
161- // HACK
162- if ( this . maximized ) {
163- this . popover = 'manual' ;
164- this . showPopover ( ) ;
165- } else if ( this . popover ) {
166- this . hidePopover ( ) ;
167- this . popover = null ;
168- }
169-
170- this . _emitMaximizedEvent = false ;
171-
172- this . _context . setValue ( this , true ) ;
173- }
174-
175- @watch ( 'colSpan' , { waitUntilFirstUpdate : true } )
176- @watch ( 'rowSpan' , { waitUntilFirstUpdate : true } )
177- @watch ( 'colStart' , { waitUntilFirstUpdate : true } )
178- @watch ( 'rowStart' , { waitUntilFirstUpdate : true } )
179- protected updateRowsColSpan ( ) {
180- this . style . gridColumn = this . style . gridColumn || `span ${ this . colSpan } ` ;
181- this . style . gridRow = this . style . gridRow || `span ${ this . rowSpan } ` ;
182- // if (this.colStart !== null) {
183- // this.style.gridColumn = `${this.colStart} / span ${this.colSpan}`;
184- // } else {
185- // this.style.gridColumn = this.style.gridColumn || `span ${this.colSpan}`; // `span ${this.colSpan}`;
186- // }
187- // if (this.rowStart !== null) {
188- // this.style.gridRow = `${this.rowStart} / span ${this.rowSpan}`;
189- // } else {
190- // this.style.gridRow = this.style.gridRow || `span ${this.rowSpan}`; // `span ${this.rowSpan}`;
191- // }
192- }
161+ // HACK
162+ // @watch ('colSpan', { waitUntilFirstUpdate: true })
163+ // @watch ('rowSpan', { waitUntilFirstUpdate: true })
164+ // @watch ('colStart', { waitUntilFirstUpdate: true })
165+ // @watch ('rowStart', { waitUntilFirstUpdate: true })
166+ // protected updateRowsColSpan() {
167+ // this.style.gridColumn = this.style.gridColumn || `span ${this.colSpan}`;
168+ // this.style.gridRow = this.style.gridRow || `span ${this.rowSpan}`;
169+ // // if (this.colStart !== null) {
170+ // // this.style.gridColumn = `${this.colStart} / span ${this.colSpan}`;
171+ // // } else {
172+ // // this.style.gridColumn = this.style.gridColumn || `span ${this.colSpan}`; // `span ${this.colSpan}`;
173+ // // }
174+ // // if (this.rowStart !== null) {
175+ // // this.style.gridRow = `${this.rowStart} / span ${this.rowSpan}`;
176+ // // } else {
177+ // // this.style.gridRow = this.style.gridRow || `span ${this.rowSpan}`; // `span ${this.rowSpan}`;
178+ // // }
179+ // }
193180
194181 constructor ( ) {
195182 super ( ) ;
@@ -217,15 +204,10 @@ export default class IgcTileComponent extends EventEmitterMixin<
217204 this . emitFullScreenEvent ( ) ;
218205 }
219206
220- public toggleMaximize ( ) {
221- this . _emitMaximizedEvent = true ;
222- this . maximized = ! this . maximized ;
223- }
224-
225- protected override async firstUpdated ( ) {
226- await this . updateComplete ;
227- this . updateRowsColSpan ( ) ;
228- }
207+ // protected override async firstUpdated() {
208+ // await this.updateComplete;
209+ // this.updateRowsColSpan();
210+ // }
229211
230212 private emitFullScreenEvent ( ) {
231213 return this . emitEvent ( 'igcTileFullscreen' , {
@@ -234,13 +216,6 @@ export default class IgcTileComponent extends EventEmitterMixin<
234216 } ) ;
235217 }
236218
237- private emitMaximizedEvent ( ) {
238- return this . emitEvent ( 'igcTileMaximize' , {
239- detail : { tile : this , state : this . maximized } ,
240- cancelable : true ,
241- } ) ;
242- }
243-
244219 private handleDoubleClick ( ) {
245220 if ( ! this . emitFullScreenEvent ( ) ) {
246221 return ;
@@ -351,10 +326,18 @@ export default class IgcTileComponent extends EventEmitterMixin<
351326 fullscreen : this . fullscreen ,
352327 draggable : ! this . disableDrag ,
353328 dragging : this . _isDragging ,
329+ maximized : this . maximized ,
354330 } ) ;
355331
332+ const styles = {
333+ '--ig-col-span' : `${ this . colSpan } ` ,
334+ '--ig-row-span' : `${ this . rowSpan } ` ,
335+ '--ig-col-start' : `${ this . colStart } ` ,
336+ '--ig-row-start' : `${ this . rowStart } ` ,
337+ } ;
338+
356339 return html `
357- < div part =${ parts } .inert =${ this . _hasDragOver } >
340+ < div part =${ parts } .inert =${ this . _hasDragOver } style= ${ styleMap ( styles ) } >
358341 < slot name ="header "> </ slot >
359342 < div part ="content-container ">
360343 < slot > </ slot >
0 commit comments