Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
dashboard
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
dashboard
Commits
41c40b01
Commit
41c40b01
authored
1 year ago
by
Konrad Mohrfeldt
Browse files
Options
Downloads
Patches
Plain Diff
feat: add self-managed open-state for ADialog component
parent
2f4fc4ee
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/components/generic/ADialog.vue
+32
-14
32 additions, 14 deletions
src/components/generic/ADialog.vue
with
32 additions
and
14 deletions
src/components/generic/ADialog.vue
+
32
−
14
View file @
41c40b01
<
template
>
<
template
>
<dialog
<dialog
v-if=
"
modelValue
"
v-if=
"
isOpen
"
ref=
"dialogEl"
ref=
"dialogEl"
class=
"tw-shadow-xl tw-border tw-border-gray-200 tw-rounded tw-p-0 tw-bg-white tw-z-30 tw-flex tw-flex-col"
class=
"tw-shadow-xl tw-border tw-border-gray-200 tw-rounded tw-p-0 tw-bg-white tw-z-30 tw-flex tw-flex-col"
style=
"max-width: 95%"
style=
"max-width: 95%"
...
@@ -34,17 +34,20 @@
...
@@ -34,17 +34,20 @@
</
template
>
</
template
>
<
script
lang=
"ts"
setup
>
<
script
lang=
"ts"
setup
>
import
{
nextTick
,
ref
,
useSlots
,
watch
}
from
'
vue
'
import
{
computed
,
nextTick
,
ref
,
useSlots
,
watch
}
from
'
vue
'
defineOptions
({
compatConfig
:
{
MODE
:
3
}
})
const
titleClass
=
'
tw-text-lg tw-font-semibold tw-m-0
'
const
titleClass
=
'
tw-text-lg tw-font-semibold tw-m-0
'
const
props
=
withDefaults
(
const
props
=
withDefaults
(
defineProps
<
{
defineProps
<
{
modelValue
:
boolean
modelValue
?
:
boolean
|
undefined
isModal
?:
boolean
isModal
?:
boolean
title
?:
string
title
?:
string
}
>
(),
}
>
(),
{
{
modelValue
:
undefined
,
title
:
''
,
title
:
''
,
isModal
:
false
,
isModal
:
false
,
},
},
...
@@ -53,15 +56,38 @@ const emit = defineEmits<{
...
@@ -53,15 +56,38 @@ const emit = defineEmits<{
(
e
:
'
update:modelValue
'
,
value
:
boolean
):
void
(
e
:
'
update:modelValue
'
,
value
:
boolean
):
void
}
>
()
}
>
()
const
slots
=
useSlots
()
const
slots
=
useSlots
()
const
localIsOpen
=
ref
(
false
)
const
dialogEl
=
ref
<
HTMLDialogElement
>
()
const
dialogEl
=
ref
<
HTMLDialogElement
>
()
const
isOpen
=
computed
({
get
()
{
return
props
.
modelValue
!==
undefined
?
props
.
modelValue
:
localIsOpen
.
value
},
set
(
value
:
boolean
)
{
if
(
props
.
modelValue
!==
undefined
)
{
emit
(
'
update:modelValue
'
,
value
)
}
else
{
localIsOpen
.
value
=
value
}
},
})
function
close
()
{
function
close
()
{
emit
(
'
update:modelValue
'
,
false
)
isOpen
.
value
=
false
}
function
open
()
{
isOpen
.
value
=
true
}
}
defineExpose
({
close
,
open
,
hide
:
close
,
show
:
open
,
})
watch
(
watch
(
()
=>
props
.
modelValue
,
isOpen
,
async
(
isOpen
)
=>
{
async
(
isOpen
)
=>
{
if
(
isOpen
&&
!
dialogEl
.
value
)
{
if
(
isOpen
&&
!
dialogEl
.
value
)
{
await
nextTick
()
await
nextTick
()
...
@@ -83,14 +109,6 @@ watch(
...
@@ -83,14 +109,6 @@ watch(
)
)
</
script
>
</
script
>
<
script
lang=
"ts"
>
export
default
{
compatConfig
:
{
MODE
:
3
,
},
}
</
script
>
<
style
lang=
"postcss"
scoped
>
<
style
lang=
"postcss"
scoped
>
dialog::backdrop {
dialog::backdrop {
background: rgba(0, 0, 0, 0.5);
background: rgba(0, 0, 0, 0.5);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment