@@ -19,6 +19,14 @@ import A11yDialog from 'a11y-dialog';
19
19
import stylesDialogContainer from './dialog-container.css?inline' ;
20
20
import stylesDialogContent from './dialog-content.css?inline' ;
21
21
22
+ interface DialogStyleProps {
23
+ classNames ?: { container : string ; content : string } ;
24
+ }
25
+
26
+ interface StyleProps {
27
+ class ?: string ;
28
+ }
29
+
22
30
interface DialogContextSignals {
23
31
/** Indicates whether Dialog is open or not. */
24
32
isOpenSignal : Signal < boolean > ;
@@ -65,7 +73,7 @@ const Root = component$(() => {
65
73
) ;
66
74
} ) ;
67
75
68
- const Trigger = component$ ( ( ) => {
76
+ const Trigger = component$ ( ( props : StyleProps ) => {
69
77
const dialogContext = useContext ( dialogContextId ) ;
70
78
const a11yDialog = useSignal < NoSerialize < A11yDialog > > ( ) ;
71
79
@@ -95,16 +103,16 @@ const Trigger = component$(() => {
95
103
) ;
96
104
97
105
return (
98
- < div role = "button" >
106
+ < div role = "button" class = { props . class } >
99
107
< Slot />
100
108
</ div >
101
109
) ;
102
110
} ) ;
103
111
104
- // TODO: We need a way to add the template as nearest as possible to the <body>-Element
112
+ // TODO: We need a way to add the template as nearest as possible to the </ body>-Element
105
113
// This ensures the dialog being displayed on top of all other elements
106
114
// React has a built-in way to create portals. How to we handle this in Qwik-UI?
107
- const Portal = component$ ( ( ) => {
115
+ const Portal = component$ ( ( props : DialogStyleProps ) => {
108
116
useStylesScoped$ ( stylesDialogContainer ) ;
109
117
110
118
const dialogContext = useContext ( dialogContextId ) ;
@@ -119,15 +127,15 @@ const Portal = component$(() => {
119
127
ref = { containerRefSignal }
120
128
aria-labelledby = "your-dialog-title-id"
121
129
aria-hidden = "true"
122
- class = "dialog-container"
130
+ // class={`dialog-container ${props.classNames?.container}`}
131
+ class = { `${ props . classNames ?. container || 'dialog-container' } ` }
123
132
>
124
133
< div
125
134
data-a11y-dialog-hide
126
135
class = "dialog-overlay"
127
136
onClick$ = { ( ) => ( dialogContext . isOpenSignal . value = false ) }
128
137
> </ div >
129
-
130
- < div role = "document" >
138
+ < div role = "document" class = { props . classNames ?. content } >
131
139
< Slot />
132
140
</ div >
133
141
</ div >
0 commit comments