Skip to content

Commit 4d3082b

Browse files
committed
feat(Modal,Slideover): implement programmatic close method and update documentation
# Conflicts: # pnpm-lock.yaml
1 parent 7df7ee3 commit 4d3082b

File tree

10 files changed

+1209
-451
lines changed

10 files changed

+1209
-451
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<UModal
3+
title="Modal with close method"
4+
description="This is useful when you want to close the modal from within the content without creating a new ref."
5+
>
6+
<UButton label="Open" color="neutral" variant="subtle" />
7+
8+
<template #body="{ close }">
9+
<div class="space-y-4">
10+
<p>You can close this modal using the close method exposed in the slots.</p>
11+
<UButton label="Close Modal" color="primary" @click="close" />
12+
</div>
13+
</template>
14+
15+
<template #footer="{ close }">
16+
<UButton label="Cancel" color="neutral" variant="outline" @click="close" />
17+
<UButton label="Submit" color="neutral" />
18+
</template>
19+
</UModal>
20+
</template>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<USlideover
3+
title="Sliderover with close method"
4+
description="This is useful when you want to close the slider over from within the content without creating a new ref."
5+
>
6+
<UButton label="Open" color="neutral" variant="subtle" />
7+
8+
<template #body="{ close }">
9+
<div class="space-y-4">
10+
<p>You can close this slider over using the close method exposed in the slots.</p>
11+
<UButton label="Close Modal" color="primary" @click="close" />
12+
</div>
13+
</template>
14+
15+
<template #footer="{ close }">
16+
<UButton label="Cancel" color="neutral" variant="outline" @click="close" />
17+
<UButton label="Submit" color="neutral" />
18+
</template>
19+
</USlideover>
20+
</template>

docs/content/3.components/modal.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,22 @@ name: 'modal-nested-example'
347347
---
348348
::
349349

350+
### Using the close method
351+
352+
All slots in the Modal component receive a `close` method that can be used to programmatically close the modal from within the content.
353+
354+
::component-example
355+
---
356+
name: 'modal-programatic-close'
357+
props:
358+
class: 'px-4'
359+
---
360+
::
361+
362+
::tip
363+
The `close` method is available in all slots: `content`, `header`, `title`, `description`, `body`, and `footer`.
364+
::
365+
350366
### With footer slot
351367

352368
Use the `#footer` slot to add content after the Modal's body.

docs/content/3.components/slideover.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,22 @@ name: 'slideover-nested-example'
346346
---
347347
::
348348

349+
### Using the close method
350+
351+
All slots in the SlideOver component receive a `close` method that can be used to programmatically close the modal from within the content.
352+
353+
::component-example
354+
---
355+
name: 'modal-programatic-close'
356+
props:
357+
class: 'px-4'
358+
---
359+
::
360+
361+
::tip
362+
The `close` method is available in all slots: `content`, `header`, `title`, `description`, `body`, and `footer`.
363+
::
364+
349365
### With footer slot
350366

351367
Use the `#footer` slot to add content after the Slideover's body.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"mlly": "^1.7.4",
145145
"ohash": "^2.0.11",
146146
"pathe": "^2.0.3",
147-
"reka-ui": "^2.2.1",
147+
"reka-ui": "^2.3.0",
148148
"scule": "^1.3.0",
149149
"tailwind-variants": "^1.0.0",
150150
"tailwindcss": "^4.1.7",

playground/app/pages/components/modal.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,13 @@ function openModal() {
6969
</UModal>
7070

7171
<UButton label="Open programmatically" color="neutral" variant="outline" @click="openModal" />
72+
73+
<UModal title="First modal">
74+
<UButton color="neutral" variant="outline" label="Close with scoped slot close" />
75+
76+
<template #footer="{ close }">
77+
<UButton label="Close with scoped slot close" @click="close" />
78+
</template>
79+
</UModal>
7280
</div>
7381
</template>

playground/app/pages/components/slideover.vue

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,21 @@ function openSlideover() {
125125
</USlideover>
126126

127127
<UButton label="Open programmatically" color="neutral" variant="outline" @click="openSlideover" />
128+
129+
<USlideover title="Slideover with scoped slot close" description="This slideover has a scoped slot close that can be used to close the slideover from within the content.">
130+
<UButton color="neutral" variant="subtle" label="Open with scoped slot close" />
131+
132+
<template #header="{ close }">
133+
<UButton label="Close with scoped slot close" @click="close" />
134+
</template>
135+
136+
<template #body="{ close }">
137+
<UButton label="Close with scoped slot close" @click="close" />
138+
</template>
139+
140+
<template #footer="{ close }">
141+
<UButton label="Close with scoped slot close" @click="close" />
142+
</template>
143+
</USlideover>
128144
</div>
129145
</template>

0 commit comments

Comments
 (0)