Skip to content

Commit 111e29a

Browse files
authored
Merge pull request #1419 from privy-open-source/feat/avatar-square
feat(avatar): create avatar square-round type variant
2 parents 4c152f7 + b23963b commit 111e29a

File tree

8 files changed

+145
-21
lines changed

8 files changed

+145
-21
lines changed

src/components/accordion/Accordion.vue

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,16 @@ const classNames = computed(() => {
7777

7878
<style lang="postcss">
7979
.accordion {
80+
--p-accordion-border: theme(borderColor.default.DEFAULT);
81+
--p-accordion-border-dark: theme(borderColor.dark.default.DEFAULT);
82+
--p-accordion-item-border: theme(borderColor.default.DEFAULT);
83+
--p-accordion-item-border-dark: theme(borderColor.dark.default.DEFAULT);
84+
--p-accordion-divide: theme(divideColor.default.DEFAULT);
85+
--p-accordion-divide-dark: theme(divideColor.dark.default.DEFAULT);
86+
8087
@apply flex flex-col w-full;
81-
@apply border border-default rounded;
82-
@apply dark:border-dark-default;
88+
@apply border border-[var(--p-accordion-border)] rounded;
89+
@apply dark:border-[var(--p-accordion-border-dark)];
8390
8491
& > &__item {
8592
@apply first:rounded-t last:rounded-b;
@@ -89,14 +96,18 @@ const classNames = computed(() => {
8996
@apply gap-2 border-0 rounded-none;
9097
9198
> .accordion__item {
92-
@apply border rounded border-default;
93-
@apply dark:border-dark-default;
99+
@apply border rounded border-[var(--p-accordion-item-border)];
100+
@apply dark:border-[var(--p-accordion-item-border-dark)];
101+
102+
> .accordion__item__activator {
103+
@apply rounded-t-sm;
104+
}
94105
}
95106
}
96107
97108
&:not(&--pills) {
98-
@apply divide-y divide-default;
99-
@apply dark:divide-dark-default;
109+
@apply divide-y divide-[var(--p-accordion-divide)];
110+
@apply dark:divide-[var(--p-accordion-divide-dark)];
100111
}
101112
102113
&--flush {

src/components/accordion/AccordionItem.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ defineSlots<{
191191
--p-accordion-expanded-border-dark: theme(borderColor.dark.default.DEFAULT);
192192
--p-accordion-expanded-activator-bg: theme(backgroundColor.default.alpha);
193193
--p-accordion-expanded-activator-bg-dark: theme(backgroundColor.dark.default.alpha);
194+
--p-accordion-expanded-activator-color: theme(textColor.default);
195+
--p-accordion-expanded-activator-color-dark: theme(textColor.dark.default);
194196
195197
@apply w-full bg-[color:var(--p-accordion-bg)];
196198
@apply dark:bg-[color:var(--p-accordion-bg-dark)];
@@ -220,6 +222,12 @@ defineSlots<{
220222
.expanded & {
221223
@apply bg-[color:var(--p-accordion-expanded-activator-bg)];
222224
@apply dark:bg-[color:var(--p-accordion-expanded-activator-bg-dark)];
225+
226+
.accordion__item__title,
227+
.subheading {
228+
@apply text-[color:var(--p-accordion-expanded-activator-color)];
229+
@apply dark:text-[color:var(--p-accordion-expanded-activator-color-dark)];
230+
}
223231
}
224232
}
225233

src/components/accordion/index.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,19 @@ const expanded = ref(false)
559559
```
560560

561561
## Variables
562-
Accordion use local CSS variables on `.accordion__item` for enhanced real-time customization.
562+
Accordion use local CSS variables on `.accordion` and `.accordion__item` for enhanced real-time customization.
563+
564+
### .accordion
565+
```sass
566+
--p-accordion-border: theme(borderColor.default.DEFAULT);
567+
--p-accordion-border-dark: theme(borderColor.dark.default.DEFAULT);
568+
--p-accordion-item-border: theme(borderColor.default.DEFAULT);
569+
--p-accordion-item-border-dark: theme(borderColor.dark.default.DEFAULT);
570+
--p-accordion-divide: theme(divideColor.default.DEFAULT);
571+
--p-accordion-divide-dark: theme(divideColor.dark.default.DEFAULT);
572+
```
573+
574+
### .accordion__item
563575

564576
```sass
565577
--p-accordion-bg: theme(backgroundColor.default.DEFAULT);
@@ -570,8 +582,11 @@ Accordion use local CSS variables on `.accordion__item` for enhanced real-time c
570582
--p-accordion-expanded-border-dark: theme(borderColor.dark.default.DEFAULT);
571583
--p-accordion-expanded-activator-bg: theme(backgroundColor.default.alpha);
572584
--p-accordion-expanded-activator-bg-dark: theme(backgroundColor.dark.default.alpha);
585+
--p-accordion-expanded-activator-color: theme(textColor.default);
586+
--p-accordion-expanded-activator-color-dark: theme(textColor.dark.default);
573587
```
574588

589+
575590
## API
576591

577592
### Props `<p-accordion>`

src/components/avatar/Avatar.spec.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ it('should emit event "imgerror" when image fail to load', async () => {
191191
)
192192
})
193193

194-
it('should have addiotional class if prop imgClass if provided', () => {
194+
it('should have additional class if prop imgClass if provided', () => {
195195
const screen = render({
196196
components: { Avatar },
197197
template : `
@@ -206,3 +206,17 @@ it('should have addiotional class if prop imgClass if provided', () => {
206206
expect(image).toHaveClass('custom-class')
207207
expect(avatar).not.toHaveClass('custom-class')
208208
})
209+
210+
it('should have style `square` when `square` prop was provided', () => {
211+
const screen = render({
212+
components: { Avatar },
213+
template : `
214+
<Avatar square />
215+
`,
216+
})
217+
218+
const avatar = screen.queryByTestId('avatar')
219+
220+
expect(avatar).toBeInTheDocument()
221+
expect(avatar).toHaveClass('avatar--square')
222+
})

src/components/avatar/Avatar.vue

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ const props = defineProps({
6161
],
6262
default: undefined,
6363
},
64+
square: {
65+
type : Boolean,
66+
default: false,
67+
},
6468
})
6569
6670
const emit = defineEmits<{
@@ -77,6 +81,9 @@ const classNames = computed(() => {
7781
if (props.size)
7882
result.push(`avatar--${props.size}`)
7983
84+
if (props.square)
85+
result.push('avatar--square')
86+
8087
return result
8188
})
8289
@@ -131,9 +138,13 @@ onMounted(() => {
131138

132139
<style lang="postcss">
133140
.avatar {
134-
@apply rounded-full inline-flex items-center justify-center overflow-hidden text-subtle bg-subtle;
141+
@apply inline-flex items-center justify-center overflow-hidden text-subtle bg-subtle;
135142
@apply dark:text-dark-subtle dark:bg-dark-subtle;
136143
144+
&:not(&--square) {
145+
@apply rounded-full;
146+
}
147+
137148
&__image {
138149
@apply w-full h-full object-cover;
139150
}
@@ -157,5 +168,26 @@ onMounted(() => {
157168
&--xl {
158169
@apply w-24 h-24 text-lg;
159170
}
171+
172+
&--square {
173+
&.avatar {
174+
&--xs {
175+
@apply rounded-xs;
176+
}
177+
178+
&--sm {
179+
@apply rounded-sm;
180+
}
181+
182+
&--md {
183+
@apply rounded;
184+
}
185+
186+
&--lg,
187+
&--xl {
188+
@apply rounded-md;
189+
}
190+
}
191+
}
160192
}
161193
</style>

src/components/avatar/index.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ description: Show user's avatar, using name or image
77
import pAvatar from './Avatar.vue'
88
import pAvatarGroup from './AvatarGroup.vue'
99
import IconUser from '@privyid/persona-icon/vue/profile/20.vue'
10+
import IconGroup from '@privyid/persona-icon/vue/chat/24.vue'
11+
import pBanner from '../banner/Banner.vue'
1012
</script>
1113

1214
# Avatar
@@ -59,18 +61,48 @@ description: Show user's avatar, using name or image
5961
</script>
6062
```
6163

64+
## Square round
65+
Avatar also comes in square-round type variant. Just using `square` prop
66+
to enable this type variant.
67+
68+
<p-banner :dismissable="false">
69+
Use square-round type variant of avatars only to represent an entity, e.g. group chat avatar.
70+
Avatar square-round can't be used to represent a user.
71+
</p-banner>
72+
73+
<preview>
74+
<p-avatar square>
75+
<IconGroup />
76+
</p-avatar>
77+
</preview>
78+
79+
```vue
80+
<template>
81+
<p-avatar square>
82+
<IconChatGroup />
83+
</p-avatar>
84+
</template>
85+
```
86+
6287
## Sizing
6388

6489
There are 5 available size variant: `xs`, `sm`, `md`, `lg`, `xl`. The default is `md`.
6590

66-
<preview>
91+
<preview class="flex-col space-y-4">
6792
<div class="flex flex-col items-center space-gap-3 lg:flex-row">
6893
<p-avatar src="https://picsum.photos/id/24/24" size="xs" />
6994
<p-avatar src="https://picsum.photos/id/32/32" size="sm" />
7095
<p-avatar src="https://picsum.photos/id/40/40" size="md" />
7196
<p-avatar src="https://picsum.photos/id/56/56" size="lg" />
7297
<p-avatar src="https://picsum.photos/id/96/96" size="xl" />
7398
</div>
99+
<div class="flex flex-col items-center space-gap-3 lg:flex-row">
100+
<p-avatar src="https://picsum.photos/id/96/96" size="xl" square />
101+
<p-avatar src="https://picsum.photos/id/56/56" size="lg" square />
102+
<p-avatar src="https://picsum.photos/id/40/40" size="md" square />
103+
<p-avatar src="https://picsum.photos/id/32/32" size="sm" square />
104+
<p-avatar src="https://picsum.photos/id/24/24" size="xs" square />
105+
</div>
74106
</preview>
75107

76108
```vue
@@ -80,6 +112,12 @@ There are 5 available size variant: `xs`, `sm`, `md`, `lg`, `xl`. The default is
80112
<p-avatar src="https://picsum.photos/id/40/40" size="md" />
81113
<p-avatar src="https://picsum.photos/id/56/56" size="lg" />
82114
<p-avatar src="https://picsum.photos/id/96/96" size="xl" />
115+
116+
<p-avatar src="https://picsum.photos/id/96/96" size="xl" square />
117+
<p-avatar src="https://picsum.photos/id/56/56" size="lg" square />
118+
<p-avatar src="https://picsum.photos/id/40/40" size="md" square />
119+
<p-avatar src="https://picsum.photos/id/32/32" size="sm" square />
120+
<p-avatar src="https://picsum.photos/id/24/24" size="xs" square />
83121
</template>
84122
```
85123

src/components/notify/NotifyGroup.vue

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,6 @@ defineExpose({
121121
}
122122
123123
&--top-right {
124-
@apply top-2 right-4;
125-
126124
.notify-group__container {
127125
@apply items-end;
128126
}
@@ -136,7 +134,7 @@ defineExpose({
136134
}
137135
138136
&--top-center {
139-
@apply top-2 left-1/2 -translate-x-1/2;
137+
@apply left-1/2 -translate-x-1/2;
140138
141139
.notify-group__container {
142140
@apply items-center;
@@ -151,8 +149,6 @@ defineExpose({
151149
}
152150
153151
&--top-left {
154-
@apply top-2 left-4;
155-
156152
.notify-group__container {
157153
@apply items-start;
158154
}
@@ -166,8 +162,6 @@ defineExpose({
166162
}
167163
168164
&--bottom-right {
169-
@apply bottom-2 right-4;
170-
171165
.notify-group__container {
172166
@apply items-end;
173167
}
@@ -181,7 +175,7 @@ defineExpose({
181175
}
182176
183177
&--bottom-center {
184-
@apply bottom-2 left-1/2 -translate-x-1/2;
178+
@apply left-1/2 -translate-x-1/2;
185179
186180
.notify-group__container {
187181
@apply items-center;
@@ -196,8 +190,6 @@ defineExpose({
196190
}
197191
198192
&--bottom-left {
199-
@apply bottom-2 left-4;
200-
201193
.notify-group__container {
202194
@apply items-start;
203195
}
@@ -213,14 +205,28 @@ defineExpose({
213205
&--top-left,
214206
&--top-center,
215207
&--top-right {
208+
@apply top-8;
209+
216210
.notify-group__container {
217211
@apply justify-start flex-col-reverse space-y-reverse;
218212
}
219213
}
220214
215+
&--top-right,
216+
&--bottom-right {
217+
@apply right-8;
218+
}
219+
220+
&--top-left,
221+
&--bottom-left {
222+
@apply left-8;
223+
}
224+
221225
&--bottom-left,
222226
&--bottom-center,
223227
&--bottom-right {
228+
@apply bottom-8;
229+
224230
.notify-group__container {
225231
@apply justify-end flex-col;
226232
}

src/components/toast/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ description: Simple notification pop-up.
3838
### Simple Usage
3939

4040
<div class="flex mt-3">
41-
<Button color="info" @click="toast('Far far away, behind the word.')">
41+
<Button color="info" @click="toast({ text: 'Far far away, behind the word.', duration: -1 })">
4242
Show Toast
4343
</Button>
4444
</div>

0 commit comments

Comments
 (0)