11import { LitElement , css , html } from 'lit'
22import { customElement , property } from 'lit/decorators.js'
3+ import { MY_MODAL_TOKEN } from '../dialogs/custom-modal.token' ;
4+ import { UMB_MODAL_MANAGER_CONTEXT } from '@umbraco-cms/backoffice/modal' ;
5+ import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api' ;
36
47/**
58 * An example element.
@@ -8,29 +11,48 @@ import { customElement, property } from 'lit/decorators.js'
811 * @csspart button - The button
912 */
1013@customElement ( 'uie-custom-dialogs-dashboard' )
11- export default class UieCustomDialogsDashboard extends LitElement {
12- /**
13- * Copy for the read the docs hint.
14- */
15- @property ( )
16- docsHint = 'Click on the Vite and Lit logos to learn more'
14+ export default class UieCustomDialogsDashboard extends UmbElementMixin ( LitElement ) {
15+ #modalManagerContext?: typeof UMB_MODAL_MANAGER_CONTEXT . TYPE ;
1716
17+ constructor ( ) {
18+ super ( ) ;
19+ this . consumeContext ( UMB_MODAL_MANAGER_CONTEXT , ( instance ) => {
20+ this . #modalManagerContext = instance ;
21+ // modalManagerContext is now ready to be used.
22+ } ) ;
23+ }
1824
19- /**
20- * The number of times the button has been clicked.
21- */
22- @property ( { type : Number } )
23- count = 0
25+ render ( ) {
26+ return html `
27+ <uui- box>
28+ <div slot= "header" class = "header-bar" >
29+ <div>
30+ <h5 class= "title" > Overlay Dialogs <br/ > <span class= "sub-header" > Overlays give you a 'modal' dialog across the whole screen </ span> </ h5>
31+ </ div>
32+ </ div>
33+ <div slot= "header-actions" >
34+ <uui- butto n href= "https://uui.umbraco.com/" target = "_blank" look = "primary" color = "positive" >
35+ <uui- badge slot= "extra" label = "A11Y label" > !</ uui- badge>
36+ <uui- icon name= "info" > </ uui- icon>
37+ View the Storybook library </ uui- butto n>
38+ </ div>
39+ <slot>
40+ <p> The overlay service has a confirm option built , in with this you can quickly create a confirm dialog , to present your users with a simple option .</ p>
41+ <uui- butto n- group>
42+ <uui- butto n look= "primary" color = "default" @click=${ this . _openModal } >Confirm</uui-button>
43+ <uui-button look=" primary" color=" positive">Confirm Remove</uui-button>
44+ <uui-button look=" primary" color=" danger">Confirm Delete</uui-button>
45+ </uui-button-group>
46+ </slot>
47+ </uui-box>`
48+ }
2449
25- render ( ) {
26- return html `
27- <uui- modal- container>
28- <uui- modal- dialog>
29- <h1> My Modal</ h1>
30- <p> My modal content</ p>
31- </ uui- modal- dialog>
32- </ uui- modal- container>
33- `
50+ private _openModal ( ) {
51+ this . #modalManagerContext?. open ( this , MY_MODAL_TOKEN , {
52+ data : {
53+ headline : "My modal headline" ,
54+ } ,
55+ } ) ;
3456 }
3557
3658 static styles = css `
@@ -85,6 +107,6 @@ export default class UieCustomDialogsDashboard extends LitElement {
85107
86108declare global {
87109 interface HTMLElementTagNameMap {
88- 'uie-custom-dialogs-dashboard' : UieCustomDialogsDashboard
110+ 'uie-custom-dialogs-dashboard' : UieCustomDialogsDashboard
89111 }
90112}
0 commit comments