Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(avatar): DLT-1916 remove dt-icon from Avatar vue 2 #474

Merged
merged 15 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions apps/dialtone-documentation/docs/components/avatar.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ figma_url: https://www.figma.com/file/2adf7JhZOncRyjYiy2joil/DT-Core%3A-Componen
<code-well-header>
<div class="d-d-flex d-ai-center d-flow16">
<dt-avatar size="lg">
<template #icon>
<dt-icon name="user" />
<template #icon="{ iconSize }">
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
<dt-avatar size="lg" full-name="dp" color="1000" presence="busy" />
Expand All @@ -24,7 +24,7 @@ figma_url: https://www.figma.com/file/2adf7JhZOncRyjYiy2joil/DT-Core%3A-Componen

## Usage

The Avatar component is designed to prioritize different sources for content display. It will sequentially check for the availability of an image source (`image-src`) or an icon slot. If both are not provided, the avatar will extract and display initials from the full name (`full-name`). The resulting initials are extracted using the following logic:
The Avatar component is designed to prioritize different sources for content display. It will sequentially check for the availability of an image source (`image-src`) or content through the icon slot. If both are not provided, the avatar will extract and display initials from the full name (`full-name`). The resulting initials are extracted using the following logic:

* If the string contains two or more words, the result will be the first character of the first and last word capitalized. E.g.:
`full-name: "Jaqueline Nackos"` will result in: `JN`.
Expand All @@ -51,7 +51,7 @@ The Avatar component is designed to prioritize different sources for content dis
<td>
<dt-avatar>
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
</td>
Expand Down Expand Up @@ -89,7 +89,7 @@ The Avatar component is designed to prioritize different sources for content dis
<code-well-header>
<dt-avatar>
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
</code-well-header>
Expand All @@ -106,7 +106,7 @@ htmlCode='
vueCode='
<dt-avatar>
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
'
Expand Down Expand Up @@ -166,7 +166,7 @@ vueCode='
<div class="d-d-inline-flex d-ai-center d-flow8">
<dt-avatar v-for="size in sizes" :size="size">
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
</div>
Expand Down Expand Up @@ -203,27 +203,27 @@ htmlCode='
vueCode='
<dt-avatar size="xs">
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
<dt-avatar size="sm" icon-name="user">
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
<dt-avatar size="md" icon-name="user">
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
<dt-avatar size="lg" icon-name="user">
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
<dt-avatar size="xl" icon-name="user">
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
'
Expand Down Expand Up @@ -313,7 +313,7 @@ vueCode='
<div class="d-d-flex d-ai-center d-flow16">
<dt-avatar size="lg" image-src="/assets/images/person.png" image-alt="avatar user">
<template #overlayIcon>
<dt-icon name="hear" />
<dt-icon-hear />
</template>
</dt-avatar>
<dt-avatar size="lg" image-src="/assets/images/person.png" image-alt="avatar user" overlay-text="+3" />
Expand All @@ -339,7 +339,7 @@ htmlCode='
vueCode='
<dt-avatar size="lg" image-src="/assets/images/person.png" image-alt="avatar user">
<template #overlayIcon>
<dt-icon name="hear" />
<dt-icon-hear />
</template>
</dt-avatar>
<dt-avatar size="lg" image-src="/assets/images/person.png" image-alt="avatar user" overlay-text="+3" />
Expand All @@ -354,7 +354,7 @@ If you need to create a clickable avatar you can set the clickable prop. This wi
<div class="d-d-flex d-ai-center d-flow16">
<dt-avatar clickable icon-aria-label="user" ref="example-clickable">
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
</div>
Expand All @@ -365,7 +365,7 @@ If you need to create a clickable avatar you can set the clickable prop. This wi
vueCode='
<dt-avatar clickable icon-aria-label="user">
<template #icon="{ iconSize }">
<dt-icon name="user" :size="iconSize" />
<dt-icon-user :size="iconSize" />
</template>
</dt-avatar>
'
Expand Down Expand Up @@ -409,6 +409,8 @@ to [WCAG](https://www.w3.org/WAI/tutorials/images/decorative) references for
your specific usage.

<script setup>
import { DtIconUser, DtIconHear } from '@dialpad/dialtone-icons/vue3';

const colors = ['100', '200', '300', '400', '500', '600', '700', '800', '900', '1000', '1100', '1200', '1300', '1400', '1500', '1600', '1700', '1800'];
const sizes = ['xs', 'sm', 'md', 'lg', 'xl'];
</script>
Binary file removed dialpad-dialtone-9.72.0.tgz
ninamarina marked this conversation as resolved.
Outdated
Show resolved Hide resolved
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
:avatar-class="[{ 'd-mln24': index > 0, 'd-bc-brand': !!avatar.halo }]"
>
<template
v-if="hasAvatarIcon"
#icon="{ iconSize }"
>
<!-- @slot Slot for avatar icon in a list -->
<slot name="avatarIcon" :icon-size="iconSize" />
<slot
v-if="hasAvatarIcon"
name="avatarIcon"
:icon-size="iconSize"
/>
</template>
<template
v-if="avatar.icon"
Expand All @@ -55,11 +58,15 @@
:presence="presence"
>
<template
v-if="hasAvatarIcon"
#icon="{ iconSize }"
>
<!-- @slot Slot for avatar icon in a list -->
<slot name="avatarIcon" :icon-size="iconSize" />
<slot

ninamarina marked this conversation as resolved.
Show resolved Hide resolved
v-if="hasAvatarIcon"
name="avatarIcon"
:icon-size="iconSize"
/>
</template>
</dt-avatar>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#icon
>
<dt-icon-user
:size="'200'"
size="200"
/>
</template>
</dt-avatar>
Expand Down
4 changes: 2 additions & 2 deletions packages/dialtone-vue3/components/avatar/avatar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MOCK_INITIALS = 'JN';
const MOCK_SIZE = 'lg';
const MOCK_GROUP = 25;
const MOCK_CUSTOM_CLASS = 'my-custom-class';
const MOCK_ICON_SLOT = '<template #icon><dt-icon-user /></template>';
const MOCK_ICON_SLOT = '<dt-icon-user />';
let MOCK_ELEMENT = null;

const baseProps = {
Expand All @@ -37,7 +37,7 @@ describe('DtAvatar Tests', () => {
slots: { ...mockSlots },
global: {
components: {
'dt-icon-user': DtIconUser,
DtIconUser,
},
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,14 @@
:avatar-class="[{ 'd-mln24': index > 0, 'd-bc-brand': !!avatar.halo }]"
>
<template
v-if="hasAvatarIcon"
#icon="{ iconSize }"
>
<!-- @slot Slot for avatar icon in a list -->
<slot name="avatarIcon" :icon-size="iconSize" />
<slot
v-if="hasAvatarIcon"
name="avatarIcon"
:icon-size="iconSize"
/>
</template>
<template
v-if="avatar.icon"
Expand All @@ -55,11 +58,14 @@
:presence="presence"
>
<template
v-if="hasAvatarIcon"
#icon="{ iconSize }"
>
<!-- @slot Slot for avatar icon in a list -->
<slot name="avatarIcon" :icon-size="iconSize" />
<slot
v-if="hasAvatarIcon"
name="avatarIcon"
:icon-size="iconSize"
/>
</template>
</dt-avatar>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#icon
>
<dt-icon-user
:size="'200'"
size="200"
/>
</template>
</dt-avatar>
Expand Down
Loading