Skip to content

Commit

Permalink
fix(VSpeedDial): position prop styling and transition delay
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed Apr 15, 2024
1 parent 855e57d commit a9272c1
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
22 changes: 22 additions & 0 deletions packages/vuetify/src/labs/VSpeedDial/VSpeedDial.sass
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
.v-speed-dial__content
gap: 8px

&.v-overlay__content
&.v-speed-dial__content--end,
&.v-speed-dial__content--end-center,
&.v-speed-dial__content--right,
&.v-speed-dial__content--right-center
flex-direction: row

&.v-speed-dial__content--left,
&.v-speed-dial__content--left-center,
&.v-speed-dial__content--start,
&.v-speed-dial__content--start-center
flex-direction: row-reverse

&.v-speed-dial__content--top,
&.v-speed-dial__content--top-center
flex-direction: column-reverse

> *
@for $i from 1 through 10
&:nth-child(#{$i})
transition-delay: 0.05s * ($i - 1)
34 changes: 29 additions & 5 deletions packages/vuetify/src/labs/VSpeedDial/VSpeedDial.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,27 @@ import { makeVMenuProps, VMenu } from '@/components/VMenu/VMenu'

// Composables
import { makeComponentProps } from '@/composables/component'
import { makeTransitionProps, MaybeTransition } from '@/composables/transition'
import { MaybeTransition } from '@/composables/transition'

// Utilities
import { ref } from 'vue'
import { computed, ref } from 'vue'
import { genericComponent, propsFactory, useRender } from '@/util'

// Types
import type { ComputedRef } from 'vue'
import type { OverlaySlots } from '@/components/VOverlay/VOverlay'
import type { Anchor } from '@/util'

export const makeVSpeedDialProps = propsFactory({
...makeComponentProps(),
...makeVMenuProps({ offset: 8, minWidth: 0, location: 'top center' as const }),
...makeTransitionProps({ transition: 'fade-transition' }),
...makeVMenuProps({
offset: 8,
minWidth: 0,
openDelay: 0,
closeDelay: 100,
location: 'top center' as const,
transition: 'scale-transition',
}),
}, 'VSpeedDial')

export const VSpeedDial = genericComponent<OverlaySlots>()({
Expand All @@ -30,6 +38,16 @@ export const VSpeedDial = genericComponent<OverlaySlots>()({
setup (props, { slots }) {
const menuRef = ref<VMenu>()

const location = computed(() => {
const [y, x = 'center'] = props.location.split(' ')

return `${y} ${x}`
}) as ComputedRef<Anchor>

const locationClasses = computed(() => ({
[`v-speed-dial__content--${location.value.replace(' ', '-')}`]: true,
}))

useRender(() => {
const menuProps = VMenu.filterProps(props)

Expand All @@ -38,8 +56,13 @@ export const VSpeedDial = genericComponent<OverlaySlots>()({
{ ...menuProps }
class={ props.class }
style={ props.style }
contentClass="v-speed-dial__content"
contentClass={[
'v-speed-dial__content',
locationClasses.value,
]}
location={ location.value }
ref={ menuRef }
transition="fade-transition"
>
{{
...slots,
Expand All @@ -55,6 +78,7 @@ export const VSpeedDial = genericComponent<OverlaySlots>()({
appear
group
transition={ props.transition }
mode="out-in"
>
{ slots.default?.(slotProps) }
</MaybeTransition>
Expand Down

0 comments on commit a9272c1

Please sign in to comment.