mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-02-01 20:57:57 +01:00
feat(useOverlay): add isOpen method to check overlay state (#4041)
This commit is contained in:
@@ -13,7 +13,9 @@ const modal = overlay.create(LazyModalExample, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function open() {
|
async function open() {
|
||||||
const shouldIncrement = await modal.open()
|
const instance = modal.open()
|
||||||
|
|
||||||
|
const shouldIncrement = await instance.result
|
||||||
|
|
||||||
if (shouldIncrement) {
|
if (shouldIncrement) {
|
||||||
count.value++
|
count.value++
|
||||||
|
|||||||
@@ -13,7 +13,9 @@ const slideover = overlay.create(LazySlideoverExample, {
|
|||||||
})
|
})
|
||||||
|
|
||||||
async function open() {
|
async function open() {
|
||||||
const shouldIncrement = await slideover.open()
|
const instance = slideover.open()
|
||||||
|
|
||||||
|
const shouldIncrement = await instance.result
|
||||||
|
|
||||||
if (shouldIncrement) {
|
if (shouldIncrement) {
|
||||||
count.value++
|
count.value++
|
||||||
|
|||||||
@@ -66,6 +66,13 @@ Update an overlay using its `id`
|
|||||||
|
|
||||||
Removes the overlay from the DOM using its `id`
|
Removes the overlay from the DOM using its `id`
|
||||||
|
|
||||||
|
- Parameters:
|
||||||
|
- `id`: The identifier of the overlay
|
||||||
|
|
||||||
|
### `isOpen(id: symbol): boolean`
|
||||||
|
|
||||||
|
Checks if an overlay its open using its `id`
|
||||||
|
|
||||||
- Parameters:
|
- Parameters:
|
||||||
- `id`: The identifier of the overlay
|
- `id`: The identifier of the overlay
|
||||||
|
|
||||||
|
|||||||
@@ -122,6 +122,12 @@ function _useOverlay() {
|
|||||||
return overlay
|
return overlay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isOpen = (id: symbol): boolean => {
|
||||||
|
const overlay = getOverlay(id)
|
||||||
|
|
||||||
|
return overlay.isOpen
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
overlays,
|
overlays,
|
||||||
open,
|
open,
|
||||||
@@ -129,7 +135,8 @@ function _useOverlay() {
|
|||||||
closeAll,
|
closeAll,
|
||||||
create,
|
create,
|
||||||
patch,
|
patch,
|
||||||
unMount
|
unMount,
|
||||||
|
isOpen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user