-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(b-avatar-group): new helper component b-avatar-group (#5272)
* feat(b-avatar-group): new helper component b-avatar-group * Update _avatar.scss * Update _avatar.scss * Update _avatar.scss * Update _avatar.scss * Create avatar-group.js * Update index.js * Update package.json * Create avatar-group.spec.js * Update avatar-group.spec.js * Update avatar.spec.js * Update avatar.js * Update avatar-group.js * Update avatar.js * Update avatar.js * Update avatar-group.js * Update avatar.spec.js * Update avatar.spec.js * Update avatar.spec.js * Update avatar.spec.js * Update avatar-group.js * Update avatar.js * Update README.md * Update package.json * Update index.d.ts * Update _avatar.scss * Update avatar.js * Update _avatar.scss * Update avatar.js * Update _avatar.scss * Update avatar.js * Update avatar-group.js * Update _avatar.scss * Update README.md * Update _avatar.scss * Update avatar.js * Update avatar-group.js * Update avatar-group.js * Update avatar.js * Update avatar-group.js * Update avatar-group.js * Update package.json * Update README.md * Update avatar.js * Update README.md * Update avatar-group.js * Update _avatar.scss * Update avatar-group.js * Update README.md * lint * Update avatar.js * Update avatar.spec.js * Update avatar.spec.js * Update README.md * Update _avatar.scss * Update avatar.js * Update _avatar.scss * Update _avatar.scss * Update _avatar.scss * Update README.md * Update _avatar.scss * Update avatar-group.js * Update avatar-group.js * Update avatar-group.js * Update avatar.js * Update package.json * Update index.js * Update _avatar.scss * Update README.md * Update avatar-group.js * Update README.md * Update README.md * Prettify * Fix typos * Update README.md * Update README.md * Update package.json * Update avatar-group.js * Update avatar.spec.js * Update avatar-group.spec.js Co-authored-by: Jacob Müller <jacob.mueller.elz@gmail.com>
- Loading branch information
1 parent
755164f
commit c84faae
Showing
10 changed files
with
464 additions
and
35 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
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,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]) | ||
} | ||
}) |
Oops, something went wrong.