1- import { Component , Part , Prop } from '@pictogrammers/element' ;
1+ import { Component , Part , Prop , Local } from '@pictogrammers/element' ;
22
33import template from './app.html' ;
44import style from './app.css' ;
@@ -14,9 +14,14 @@ export default class PgApp extends HTMLElement {
1414 @Part ( ) $side : HTMLDivElement ;
1515 @Part ( ) $resize : HTMLButtonElement ;
1616
17+ @Local ( 'app' ) store = new Map ( [
18+ [ 'width' , 12 * 16 ]
19+ ] ) ;
20+
1721 connectedCallback ( ) {
1822 this . $logo . addEventListener ( 'click' , this . #handleClick. bind ( this ) ) ;
1923 this . $resize . addEventListener ( 'pointerdown' , this . #handlePointerDown. bind ( this ) ) ;
24+ this . $side . style . width = `${ this . store . get ( 'width' ) } px` ;
2025 }
2126
2227 #handleClick( ) {
@@ -33,6 +38,7 @@ export default class PgApp extends HTMLElement {
3338 const x = currentX - ee . clientX ;
3439 const width = currentWidth - x ;
3540 this . $side . style . width = `${ width } px` ;
41+ this . store . set ( 'width' , Math . floor ( width ) ) ;
3642 }
3743 const handlePointerUp = ( ) => {
3844 this . $resize . classList . remove ( 'dragging' ) ;
@@ -42,4 +48,4 @@ export default class PgApp extends HTMLElement {
4248 document . addEventListener ( 'pointermove' , handlePointerMove ) ;
4349 document . addEventListener ( 'pointerup' , handlePointerUp ) ;
4450 }
45- }
51+ }
0 commit comments