diff --git a/src/runtime/components/Avatar.vue b/src/runtime/components/Avatar.vue index 44ee12ad..e909ea83 100644 --- a/src/runtime/components/Avatar.vue +++ b/src/runtime/components/Avatar.vue @@ -27,6 +27,10 @@ export interface AvatarProps extends Pick { ui?: Partial } +export interface AvatarSlots { + default(props?: {}): any +} + extendDevtoolsMeta({ defaultProps: { src: 'https://avatars.githubusercontent.com/u/739984?v=4', alt: 'Benjamin Canac' } }) @@ -80,8 +84,10 @@ const sizePx = computed(() => ({ /> - - {{ fallback }} + + + {{ fallback }} + diff --git a/test/components/Avatar.spec.ts b/test/components/Avatar.spec.ts index 681ed417..935f1340 100644 --- a/test/components/Avatar.spec.ts +++ b/test/components/Avatar.spec.ts @@ -1,5 +1,5 @@ import { describe, it, expect } from 'vitest' -import Avatar, { type AvatarProps } from '../../src/runtime/components/Avatar.vue' +import Avatar, { type AvatarProps, type AvatarSlots } from '../../src/runtime/components/Avatar.vue' import ComponentRender from '../component-render' import theme from '#build/ui/avatar' @@ -15,8 +15,10 @@ describe('Avatar', () => { ...sizes.map((size: string) => [`with size ${size}`, { props: { src: 'https://github.com/benjamincanac.png', size } }]), ['with as', { props: { as: 'section' } }], ['with class', { props: { class: 'bg-[var(--ui-bg)]' } }], - ['with ui', { props: { ui: { fallback: 'font-bold' } } }] - ])('renders %s correctly', async (nameOrHtml: string, options: { props?: AvatarProps }) => { + ['with ui', { props: { ui: { fallback: 'font-bold' } } }], + // Slots + ['with default slot', { slots: { default: '🇫🇷' } }] + ])('renders %s correctly', async (nameOrHtml: string, options: { props?: AvatarProps, slots?: AvatarSlots }) => { const html = await ComponentRender(nameOrHtml, options, Avatar) expect(html).toMatchSnapshot() }) diff --git a/test/components/__snapshots__/Avatar-vue.spec.ts.snap b/test/components/__snapshots__/Avatar-vue.spec.ts.snap index 4b54f27c..7f0cd4bf 100644 --- a/test/components/__snapshots__/Avatar-vue.spec.ts.snap +++ b/test/components/__snapshots__/Avatar-vue.spec.ts.snap @@ -10,6 +10,8 @@ exports[`Avatar > renders with as correctly 1`] = ` exports[`Avatar > renders with class correctly 1`] = `""`; +exports[`Avatar > renders with default slot correctly 1`] = `"🇫🇷"`; + exports[`Avatar > renders with icon correctly 1`] = `""`; exports[`Avatar > renders with size 2xl correctly 1`] = `""`; diff --git a/test/components/__snapshots__/Avatar.spec.ts.snap b/test/components/__snapshots__/Avatar.spec.ts.snap index e8c955c0..0c0ed50c 100644 --- a/test/components/__snapshots__/Avatar.spec.ts.snap +++ b/test/components/__snapshots__/Avatar.spec.ts.snap @@ -10,6 +10,8 @@ exports[`Avatar > renders with as correctly 1`] = ` exports[`Avatar > renders with class correctly 1`] = `""`; +exports[`Avatar > renders with default slot correctly 1`] = `"🇫🇷"`; + exports[`Avatar > renders with icon correctly 1`] = `""`; exports[`Avatar > renders with size 2xl correctly 1`] = `""`;