File tree Expand file tree Collapse file tree 2 files changed +140
-0
lines changed Expand file tree Collapse file tree 2 files changed +140
-0
lines changed Original file line number Diff line number Diff line change 11<template >
22 <div id =" playground" >
33 <main id =" main" >
4+ <button @click =" basicDialog = true" >Open basic Dialog</button >
45 <button @click =" isOpen = !isOpen" >Default</button >
56 <button style =" visibility :hidden " >Default</button >
7+
8+ <BasicDialog
9+ :open =" basicDialog"
10+ @close =" basicDialog = false"
11+ @confirm =" basicDialog = false"
12+ >
13+ <template v-slot :title >
14+ Your markup,
15+ <strong >your rules</strong >
16+ </template >
17+ <template v-slot :default >
18+ Are you sure you want to be overriding CSS or pass a thousand props again?
19+ </template >
20+ </BasicDialog >
21+
622 <DialogExample
723 :open =" isOpen"
824 @close =" isOpen = false"
107123import ' focus-visible'
108124import { PortalTarget } from " portal-vue" ;
109125import DialogExample from " ./components/DialogExample.vue" ;
126+ import BasicDialog from " ./components/BasicDialog.vue" ;
110127
111128
112129export default {
113130 name: " Playground" ,
114131 components: {
132+ BasicDialog,
115133 DialogExample,
116134 PortalTarget,
117135 // A11yDialog
118136 },
119137 data : () => ({
138+ basicDialog: false ,
120139 last: false ,
121140 exOpen: false ,
122141 exOpenTwo: false ,
Original file line number Diff line number Diff line change 1+ <template >
2+ <a11y-dialog
3+ v-bind =" $attrs"
4+ v-on =" $listeners"
5+ #default =" {
6+ open,
7+ closeFn,
8+ backdropRef,
9+ dialogRef,
10+ titleRef,
11+ closeRef,
12+ }"
13+ >
14+ <portal to =" a11y-vue-dialogs" v-if =" open" >
15+ <div
16+ class =" dialog"
17+ v-bind =" backdropRef.props"
18+ v-on =" backdropRef.listeners"
19+ >
20+ <div
21+ class =" dialog__inner"
22+ v-bind =" dialogRef.props"
23+ v-on =" dialogRef.listeners"
24+ >
25+ <header class =" dialog__header" >
26+ <h1 v-bind =" titleRef.props" >
27+ <slot name =" title" />
28+ </h1 >
29+ <button v-bind =" closeRef.props" v-on =" closeRef.listeners" >x</button >
30+ </header >
31+ <section class =" dialog__body" >
32+ <slot />
33+ </section >
34+ <footer class =" dialog__footer" >
35+ <button @click =" closeFn" class =" btn btn-danger" >Cancel</button >
36+ <button
37+ class =" btn btn-sucess"
38+ @click =" $emit('confirm', { life: 42 })"
39+ >
40+ Confirm
41+ </button >
42+ </footer >
43+ </div >
44+ </div >
45+ </portal >
46+ </a11y-dialog >
47+ </template >
48+
49+ <script >
50+ import { A11yDialog } from ' ../../../src/index'
51+ import { Portal } from " @linusborg/vue-simple-portal" ;
52+ export default {
53+ name: " BasicDialog" ,
54+ components: {
55+ A11yDialog,
56+ Portal
57+ },
58+ props: {
59+ title: {
60+ type: String ,
61+ },
62+ },
63+ };
64+ </script >
65+
66+ <style lang="scss">
67+ .dialog {
68+ position : fixed ;
69+ top : 0 ;
70+ left : 0 ;
71+ width : 100% ;
72+ height : 100% ;
73+ background : rgba (0 , 0 , 0 , 0.5 );
74+ z-index : 1000 ;
75+ display : flex ;
76+ flex-direction : column ;
77+ place-items : center ;
78+ place-content : center ;
79+ text-align : left ;
80+ }
81+
82+ .dialog__inner {
83+ background : white ;
84+ max-width : 400px ;
85+ }
86+
87+ .dialog__header ,
88+ .dialog__body ,
89+ .dialog__footer {
90+ padding : 10px 20px ;
91+ }
92+
93+ .dialog__header {
94+ display : flex ;
95+ justify-content : space-between ;
96+ align-items : center ;
97+ border-bottom : 1px solid whitesmoke ;
98+
99+ h1 {
100+ font-size : 20px ;
101+ margin-right : 20px ;
102+ margin-bottom : 0px ;
103+ margin-top : 0px ;
104+ }
105+ }
106+
107+ .dialog__body {
108+ padding : 30px 20px ;
109+ }
110+
111+ .dialog__footer {
112+ display : flex ;
113+ justify-content : flex-end ;
114+ background-color : whitesmoke ;
115+ }
116+
117+ .btn-sucess {
118+ background-color : lime ;
119+ }
120+ </style >
121+
You can’t perform that action at this time.
0 commit comments