File tree Expand file tree Collapse file tree 6 files changed +29
-7
lines changed Expand file tree Collapse file tree 6 files changed +29
-7
lines changed Original file line number Diff line number Diff line change 11< app-header > < h2 > Activity State</ h2 > </ app-header >
22
3- < activity-state data-state ="busy "> </ activity-state >
4-
53< tool-bar >
64 < button data-action ="busy "> Set Busy</ button >
75 < button data-action ="success "> Set Success</ button >
86 < button data-action ="error "> Set Error</ button >
7+ < activity-state data-state ="busy "> </ activity-state >
98</ tool-bar >
Original file line number Diff line number Diff line change @@ -27,15 +27,16 @@ export default class ActivityStateView extends HTMLElement {
2727 }
2828
2929 #click( event ) {
30- if ( event . target . dataset . action ) {
31- this . setState ( "busy" ) ;
30+ const target = event . composedPath ( ) [ 0 ] ;
31+ if ( target . dataset . action ) {
32+ this . setState ( target . dataset . action ) ;
3233 }
3334 }
3435
3536 setState ( state ) {
3637 requestAnimationFrame ( ( ) => {
3738 const activityState = this . shadowRoot . querySelector ( "activity-state" ) ;
38- activityState . dataset . state = state ;
39+ activityState . setState ( state ) ;
3940 } ) ;
4041 }
4142}
Original file line number Diff line number Diff line change 11: host {
22 dis play: block;
3- padding: var(--padding );
43 box- sizing: bor der- box;
4+ width: 1.5rem;
5+ height: 1.5rem;
56}
Original file line number Diff line number Diff line change @@ -16,6 +16,23 @@ class ActivityState extends HTMLElement {
1616
1717 this . style . display = "block" ;
1818 }
19+
20+ setState ( state ) {
21+ const materialIcon = this . shadowRoot . querySelector ( "material-icon" ) ;
22+
23+ const iconName = {
24+ "busy" : "hourglass_full" ,
25+ "success" : "check_circle" ,
26+ "error" : "error" ,
27+ } [ state ] ;
28+
29+ ComponentModule . on_ready ( {
30+ element : materialIcon ,
31+ callback : ( ) => {
32+ materialIcon . setIcon ( iconName ) ;
33+ }
34+ } )
35+ }
1936}
2037
2138customElements . define ( ActivityState . name , ActivityState ) ;
Original file line number Diff line number Diff line change 1+ import { ComponentModule } from "../../src/modules/component.js" ;
2+
13export class MaterialIcon extends HTMLElement {
24 static name = Object . freeze ( "material-icon" ) ;
35
@@ -19,6 +21,8 @@ export class MaterialIcon extends HTMLElement {
1921 this . style . alignItems = "center" ;
2022 this . style . justifyContent = "center" ;
2123 this . style . pointerEvents = "none" ;
24+
25+ ComponentModule . ready ( { element : this } ) ;
2226 }
2327
2428 setIcon ( iconName ) {
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export class ToolBar extends HTMLElement {
2424 url : import . meta. url ,
2525 } ) ;
2626
27- this . style . display = "block " ;
27+ this . style . display = "flex " ;
2828 }
2929}
3030
You can’t perform that action at this time.
0 commit comments