0.1.7 • Published 5 years ago

vue-sphere-avatar v0.1.7

Weekly downloads
35
License
-
Repository
github
Last release
5 years ago

Vue Sphere Avatar

A simple component to display a sphere-shaped avatar for users, accounts, companies etc. An image can be used but falls back to initials on a colored background.

Installation

npm install --save vue-sphere-avatar

Usage

You can either use the component globally or locally.

Globally

In your main.js, just import the library using:

import 'vue-sphere-avatar'

Then use the component directly in your template

<sphere-avatar :name="'Strawhat Pirates'" />

Locally

Example usage in a SFC (single file component):

<template>
  <div>
    <sphere-avatar :name="'Strawhat Pirates'" />
  </div>
</template>

<script>
import SphereAvatar from 'vue-sphere-avatar';
export default {
  components: {
    SphereAvatar,
  },
}
</script>

Props

NameDefaultTypeDescription
srcnullStringImage source e.g. "https://picsum.photos/200"
size50NumberHow big is the sphere in height and width
name-StringThe name where the initials shall be extracted if none is provided
initials-StringThe initials to put inside the sphere. If none is not provided, it will extracted from name. If name isn't provided a ? is displayed.
color-String, ObjectThe background color of choice. String and Object inputs specified in tinycolor2 are allowed. An invalid input would return black. In case no value is provided, a color based on the name or initials will be assigned. This is to make sure the color doesn't change on every DOM update.
maxFontSize512NumberIf you want a non-fit avatar display for initials, specify a maximum font size
minFontSize16NumberMinimum font size

Fitty

Fitty is utilized to scale up or down the initials so it fits perfectly inside the sphere. To change how that looks, just specify maxFontSize and/or minFontSize accordingly.

Text color - Light or Dark

Text color is automatically contrasted to the background color via tinycolor2.

0.1.7

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago