Skip to content

Commit ebb1642

Browse files
committed
chore: fix usage + minor tweaks after rebase
1 parent c5b69b9 commit ebb1642

4 files changed

Lines changed: 52 additions & 40 deletions

File tree

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,42 @@
11
<template>
2-
<v-row align="center" justify="center">
3-
<v-col cols="auto">
4-
<v-sheet class="pa-8 d-flex align-center justify-center" color="white" rounded>
5-
<v-morphing-icon :color="color" :icon="icon" size="40"></v-morphing-icon>
6-
</v-sheet>
2+
<div>
3+
<div class="d-flex align-center justify-center ga-6">
4+
<div>
5+
<div class="text-center text-body-small my-2">Light background</div>
6+
<v-sheet class="px-12 py-6" color="white">
7+
<v-morphing-icon
8+
:color="color"
9+
:icon="icon"
10+
size="40"
11+
></v-morphing-icon>
12+
</v-sheet>
13+
</div>
714

8-
<div class="text-center text-caption mt-2">Light background</div>
9-
</v-col>
15+
<div>
16+
<div class="text-center text-body-small my-2">Dark background</div>
17+
<v-sheet class="px-12 py-6" color="grey-darken-4">
18+
<v-morphing-icon
19+
:color="color"
20+
:icon="icon"
21+
size="40"
22+
dark
23+
></v-morphing-icon>
24+
</v-sheet>
25+
</div>
26+
</div>
1027

11-
<v-col cols="auto">
12-
<v-sheet class="pa-8 d-flex align-center justify-center" color="grey-darken-4" rounded>
13-
<v-morphing-icon :color="color" :icon="icon" size="40" dark></v-morphing-icon>
14-
</v-sheet>
15-
16-
<div class="text-center text-caption mt-2">Dark background</div>
17-
</v-col>
18-
19-
<v-col class="text-center" cols="12">
20-
<v-btn text="Change Icon" @click="toggle"></v-btn>
21-
</v-col>
22-
</v-row>
28+
<div class="text-center my-6">
29+
<v-btn text="Change Icon" @click="index++"></v-btn>
30+
</div>
31+
</div>
2332
</template>
2433

2534
<script setup>
26-
import { computed, shallowRef } from 'vue'
35+
import { shallowRef, toRef } from 'vue'
2736
2837
const icons = ['mdi-heart', 'mdi-star', 'mdi-account', 'mdi-home', 'mdi-bell']
2938
const colors = [null, 'primary', 'red', 'purple', '#fc3']
3039
const index = shallowRef(0)
31-
const icon = computed(() => icons[index.value % icons.length])
32-
const color = computed(() => colors[index.value % icons.length])
33-
34-
function toggle () {
35-
index.value++
36-
}
40+
const icon = toRef(() => icons[index.value % icons.length])
41+
const color = toRef(() => colors[index.value % icons.length])
3742
</script>

packages/docs/src/examples/v-morphing-icon/usage.vue

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,19 @@
77
:script="script"
88
>
99
<div class="d-flex flex-column justify-center align-center ga-3">
10-
<v-btn :color="color" icon @click="next">
10+
<v-btn :color="color" size="x-large" icon @click="next">
1111
<v-morphing-icon :icon="icon" v-bind="props"></v-morphing-icon>
1212
</v-btn>
13-
<span class="text-caption">Click to change icon</span>
13+
<span>☝️</span>
14+
<span class="text-body-medium">Click to change icon</span>
1415
</div>
1516

1617
<template v-slot:configuration>
1718
<v-select
1819
v-model="color"
1920
:items="colors"
21+
item-title="title"
22+
item-value="hex"
2023
label="Color"
2124
clearable
2225
></v-select>
@@ -29,19 +32,22 @@
2932
const name = 'v-morphing-icon'
3033
const model = shallowRef('default')
3134
const options = []
32-
import { getForeground, parseColor } from 'vuetify/lib/util/colorUtils'
33-
import { useTheme } from 'vuetify'
34-
35-
const theme = useTheme()
36-
const colors = ['primary', 'secondary', 'success', 'error', 'warning', 'info', 'surface-variant']
35+
const colors = [
36+
{ title: 'Red', hex: '#f44336', isDark: true },
37+
{ title: 'Purple', hex: '#9c27b0', isDark: true },
38+
{ title: 'Blue', hex: '#2196f3', isDark: true },
39+
{ title: 'Lime', hex: '#cddc39', isDark: false },
40+
{ title: 'Orange', hex: '#ff9800', isDark: false },
41+
]
3742
const color = shallowRef()
3843
const dark = shallowRef(false)
3944
4045
watch(color, val => {
41-
if (!val) return
42-
const hex = theme.current.value.colors[color.value]
43-
if (!hex) return
44-
dark.value = getForeground(parseColor(hex)) === '#fff'
46+
if (!val) {
47+
dark.value = false
48+
return
49+
}
50+
dark.value = colors.find(c => c.hex === val)?.isDark ?? false
4551
})
4652
4753
const icons = [
@@ -55,7 +61,7 @@
5561
5662
const props = computed(() => {
5763
return {
58-
dark: dark.value || undefined,
64+
dark: dark.value || (color.value ? false : undefined),
5965
}
6066
})
6167
@@ -84,7 +90,7 @@
8490
8591
const code = computed(() => {
8692
const btnProps = color.value ? ` color="${color.value}"` : ''
87-
return `<v-btn${btnProps} icon @click="next">
93+
return `<v-btn${btnProps} size="x-large" icon @click="next">
8894
<${name} :icon="icon"${propsToString(props.value)}></${name}>
8995
</v-btn>`
9096
})

packages/docs/src/pages/en/components/morphing-icons.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The `v-morphing-icon` component provides smooth animated transitions between ico
2222

2323
::: warning
2424

25-
This feature requires [v4.0.0](/getting-started/release-notes/?version=v4.0.0)
25+
This feature requires [v4.0.1](/getting-started/release-notes/?version=v4.0.1)
2626

2727
:::
2828

packages/vuetify/src/labs/VMorphingIcon/VMorphingIcon.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
&__stack {
1717
overflow: hidden;
1818
filter: contrast(200) blur(0.2px);
19+
margin: -.5px; // hides glow bleading when zoomed in
1920
isolation: isolate;
2021
display: grid;
2122
place-items: center;

0 commit comments

Comments
 (0)