Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Slideover): preset support #68

Merged
merged 5 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/pages/migration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const components = [
label: 'AvatarGroup',
to: '/components/AvatarGroup',
nuxt3: true,
capi: true,
typescript: true
},
{
Expand Down Expand Up @@ -129,6 +130,7 @@ const components = [
label: 'Alert',
to: '/components/Alert',
nuxt3: true,
capi: true,
typescript: true
},
{
Expand Down Expand Up @@ -181,6 +183,8 @@ const components = [
{
label: 'SelectCustom',
to: '/components/SelectCustom',
capi: true,
preset: true,
typescript: true
},
{
Expand Down Expand Up @@ -265,6 +269,7 @@ const components = [
to: '/components/Slideover',
nuxt3: true,
capi: true,
preset: true,
typescript: true
},
{
Expand Down
6 changes: 5 additions & 1 deletion src/runtime/components/overlays/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
leave-from="opacity-100"
leave-to="opacity-0"
>
<div class="fixed inset-0 bg-gray-500/75 dark:bg-gray-600/75 transition-opacity" />
<div class="fixed inset-0 transition-opacity" :class="overlayClass" />
</TransitionChild>

<div class="fixed inset-0 overflow-y-auto">
Expand Down Expand Up @@ -77,6 +77,10 @@ const props = defineProps({
type: String,
default: () => $ui.modal.background
},
overlayClass: {
type: String,
default: () => $ui.modal.overlay
},
shadowClass: {
type: String,
default: () => $ui.modal.shadow
Expand Down
42 changes: 36 additions & 6 deletions src/runtime/components/overlays/Slideover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
leave-from="opacity-100"
leave-to="opacity-0"
>
<div class="fixed inset-0 bg-gray-500/75 dark:bg-gray-600/75 transition-opacity" />
<div class="fixed inset-0 transition-opacity" :class="overlayClass" />
</TransitionChild>

<TransitionChild
Expand All @@ -28,9 +28,9 @@
leave-from="translate-x-0"
:leave-to="side === 'left' ? '-translate-x-full' : 'translate-x-full'"
>
<DialogPanel class="relative flex-1 flex flex-col w-full max-w-md u-bg-white focus:outline-none" :class="panelClass">
<div v-if="$slots.header" class="border-b u-border-gray-200">
<div class="flex items-center justify-between px-4 sm:px-6 h-16">
<DialogPanel :class="slideoverClass">
<div v-if="$slots.header" :class="headerWrapperClass">
<div :class="headerClass">
<slot name="header" />
</div>
</div>
Expand All @@ -45,6 +45,8 @@
import { computed } from 'vue'
import type { WritableComputedRef, PropType } from 'vue'
import { Dialog, DialogPanel, TransitionRoot, TransitionChild } from '@headlessui/vue'
import { classNames } from '../../utils/'
import $ui from '#build/ui'

const props = defineProps({
modelValue: {
Expand All @@ -56,9 +58,29 @@ const props = defineProps({
default: 'left',
validator: (value: string) => ['left', 'right'].includes(value)
},
panelClass: {
baseClass: {
type: String,
default: 'max-w-md'
default: () => $ui.slideover.base
},
backgroundClass: {
type: String,
default: () => $ui.slideover.background
},
overlayClass: {
type: String,
default: () => $ui.slideover.overlay
},
widthClass: {
type: String,
default: () => $ui.slideover.width
},
headerWrapperClass: {
type: String,
default: () => $ui.slideover.header.wrapper
},
headerClass: {
type: String,
default: () => $ui.slideover.header.base
}
})
const emit = defineEmits(['update:modelValue'])
Expand All @@ -71,6 +93,14 @@ const isOpen: WritableComputedRef<boolean> = computed({
emit('update:modelValue', value)
}
})

const slideoverClass = computed(() => {
return classNames(
props.baseClass,
props.widthClass,
props.backgroundClass
)
})
</script>

<script lang="ts">
Expand Down
15 changes: 14 additions & 1 deletion src/runtime/presets/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export default (variantColors: string[]) => {
const modal = {
base: 'relative inline-block align-bottom text-left overflow-hidden transform transition-all sm:my-8 sm:align-middle w-full',
background: 'u-bg-white',
overlay: 'bg-gray-500/75 dark:bg-gray-600/75',
border: '',
ring: '',
rounded: 'rounded-lg',
Expand Down Expand Up @@ -372,6 +373,17 @@ export default (variantColors: string[]) => {
}
}

const slideover = {
overlay: 'bg-gray-500/75 dark:bg-gray-600/75',
base: 'relative flex-1 flex flex-col w-full focus:outline-none',
background: 'u-bg-white',
width: 'max-w-md',
header: {
wrapper: 'border-b u-border-gray-200',
base: 'flex items-center justify-between px-4 sm:px-6 h-16'
}
}

return {
card,
modal,
Expand All @@ -391,6 +403,7 @@ export default (variantColors: string[]) => {
dropdown,
tabs,
pills,
avatar
avatar,
slideover
}
}