-
-
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: update v-avatar to v3 (#13265)
Co-authored-by: John Leider <john.j.leider@gmail.com>
- Loading branch information
1 parent
edc2db9
commit 18ef431
Showing
16 changed files
with
144 additions
and
137 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,23 @@ | ||
<template> | ||
<v-row justify="space-around"> | ||
<v-avatar | ||
color="indigo" | ||
size="36" | ||
color="primary" | ||
size="x-small" | ||
> | ||
<span class="white--text headline">36</span> | ||
<span class="headline">32</span> | ||
</v-avatar> | ||
|
||
<v-avatar | ||
color="teal" | ||
size="48" | ||
color="secondary" | ||
> | ||
<span class="white--text headline">48</span> | ||
<span class="headline">48</span> | ||
</v-avatar> | ||
|
||
<v-avatar | ||
color="orange" | ||
size="62" | ||
color="info" | ||
size="x-large" | ||
> | ||
<span class="white--text headline">62</span> | ||
<span class="headline">64</span> | ||
</v-avatar> | ||
</v-row> | ||
</template> |
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
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 was deleted.
Oops, something went wrong.
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,51 @@ | ||
// Styles | ||
import './VAvatar.sass' | ||
|
||
// Composables | ||
import { makeBorderRadiusProps, useBorderRadius } from '@/composables/border-radius' | ||
import { makeSizeProps, useSize } from '@/composables/size' | ||
import { makeTagProps } from '@/composables/tag' | ||
import { useBackgroundColor } from '@/composables/color' | ||
|
||
// Utilities | ||
import { defineComponent, toRef } from 'vue' | ||
|
||
export default defineComponent({ | ||
name: 'VAvatar', | ||
|
||
props: { | ||
...makeBorderRadiusProps(), | ||
...makeSizeProps(), | ||
...makeTagProps(), | ||
color: String, | ||
left: Boolean, | ||
right: Boolean, | ||
}, | ||
|
||
setup (props, { slots }) { | ||
const { backgroundColorClasses, backgroundColorStyles } = useBackgroundColor(toRef(props, 'color')) | ||
const { borderRadiusClasses } = useBorderRadius(props) | ||
const { sizeClasses, sizeStyles } = useSize(props, 'v-avatar') | ||
|
||
return () => ( | ||
<props.tag | ||
class={[ | ||
'v-avatar', | ||
{ | ||
'v-avatar--left': props.left, | ||
'v-avatar--right': props.right, | ||
}, | ||
backgroundColorClasses.value, | ||
borderRadiusClasses.value, | ||
sizeClasses.value, | ||
]} | ||
style={[ | ||
backgroundColorStyles.value, | ||
sizeStyles.value, | ||
]} | ||
> | ||
{ slots.default?.() } | ||
</props.tag> | ||
) | ||
}, | ||
}) |
47 changes: 17 additions & 30 deletions
47
packages/vuetify/src/components/VAvatar/__tests__/VAvatar.spec.ts
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 |
---|---|---|
@@ -1,38 +1,25 @@ | ||
// @ts-nocheck | ||
/* eslint-disable */ | ||
|
||
// Libraries | ||
// import Vue from 'vue' | ||
|
||
// Components | ||
// import VAvatar from '../VAvatar' | ||
import { VAvatar } from '..' | ||
|
||
// Utilities | ||
import { | ||
createLocalVue, | ||
mount, | ||
Wrapper, | ||
} from '@vue/test-utils' | ||
|
||
describe.skip('VAvatar', () => { | ||
let mountFunction: (options?: object) => Wrapper<Vue> | ||
let localVue: typeof Vue | ||
|
||
beforeEach(() => { | ||
localVue = createLocalVue() | ||
|
||
mountFunction = (options = {}) => { | ||
return mount(VAvatar, { | ||
localVue, | ||
...options, | ||
}) | ||
} | ||
}) | ||
|
||
it('should have an v-avatar class', () => { | ||
import { createVuetify } from '@/framework' | ||
import { mount } from '@vue/test-utils' | ||
|
||
describe('VAvatar', () => { | ||
const vuetify = createVuetify() | ||
|
||
function mountFunction (options = {}) { | ||
return mount(VAvatar, { | ||
global: { | ||
plugins: [vuetify], | ||
}, | ||
...options, | ||
}) | ||
} | ||
|
||
it('should match a snapshot', () => { | ||
const wrapper = mountFunction() | ||
|
||
expect(wrapper.classes()).toContain('v-avatar') | ||
expect(wrapper.html()).toMatchSnapshot() | ||
}) | ||
}) |
6 changes: 2 additions & 4 deletions
6
packages/vuetify/src/components/VAvatar/__tests__/__snapshots__/VAvatar.spec.ts.snap
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`VAvatar should have an v-avatar class 1`] = ` | ||
<div class="v-avatar" | ||
style="height: 48px; min-width: 48px; width: 48px;" | ||
> | ||
exports[`VAvatar should match a snapshot 1`] = ` | ||
<div class="v-avatar v-avatar--size-default"> | ||
</div> | ||
`; |
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 |
---|---|---|
@@ -1,3 +1,17 @@ | ||
@import '../../styles/styles.sass'; | ||
|
||
$avatar-border-radius: 50% !default; | ||
$avatar-line-height: normal !default; | ||
$avatar-vertical-align: middle !default; | ||
|
||
$avatar-sizes: () !default; | ||
$avatar-sizes: map-deep-merge( | ||
( | ||
'x-small': 32px, | ||
'small': 40px, | ||
'default': 48px, | ||
'large': 56px, | ||
'x-large': 64px, | ||
), | ||
$avatar-sizes | ||
); |
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 |
---|---|---|
@@ -1,4 +1 @@ | ||
import VAvatar from './VAvatar' | ||
|
||
export { VAvatar } | ||
export default VAvatar | ||
export { default as VAvatar } from './VAvatar' |
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
Oops, something went wrong.