fix(a11y): make modal actions responsive (wrap on slim screens)
This commit is contained in:
parent
abf29eeffe
commit
b27d34bbbf
|
@ -1,10 +1,11 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { type ColorProps, type DefaultProps, color } from '~/composables/color';
|
import { type ColorProps, type DefaultProps, color } from '~/composables/color';
|
||||||
import { watchEffect, computed, useSlots } from 'vue';
|
import { watchEffect } from 'vue';
|
||||||
import onKeyboardShortcut from '~/composables/onKeyboardShortcut';
|
import onKeyboardShortcut from '~/composables/onKeyboardShortcut';
|
||||||
|
|
||||||
import Button from '~/components/ui/Button.vue'
|
import Button from '~/components/ui/Button.vue'
|
||||||
import Spacer from '~/components/ui/Spacer.vue'
|
import Spacer from '~/components/ui/Spacer.vue'
|
||||||
|
import Layout from '~/components/ui/Layout.vue'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
title: string,
|
title: string,
|
||||||
|
@ -12,19 +13,13 @@ const props = defineProps<{
|
||||||
destructive?: true
|
destructive?: true
|
||||||
} & (ColorProps | DefaultProps)>()
|
} & (ColorProps | DefaultProps)>()
|
||||||
|
|
||||||
const slots = useSlots()
|
|
||||||
const isOpen = defineModel<boolean>({ default:false })
|
const isOpen = defineModel<boolean>({ default:false })
|
||||||
|
|
||||||
const modalClasses = computed(() => ({
|
|
||||||
'is-destructive': props.destructive,
|
|
||||||
'has-alert': !!slots.alert,
|
|
||||||
'over-popover': props.overPopover
|
|
||||||
}))
|
|
||||||
|
|
||||||
watchEffect(() =>
|
watchEffect(() =>
|
||||||
isOpen.value ?
|
isOpen.value
|
||||||
document.querySelector('#app')?.setAttribute('inert', 'true') : document.querySelector('#app')?.removeAttribute('inert')
|
? document.querySelector('#app')?.setAttribute('inert', 'true')
|
||||||
)
|
: document.querySelector('#app')?.removeAttribute('inert')
|
||||||
|
)
|
||||||
|
|
||||||
onKeyboardShortcut('escape', () => isOpen.value = false)
|
onKeyboardShortcut('escape', () => isOpen.value = false)
|
||||||
|
|
||||||
|
@ -43,8 +38,10 @@ onKeyboardShortcut('escape', () => isOpen.value = false)
|
||||||
<div @click.stop
|
<div @click.stop
|
||||||
class="funkwhale modal"
|
class="funkwhale modal"
|
||||||
:class="[
|
:class="[
|
||||||
modalClasses,
|
{ 'is-destructive': destructive,
|
||||||
{ 'destructive': destructive }
|
'has-alert': !!$slots.alert,
|
||||||
|
'over-popover': overPopover,
|
||||||
|
}
|
||||||
]"
|
]"
|
||||||
v-bind="color(props)"
|
v-bind="color(props)"
|
||||||
>
|
>
|
||||||
|
@ -68,9 +65,9 @@ onKeyboardShortcut('escape', () => isOpen.value = false)
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
<div v-if="$slots.actions" class="modal-actions">
|
<Layout flex gap-12 style="flex-wrap: wrap;" v-if="$slots.actions" class="modal-actions">
|
||||||
<slot name="actions" />
|
<slot name="actions" />
|
||||||
</div>
|
</Layout>
|
||||||
<Spacer :size="64" v-else />
|
<Spacer :size="64" v-else />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue