-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(avatar): add border when no image is defined
- Loading branch information
Showing
5 changed files
with
160 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<script setup lang="ts"> | ||
import SAvatar from 'sefirot/components/SAvatar.vue' | ||
</script> | ||
|
||
# SAvatar | ||
|
||
`<SAvatar>` is a common avatar displaying component. | ||
|
||
<Showcase | ||
path="/components/SAvatar.vue" | ||
story="/stories-components-savatar-01-playground-story-vue" | ||
> | ||
<div class="flex flex-wrap gap-16"> | ||
<SAvatar avatar="https://avatars.githubusercontent.com/u/3753672?v=4" /> | ||
<SAvatar avatar="https://avatars.githubusercontent.com/u/62658104?v=4" /> | ||
<SAvatar avatar="https://avatars.githubusercontent.com/u/16436160?v=4" /> | ||
<SAvatar name="John Doe" /> | ||
<SAvatar name="Anna Green" /> | ||
<SAvatar name="George Walsh" /> | ||
</div> | ||
</Showcase> | ||
## Usage | ||
|
||
Import `<SAvatar>` component and pass in either the image or a name. When the image is passed, the image gets displayed, and when passing a name, the initial of the name will be used. | ||
|
||
```vue | ||
<script setup lang="ts"> | ||
import SAvatar from '@globalbrain/sefirot/lib/components/SAvatar.vue' | ||
</script> | ||
<template> | ||
<SAvatar avatar="/path/to/image.jpg" /> | ||
<SAvatar name="John Doe" /> | ||
</template> | ||
``` | ||
|
||
## Props | ||
|
||
Here are the list of props you may pass to the component. | ||
|
||
### `size` | ||
|
||
Defines the size of the component. The default is `medium`. | ||
|
||
```ts | ||
interface Props { | ||
size?: 'nano' | 'mini' | 'small' | 'medium' | 'large' | ||
} | ||
``` | ||
|
||
```vue | ||
<SAvatar size="medium" image="/image.jpg" /> | ||
``` | ||
|
||
### `avatar` | ||
|
||
The path to the image. | ||
|
||
```ts | ||
interface Props { | ||
avatar?: string | null | ||
} | ||
``` | ||
|
||
```vue | ||
<SAvatar image="/image.jpg" /> | ||
``` | ||
|
||
### `name` | ||
|
||
The name of the avatar user. The initial value of the name gets displayed. When `avatar` prop is set, this value gets ignored. | ||
|
||
```ts | ||
interface Props { | ||
name?: string | null | ||
} | ||
``` | ||
|
||
```vue | ||
<SAvatar name="John Doe" /> | ||
``` |
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,11 +1,34 @@ | ||
<script setup lang="ts"> | ||
import SAvatar from 'sefirot/components/SAvatar.vue' | ||
const variants = [ | ||
{ title: 'Nano', size: 'nano' }, | ||
{ title: 'Mini', size: 'mini' }, | ||
{ title: 'Small', size: 'small' }, | ||
{ title: 'Medium', size: 'medium' }, | ||
{ title: 'Large', size: 'large' } | ||
] as const | ||
</script> | ||
|
||
<template> | ||
<Board | ||
title="Components / SAvatar / 01. Playground" | ||
docs="/components/button" | ||
> | ||
<SAvatar name="John Doe" /> | ||
<div class="grid gap-y-32"> | ||
<div v-for="v in variants" :key="v.size" class="grid gap-y-12"> | ||
<div class="leading-24 text-14 font-500 text-c-2"> | ||
{{ v.title }} | ||
</div> | ||
<div class="flex flex-wrap gap-16"> | ||
<SAvatar :size="v.size" avatar="https://avatars.githubusercontent.com/u/3753672?v=4" /> | ||
<SAvatar :size="v.size" avatar="https://avatars.githubusercontent.com/u/62658104?v=4" /> | ||
<SAvatar :size="v.size" avatar="https://avatars.githubusercontent.com/u/16436160?v=4" /> | ||
<SAvatar :size="v.size" name="John Doe" /> | ||
<SAvatar :size="v.size" name="Anna Green" /> | ||
<SAvatar :size="v.size" name="George Walsh" /> | ||
</div> | ||
</div> | ||
</div> | ||
</Board> | ||
</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