-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(VSpeedDial): port to v3 (#19308)
Co-authored-by: Kael <kaelwd@gmail.com>
- Loading branch information
1 parent
a98a4ca
commit 736d688
Showing
12 changed files
with
223 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<template> | ||
<ExamplesUsageExample | ||
v-model="model" | ||
:code="code" | ||
:name="name" | ||
:options="options" | ||
> | ||
<v-sheet class="text-center" height="420"> | ||
<v-fab icon="$vuetify" size="large"> | ||
<v-icon></v-icon> | ||
|
||
<v-speed-dial | ||
v-bind="props" | ||
> | ||
<v-btn key="1" icon="$success"></v-btn> | ||
<v-btn key="2" icon="$info"></v-btn> | ||
<v-btn key="3" icon="$warning"></v-btn> | ||
<v-btn key="4" icon="$error"></v-btn> | ||
</v-speed-dial> | ||
</v-fab> | ||
</v-sheet> | ||
|
||
<template v-slot:configuration> | ||
<v-select v-model="location1" :items="locations1" label="Location 1"></v-select> | ||
<v-select v-model="location2" :items="locations2" label="Location 2"></v-select> | ||
<v-select v-model="transition" :items="transitions" label="Transition"></v-select> | ||
</template> | ||
</ExamplesUsageExample> | ||
</template> | ||
|
||
<script setup> | ||
const name = 'v-speed-dial' | ||
const model = shallowRef('default') | ||
const options = [] | ||
const location1 = shallowRef('Bottom') | ||
const locations1 = ['Top', 'Bottom', 'Left', 'Right'] | ||
const location2 = shallowRef('Center') | ||
const locations2 = ['Top', 'Bottom', 'Center', 'Left', 'Right'] | ||
const location = computed(() => `${location1.value.toLowerCase()} ${location2.value.toLowerCase()}`) | ||
const transition = shallowRef('fade-transition') | ||
const transitions = ['scale-transition', 'slide-x-transition', 'slide-y-transition', 'slide-x-reverse-transition', 'slide-y-reverse-transition'] | ||
const props = computed(() => { | ||
return { | ||
activator: 'parent', | ||
location: location.value, | ||
transition: transition.value, | ||
} | ||
}) | ||
const slots = computed(() => { | ||
return ` | ||
<template v-slot:activator="{ props: activatorProps }"> | ||
<v-fab | ||
v-bind="activatorProps" | ||
size="large" | ||
icon="$vuetify" | ||
></v-fab> | ||
</template> | ||
<v-btn key="1" icon="$success"></v-btn> | ||
<v-btn key="2" icon="$info"></v-btn> | ||
<v-btn key="3" icon="$warning"></v-btn> | ||
<v-btn key="4" icon="$error"></v-btn> | ||
` | ||
}) | ||
const code = computed(() => { | ||
return `<${name}${propsToString(props.value)}>${slots.value}</${name}>` | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
emphasized: true | ||
meta: | ||
nav: Speed Dials | ||
title: Speed Dial component | ||
description: The speed dial component is a floating action button that can reveal additional actions when clicked. | ||
keywords: speed dial, fab, vuetify speed dial component, vue speed dial component | ||
related: | ||
- /components/buttons/ | ||
- /components/icons/ | ||
- /styles/transitions/ | ||
features: | ||
report: true | ||
--- | ||
|
||
# Speed Dials | ||
|
||
The `v-speed-dial` component can be used as a floating action button that can reveal additional actions when clicked. | ||
|
||
<PageFeatures /> | ||
|
||
::: warning | ||
|
||
This feature requires [v3.5.8](/getting-started/release-notes/?version=v3.5.8) | ||
|
||
::: | ||
|
||
## Installation | ||
|
||
Labs components require a manual import and installation of the component. | ||
|
||
```js { resource="src/plugins/vuetify.js" } | ||
import { VSpeedDial } from 'vuetify/labs/VSpeedDial' | ||
|
||
export default createVuetify({ | ||
components: { | ||
VSpeedDial, | ||
}, | ||
}) | ||
``` | ||
|
||
## Usage | ||
|
||
Speed dials can be attached to material to signify a promoted action in your application. The default size will be used in most cases, whereas the `small` variant can be used to maintain continuity with similar sized elements. | ||
|
||
<ExamplesUsage name="v-speed-dial" /> | ||
|
||
<PromotedEntry /> | ||
|
||
## API | ||
|
||
| Component | Description | | ||
| - | - | | ||
| [v-speed-dial](/api/v-speed-dial/) | Primary Component | | ||
|
||
<ApiInline hide-links /> | ||
|
||
### Guide | ||
|
||
Coming soon. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ | |
vertical-align: middle | ||
|
||
.v-fab--app & | ||
margin: 4px | ||
margin: 12px | ||
|
||
.v-fab--absolute & | ||
position: absolute | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.v-speed-dial__content | ||
gap: 8px |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Styles | ||
import './VSpeedDial.sass' | ||
|
||
// Components | ||
import { VDefaultsProvider } from '@/components/VDefaultsProvider' | ||
import { makeVMenuProps, VMenu } from '@/components/VMenu/VMenu' | ||
|
||
// Composables | ||
import { makeComponentProps } from '@/composables/component' | ||
import { makeTransitionProps, MaybeTransition } from '@/composables/transition' | ||
|
||
// Utilities | ||
import { genericComponent, propsFactory, useRender } from '@/util' | ||
|
||
export const makeVSpeedDialProps = propsFactory({ | ||
...makeComponentProps(), | ||
...makeVMenuProps({ offset: 8, minWidth: 0, location: 'top center' as const }), | ||
...makeTransitionProps({ transition: 'fade-transition' }), | ||
}, 'VSpeedDial') | ||
|
||
export const VSpeedDial = genericComponent()({ | ||
name: 'VSpeedDial', | ||
|
||
props: makeVSpeedDialProps(), | ||
|
||
setup (props, { slots }) { | ||
useRender(() => { | ||
const menuProps = VMenu.filterProps(props) | ||
|
||
return ( | ||
<VMenu | ||
{ ...menuProps } | ||
class={ props.class } | ||
style={ props.style } | ||
contentClass="v-speed-dial__content" | ||
> | ||
<VDefaultsProvider | ||
defaults={{ | ||
VBtn: { | ||
size: 'small', | ||
}, | ||
}} | ||
> | ||
<MaybeTransition | ||
appear | ||
group | ||
transition={ props.transition } | ||
> | ||
{ slots.default?.() } | ||
</MaybeTransition> | ||
</VDefaultsProvider> | ||
</VMenu> | ||
) | ||
}) | ||
|
||
return {} | ||
}, | ||
}) | ||
|
||
export type VSpeedDial = InstanceType<typeof VSpeedDial> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { VSpeedDial } from './VSpeedDial' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters