0.0.2 • Published 6 years ago

gravatar-wc v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

gravatar-wc

npm npm bundle size NPM

gravatar-wc uses the Gravatar image request API to display an image for the specified email address. This package uses Stencil to generate a web component that can be used by any front end library or framework.

Attributes

<!-- Empty component. Will use the default image. -->
<gravatar-wc></gravatar-wc>

<!-- Fully configured component. -->
<gravatar-wc
  email="first.last@mybusiness.com"
  default="identicon"
  force-default="true"
  protocol="https"
  rating="g"
  size="64"
>
</gravatar-wc>
nametypeoptions
emailstring
defaultstring404, blank, identicon, monsterid, mp, retro, robohash, wavatar
force-defaultboolean
protocolstringhttp, https
ratingstringg, pg, r, x
sizenumber

Integration

Stencil Integration Docs

JavaScript

<gravatar-wc email="demo@demo.com"></gravatar-wc>

<script src="https://unpkg.com/gravatar-wc/dist/gravatar-wc.js"></script>

React

// index.js, index.ts

import { defineCustomElements as defineGravatar } from "gravatar-wc/dist/loader";

defineGravatar(window);
// App.jsx, App.tsx

import { Component } from "react";

// skip if using JavaScript - only needed for TypeScript
declare global {
  namespace JSX {
    interface IntrinsicElements {
      "gravatar-wc": any;
    }
  }
}

export default class extends Component {
  render() {
    return <gravatar-wc email="demo@demo.com" />;
  }
}

Vue

// main.js, main.ts

import { defineCustomElements as defineGravatar } from "gravatar-wc/dist/loader";
import Vue from "vue";

defineGravatar(window);

Vue.config.ignoredElements = ["gravatar-wc"];
// ExampleComponent.vue

<template>
  <div>
    <gravatar-wc :email="email"></gravatar-wc>
  </div>
</template>

<script lang="ts">
import { Component, Vue, Prop } from "vue-property-decorator";

@Component
export default class ExampleComponent extends Vue {
  email = "demo@demo.com";
}
</script>