Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@svelte-put/avatar

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@svelte-put/avatar

Component and utils for handling avatar

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
113
increased by37.8%
Maintainers
1
Weekly downloads
 
Created
Source

@svelte-put/avatar

npm.badge bundlephobia.badge

Svelte Avatar component and utilities for building avatar urls

Table of Contents

Show / hide

svelte-put

This package is part of the @svelte-put family. For contributing guideline and more, refer to its readme.

Installation

npm install -D @svelte-put/avatar
yarn add -D @svelte-put/avatar
pnpm add -D @svelte-put/avatar

Changelog

Usage

Currently, gravatar and UIAvatar are supported. If you find that another avatar server is worth mapping to, please propose through an issue.

Show / hide
<script>
  import Avatar from '@svelte-put/avatar/Avatar.svelte';
  import { gravatar, uiAvatar } from '@svelte-put/avatar';

  const simpleGravatarUrl = gravatar('johndoe@domain.com');
  const complexGravatarUrl = gravatar({
    email: 'johndoe@domain.com',
    rating: 'r',
    size: 32,
  });

  const simpleUIAvatarUrl = uiAvatar('John+Doe');
  const complexGravatarUrl = uiAvatar({
    name: 'John+Doe',
    rounded: true,
    length: 3,
    bold: true,
    size: 32,
    format: 'svg',
  });
</script>

<!--
  Multiple resolution strategy can be provided as props.
  If one url does not point to a valid resource, the next will
  be used until all are exhausted and an internal fallback (https://www.gravatar.com/avatar?d=mp) is used instead.

  Resolution flow is shown below:

  src -> gravatar -> uiAvatar -> fallback -> internal fallback
-->

<Avatar
  class="rounded-full"
  src="https://johndoe.com/avatar.png"
  gravatar="johndoe@domain.com"
  uiAvatar="John+Doe"
  fallback="https://johndoe.com/fallback.png"
  size={32}
>
</Avatar>

<Avatar
  src="https://johndoe.com/avatar.png"
  gravatar={{ email: 'johndoe@domain.com', rating: 'pg' }}
  uiAvatar={{ name: 'John+Doe', background: '333333', color: 'FFFFFF' }}
  fallback="https://johndoe.com/fallback.png"
  size={32}
>
  <svelte:fragment let:src>
    <img {src} alt="custom" />
  </svelte:fragment>
</Avatar>

Documentation

For detailed documentation, see the extracted API. It is recommended to skim through at least the AvatarProps page so that you know what options are available.

Keywords

FAQs

Package last updated on 19 Aug 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc