🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
f3cf17c
feat(b-avatar-group): new helper component b-avatar-group
tmorehouse Apr 28, 2020
1602438
Update _avatar.scss
tmorehouse Apr 28, 2020
5c43381
Update _avatar.scss
tmorehouse Apr 28, 2020
b121568
Update _avatar.scss
tmorehouse Apr 28, 2020
0b4cf86
Update _avatar.scss
tmorehouse Apr 28, 2020
e55e021
Create avatar-group.js
tmorehouse Apr 28, 2020
486583e
Update index.js
tmorehouse Apr 28, 2020
f2b7c18
Update package.json
tmorehouse Apr 28, 2020
451d0a2
Create avatar-group.spec.js
tmorehouse Apr 28, 2020
6c49606
Update avatar-group.spec.js
tmorehouse Apr 28, 2020
b664422
Update avatar.spec.js
tmorehouse Apr 28, 2020
5f1ab39
Update avatar.js
tmorehouse Apr 28, 2020
2263366
Update avatar-group.js
tmorehouse Apr 28, 2020
a60dbae
Update avatar.js
tmorehouse Apr 28, 2020
1d1267f
Update avatar.js
tmorehouse Apr 28, 2020
2d6fd32
Update avatar-group.js
tmorehouse Apr 28, 2020
29ba651
Update avatar.spec.js
tmorehouse Apr 28, 2020
a84042c
Update avatar.spec.js
tmorehouse Apr 28, 2020
28af7b7
Update avatar.spec.js
tmorehouse Apr 28, 2020
e03c999
Update avatar.spec.js
tmorehouse Apr 28, 2020
6ac2e70
Update avatar-group.js
tmorehouse Apr 28, 2020
2ca8fbe
Update avatar.js
tmorehouse Apr 28, 2020
f85cff7
Update README.md
tmorehouse Apr 28, 2020
47dc7fb
Update package.json
tmorehouse Apr 28, 2020
a477f92
Update index.d.ts
tmorehouse Apr 28, 2020
375c919
Update _avatar.scss
tmorehouse Apr 29, 2020
088a016
Update avatar.js
tmorehouse Apr 29, 2020
cdd6499
Update _avatar.scss
tmorehouse Apr 29, 2020
81d1a50
Update avatar.js
tmorehouse Apr 29, 2020
a2c013d
Update _avatar.scss
tmorehouse Apr 29, 2020
6467d39
Update avatar.js
tmorehouse Apr 29, 2020
1779856
Update avatar-group.js
tmorehouse Apr 29, 2020
1600fdf
Update _avatar.scss
tmorehouse Apr 29, 2020
2945364
Update README.md
tmorehouse Apr 29, 2020
894bde4
Update _avatar.scss
tmorehouse Apr 29, 2020
e71ebc9
Update avatar.js
tmorehouse Apr 29, 2020
9fd1b7f
Update avatar-group.js
tmorehouse Apr 29, 2020
96b6ced
Update avatar-group.js
tmorehouse Apr 29, 2020
0873955
Update avatar.js
tmorehouse Apr 29, 2020
194ab89
Update avatar-group.js
tmorehouse Apr 29, 2020
9644ec3
Update avatar-group.js
tmorehouse Apr 29, 2020
4722ef3
Update package.json
tmorehouse Apr 29, 2020
efc3657
Update README.md
tmorehouse Apr 29, 2020
04b9f80
Update avatar.js
tmorehouse Apr 29, 2020
8f762bf
Update README.md
tmorehouse Apr 29, 2020
a7dbe75
Update avatar-group.js
tmorehouse Apr 29, 2020
b5182db
Update _avatar.scss
tmorehouse Apr 29, 2020
ea53373
Update avatar-group.js
tmorehouse Apr 29, 2020
4fd60ed
Update README.md
tmorehouse Apr 29, 2020
022ea5c
lint
tmorehouse Apr 29, 2020
3bcea50
Update avatar.js
tmorehouse Apr 29, 2020
9a0b1ee
Update avatar.spec.js
tmorehouse Apr 29, 2020
55b420f
Update avatar.spec.js
tmorehouse Apr 29, 2020
55e73f4
Update README.md
tmorehouse Apr 29, 2020
e20f840
Merge branch 'dev' into avatar-group
jacobmllr95 Apr 29, 2020
3c3c359
Update _avatar.scss
tmorehouse Apr 29, 2020
de2c4e4
Update avatar.js
tmorehouse Apr 29, 2020
cccedfd
Update _avatar.scss
tmorehouse Apr 29, 2020
d6b156e
Merge branch 'dev' into avatar-group
tmorehouse Apr 29, 2020
b6771f2
Merge branch 'dev' into avatar-group
tmorehouse Apr 29, 2020
cb78355
Update _avatar.scss
tmorehouse Apr 29, 2020
844d661
Update _avatar.scss
tmorehouse Apr 29, 2020
781f08e
Update README.md
tmorehouse Apr 29, 2020
4856137
Update _avatar.scss
tmorehouse Apr 29, 2020
b7f90c3
Update avatar-group.js
tmorehouse Apr 29, 2020
4642f62
Update avatar-group.js
tmorehouse Apr 29, 2020
3ad1a2b
Update avatar-group.js
tmorehouse Apr 29, 2020
9d4507d
Update avatar.js
tmorehouse Apr 29, 2020
547e1d4
Update package.json
tmorehouse Apr 29, 2020
2752c30
Update index.js
tmorehouse Apr 29, 2020
8c4b362
Update _avatar.scss
tmorehouse Apr 29, 2020
16b10ec
Update README.md
tmorehouse Apr 29, 2020
598867d
Update avatar-group.js
tmorehouse Apr 29, 2020
0e21b5e
Update README.md
tmorehouse Apr 30, 2020
273f808
Update README.md
tmorehouse Apr 30, 2020
6e7c840
Merge branch 'dev' into avatar-group
jacobmllr95 Apr 30, 2020
a086140
Prettify
jacobmllr95 Apr 30, 2020
e551d62
Fix typos
jacobmllr95 Apr 30, 2020
df21cc8
Update README.md
jacobmllr95 Apr 30, 2020
b5a7595
Update README.md
jacobmllr95 Apr 30, 2020
ad6f5a8
Update package.json
jacobmllr95 Apr 30, 2020
ed969f5
Update avatar-group.js
jacobmllr95 Apr 30, 2020
fc76bb9
Merge branch 'dev' into avatar-group
tmorehouse Apr 30, 2020
5fa2ffb
Merge branch 'dev' into avatar-group
tmorehouse May 6, 2020
b38942f
Merge branch 'dev' into avatar-group
jacobmllr95 May 6, 2020
d88c083
Update avatar.spec.js
jacobmllr95 May 7, 2020
14bf4f4
Update avatar-group.spec.js
jacobmllr95 May 7, 2020
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
161 changes: 149 additions & 12 deletions src/components/avatar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ styling on the content.

Use the `src` prop to specify a URL of an image to use as the avatar content. The image should have
an aspect ratio of `1:1` (meaning the width and height should be equal), otherwise image aspect
distortion will occur. The image will be scaled up or down to fit within the avatar's bounding box,
and will be sized to show the avatar's [variant background](#variants) around the edge.
distortion will occur. The image will be scaled up or down to fit within the avatar's bounding box.

```html
<template>
Expand All @@ -84,8 +83,9 @@ and will be sized to show the avatar's [variant background](#variants) around th
fallback to the value of the `icon` or `text` props. If neither the `icon` or `text` props are
provided, then the default avatar icon will be shown. Also, when the image fails to load, the
`img-error` event will be emitted.
- <span class="badge badge-secondary">2.12.0+</span> Setting the [variant prop](#variants) to an
empty string will remove the visible background border around the image.
- [Variant colors](#variants) when using images not normally visible, unless the image fails load.
The variant will affect the focus styling when the image avatar is also an
[actionalble avatar](#actionalble-avatars).

### Icon content

Expand Down Expand Up @@ -270,6 +270,8 @@ Easily create avatars that respond to clicks, or avatars that change the URL/rou
Actionable avatars will appear in the document tab sequence, and are accessible for both screen
reader and keyboard-only users.

Image avatars, when actionalble, employ a basic scale transform on the image when hovered.

### Button

Want to trigger the opening of a modal or trigger an action? Set the `button` prop to instruct
Expand All @@ -278,10 +280,20 @@ the `click` event whenever clicked.

```html
<template>
<div>
<b-avatar button @click="onClick" variant="primary" text="FF" class="align-baseline"></b-avatar>
Button Avatar
</div>
<b-list-group>
<b-list-group-item>
<b-avatar button @click="onClick" variant="primary" text="FF" class="align-baseline"></b-avatar>
Button Text Avatar
</b-list-group-item>
<b-list-group-item>
<b-avatar button @click="onClick" src="https://placekitten.com/300/300"></b-avatar>
Button Image Avatar
</b-list-group-item>
<b-list-group-item>
<b-avatar button @click="onClick" icon="star-fill" class="align-center"></b-avatar>
Button Icon Avatar
</b-list-group-item>
</b-list-group>
</template>

<script>
Expand Down Expand Up @@ -315,10 +327,20 @@ The `to` prop can either be a string path, or a `Location` object. The `to` prop

```html
<template>
<div>
<b-avatar href="#foobar" variant="info" src="https://placekitten.com/300/300"></b-avatar>
Link Avatar
</div>
<b-list-group>
<b-list-group-item>
<b-avatar href="#foo" variant="primary" text="FF" class="align-baseline"></b-avatar>
Link Text Avatar
</b-list-group-item>
<b-list-group-item>
<b-avatar href="#bar" src="https://placekitten.com/300/300"></b-avatar>
Link Image Avatar
</b-list-group-item>
<b-list-group-item>
<b-avatar href="#baz" icon="star-fill" class="align-center"></b-avatar>
Link Icon Avatar
</b-list-group-item>
</b-list-group>
</template>

<!-- b-avatar-href.vue -->
Expand Down Expand Up @@ -411,6 +433,121 @@ inward, while negative values will move the badge outward.
<!-- b-avatar-badge-offset.vue -->
```

## Avatar groups

<span class="badge badge-info small">v2.14.0+</span>

Group multiple avatars together by wrapping them in a `<b-avatar-group>` component:

```html
<template>
<div>
<b-avatar-group size="60px">
<b-avatar></b-avatar>
<b-avatar text="BV" variant="primary"></b-avatar>
<b-avatar src="https://placekitten.com/300/300" variant="info"></b-avatar>
<b-avatar text="OK" variant="danger"></b-avatar>
<b-avatar variant="warning"></b-avatar>
<b-avatar src="https://placekitten.com/320/320" variant="dark"></b-avatar>
<b-avatar icon="music-note" variant="success"></b-avatar>
</b-avatar-group>
</div>
</template>

<!-- b-avatar-group.vue -->
```

**Notes:**

- The `variant`, `square` and `rounded` props on `<b-avatar-group>` will take precedence over the
respective props on individual avatars.

### Group size

To size the avatars, use the prop `size` on `<b-avatar-group>`. The `size` prop accepts the same
type of values as the `size` prop on `<b-avatar>`. Note that the `size` prop will be ignored on
individual avatars when they are placed inside a `<b-avatar-group>`.

```html
<template>
<div>
<b-avatar-group size="5rem">
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
</b-avatar-group>
</div>
</template>

<!-- b-avatar-group-size.vue -->
```

### Group variant

Use the `variant` prop to color all child avatars in the `<b-avatar-group>`. Note that the `variant`
prop, when set, will override the the `variant` specified on individual avatars.

```html
<template>
<div>
<b-avatar-group variant="success">
<b-avatar></b-avatar>
<b-avatar variant="info"></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
</b-avatar-group>
</div>
</template>

<!-- b-avatar-group-variant.vue -->
```

### Group rounding

Similar to the `variant` prop, the `<b-avatar-group>` props `square` and `rounded` take precedence
over the respective props on individual child avatars.

```html
<template>
<div>
<b-avatar-group rounded="lg">
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
</b-avatar-group>
</div>
</template>

<!-- b-avatar-group-rounded.vue -->
```

### Group overlap

By default child avatars inside a `<b-avatar-group>` will overlap by a factor of `0.3` (relative to
the size of the avatar). You can control the overlap amount by setting the `overlap` prop to a value
between `0` and `1`, where `0` means no overlap and `1` means 100% overlap.

```html
<template>
<div>
<b-avatar-group overlap="0.65">
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
<b-avatar></b-avatar>
</b-avatar-group>
</div>
</template>

<!-- b-avatar-group-overlap.vue -->
```

## Accessibility

Use the `aria-label` prop to provide an accessible, screen reader friendly, label for your avatar.
Expand Down
47 changes: 39 additions & 8 deletions src/components/avatar/_avatar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,23 @@
outline: 0;
}

&a,
&button,
&.btn {
&.btn,
&[href] {
padding: 0;
border: 0;

.b-avatar-img img {
transition: transform 0.15s ease-in-out;
}

&:not(:disabled):not(.disabled) {
cursor: if($enable-pointer-cursor-for-buttons, pointer, null);

&:hover {
.b-avatar-img img {
transform: scale(1.15);
}
}
}
}

Expand All @@ -39,7 +48,8 @@
}

.b-avatar-custom,
.b-avatar-text {
.b-avatar-text,
.b-avatar-img {
border-radius: inherit;
width: 100%;
height: 100%;
Expand All @@ -54,16 +64,19 @@
white-space: nowrap;
}

&[href] {
text-decoration: none;
}

> .b-icon {
width: 60%;
height: auto;
max-width: 100%;
}

img {
width: 90%;
height: 90%;
max-width: 100%;
.b-avatar-img img {
width: 100%;
height: 100%;
max-height: auto;
border-radius: inherit;
}
Expand All @@ -81,3 +94,21 @@
z-index: 5;
}
}

.b-avatar-group {
.b-avatar-group-inner {
display: flex;
flex-wrap: wrap;
}

.b-avatar {
border: $border-width solid $border-color;
}

a,
.btn {
&.b-avatar:hover:not(.disabled):not(disabled) {
z-index: 3;
}
}
}
68 changes: 68 additions & 0 deletions src/components/avatar/avatar-group.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import Vue from '../../utils/vue'
import normalizeSlotMixin from '../../mixins/normalize-slot'
import { mathMax, mathMin } from '../../utils/math'
import { toFloat } from '../../utils/number'
import { computeSize } from './avatar'

// --- Constants ---
const NAME = 'BAvatarGroup'

// --- Main component ---
// @vue/component
export const BAvatarGroup = /*#__PURE__*/ Vue.extend({
name: NAME,
mixins: [normalizeSlotMixin],
provide() {
return { bvAvatarGroup: this }
},
props: {
variant: {
// Child avatars will prefer this variant over their own
type: String,
default: null
},
size: {
// Child avatars will always use this over their own size
type: String,
default: null
},
overlap: {
type: [Number, String],
default: 0.3
},
square: {
// Child avatars will prefer this prop (if set) over their own
type: Boolean,
default: false
},
rounded: {
// Child avatars will prefer this prop (if set) over their own
type: [Boolean, String],
default: false
},
tag: {
type: String,
default: 'div'
}
},
computed: {
computedSize() {
return computeSize(this.size)
},
overlapScale() {
return mathMin(mathMax(toFloat(this.overlap, 0), 0), 1) / 2
},
paddingStyle() {
let value = this.computedSize
value = value ? `calc(${value} * ${this.overlapScale})` : null
return value ? { paddingLeft: value, paddingRight: value } : {}
}
},
render(h) {
const $inner = h('div', { staticClass: 'b-avatar-group-inner', style: this.paddingStyle }, [
this.normalizeSlot('default')
])

return h(this.tag, { staticClass: 'b-avatar-group', attrs: { role: 'group' } }, [$inner])
}
})
Loading