File tree Expand file tree Collapse file tree 3 files changed +95
-9
lines changed
Expand file tree Collapse file tree 3 files changed +95
-9
lines changed Original file line number Diff line number Diff line change @@ -435,6 +435,7 @@ Use `<SDescAvatar>` component to display a value using [`<SAvatar>`](./avatar).
435435` ` ` ts
436436interface Props {
437437 avatar? : Avatar | null
438+ dir? : ' column' | ' row'
438439}
439440
440441interface Avatar {
@@ -455,6 +456,31 @@ interface Avatar {
455456</SDesc >
456457` ` `
457458
459+ You may also pass in multiple avatars as an array.
460+
461+ ` ` ` vue -html
462+ <SDesc cols = " 2" gap = " 24" >
463+ <SDescItem span = " 1" >
464+ <SDescLabel value = " Status" />
465+ <SDescAvatar : avatar = " [
466+ { avatar: " /path/to/avatar.jpg" , name: " John Doe" },
467+ { avatar: " /path/to/avatar.jpg" , name: " Jane Doe" }
468+ ]" />
469+ </SDescItem >
470+ </SDesc >
471+ ` ` `
472+
473+ When passing in multiple avatars, you may also define ` : dir ` to control the direction of the avatar stack. The default is set to ` column ` which stacks the avatars vertically. You may set it to ` row ` to stack them horizontally.
474+
475+ ` ` ` vue -html
476+ <SDesc cols = " 2" gap = " 24" >
477+ <SDescItem span = " 1" >
478+ <SDescLabel value = " Status" />
479+ <SDescAvatar dir = " row" : avatar = " avatars" />
480+ </SDescItem >
481+ </SDesc >
482+ ` ` `
483+
458484## File value
459485
460486Use ` <SDescFile >` to display a list of files. Useful when you have a "attachment" list in the form.
Original file line number Diff line number Diff line change 11<script setup lang="ts">
2+ import { computed } from ' vue'
3+ import { isArray } from ' ../support/Utils'
24import SAvatar from ' ./SAvatar.vue'
35import SDescEmpty from ' ./SDescEmpty.vue'
46
@@ -7,28 +9,54 @@ export interface Avatar {
79 name? : string | null
810}
911
10- defineProps <{
11- avatar? : Avatar | null
12- }>()
12+ const props = withDefaults (defineProps <{
13+ avatar? : Avatar | Avatar [] | null
14+ dir? : ' column' | ' row'
15+ }>(), {
16+ dir: ' column'
17+ })
18+
19+ const _avatar = computed (() => {
20+ if (! props .avatar ) {
21+ return null
22+ }
23+
24+ return isArray (props .avatar ) ? props .avatar : [props .avatar ]
25+ })
1326 </script >
1427
1528<template >
16- <div v-if =" avatar " class =" SDescAvatar" >
17- <div class =" value" >
29+ <div v-if =" _avatar?.length " class =" SDescAvatar" :class = " [dir] " >
30+ <div v-for = " a, i in _avatar " :key = " i " class =" value" >
1831 <SAvatar
1932 size =" nano"
20- :avatar =" avatar .avatar"
21- :name =" avatar .name"
33+ :avatar =" a .avatar"
34+ :name =" a .name"
2235 />
23- <span v-if =" avatar .name" class =" name" >
24- {{ avatar .name }}
36+ <span v-if =" a .name" class =" name" >
37+ {{ a .name }}
2538 </span >
2639 </div >
2740 </div >
2841 <SDescEmpty v-else />
2942</template >
3043
3144<style scoped lang="postcss">
45+ .SDescAvatar {
46+ display : flex;
47+ flex-wrap : wrap;
48+ }
49+
50+ .SDescAvatar.column {
51+ flex-direction : column;
52+ gap : 4 px ;
53+ }
54+
55+ .SDescAvatar.row {
56+ flex-direction : row;
57+ gap : 4 px 12 px ;
58+ }
59+
3260.value {
3361 display : flex;
3462 align-items : center;
Original file line number Diff line number Diff line change 1+ <script setup lang="ts">
2+ import SDesc from ' sefirot/components/SDesc.vue'
3+ import SDescAvatar from ' sefirot/components/SDescAvatar.vue'
4+ import SDescItem from ' sefirot/components/SDescItem.vue'
5+ import SDescLabel from ' sefirot/components/SDescLabel.vue'
6+
7+ const title = ' Components / SDesc / 04. Avatar Many'
8+ const docs = ' /components/desc'
9+
10+ const avatars = [
11+ { avatar: ' https://i.pravatar.cc/64?img=1' , name: ' Margot Foster' },
12+ { avatar: ' https://i.pravatar.cc/64?img=2' , name: ' Chris Johna' },
13+ { avatar: ' https://i.pravatar.cc/64?img=3' , name: ' Jenny Wilson' }
14+ ]
15+ </script >
16+
17+ <template >
18+ <Story :title =" title" source =" Not available" auto-props-disabled >
19+ <Board :title =" title" :docs =" docs" >
20+ <SDesc gap =" 24" >
21+ <SDescItem >
22+ <SDescLabel >Vertical stack</SDescLabel >
23+ <SDescAvatar :avatar =" avatars" />
24+ </SDescItem >
25+ <SDescItem >
26+ <SDescLabel >Horizontal stack</SDescLabel >
27+ <SDescAvatar dir =" row" :avatar =" avatars" />
28+ </SDescItem >
29+ </SDesc >
30+ </Board >
31+ </Story >
32+ </template >
You can’t perform that action at this time.
0 commit comments