GitHub Sponsor Badge - Svelte Shields

Props #

- user
- style = 'flat'
- logo
- logoColor
- logoSize
- label = ''
- labelColor
- color
- cacheSeconds
- link
- class: classname
- ...attributes

Types #

import type { HTMLImgAttributes } from 'svelte/elements';

export type LinkType = string[] | [string, string];
export interface BaseBadgePropsType {
  style?: 'flat' | 'flat-square' | 'for-the-badge' | 'plastic' | 'social';
  logo?: string | undefined | null;
  logoColor?: string | undefined | null;
  logoSize?: string | undefined | null;
  label?: string | undefined | null;
  labelColor?: string | undefined | null;
  color?: string | undefined | null;
  cacheSeconds?: string | undefined | null;
  link?: LinkType;
  class?: string | undefined | null;
}
interface ExtendedStyle extends BaseBadgePropsType, HTMLImgAttributes {
  style?: 'flat' | 'flat-square' | 'for-the-badge' | 'plastic' | 'social';
}
export interface GitHubSponsorPropsType extends ExtendedStyle {
  user: string;
}

Examples #

Basic usage #

GitHub Sponsor - shinokada
<script lang="ts">
  import { GitHubSponsor, type GitHubSponsorPropsType } from 'svelte-shields';

  const sponsor: GitHubSponsorPropsType = {
    user: 'shinokada'
  };
</script>

<GitHubSponsor {...sponsor} />

Style #

Possible values: flat, flat-square, plastic, for-the-badge, social. If not specified, the default style for this badge is "flat".

GitHub Sponsor - shinokada GitHub Sponsor - shinokada GitHub Sponsor - shinokada GitHub Sponsor - shinokada GitHub Sponsor - shinokada
<script lang="ts">
  import { GitHubSponsor, type GitHubSponsorPropsType } from 'svelte-shields';

  const style: GitHubSponsorPropsType = {
    user: 'shinokada',
    style: 'flat'
  };

  const style2: GitHubSponsorPropsType = {
    user: 'shinokada',
    style: 'flat-square'
  };

  const style3: GitHubSponsorPropsType = {
    user: 'shinokada',
    style: 'for-the-badge'
  };

  const style4: GitHubSponsorPropsType = {
    user: 'shinokada',
    style: 'plastic'
  };

  const style5: GitHubSponsorPropsType = {
    user: 'shinokada',
    style: 'social'
  };
</script>

<div class="grid gap-4">
  <GitHubSponsor {...style} />
  <GitHubSponsor {...style2} />
  <GitHubSponsor {...style3} />
  <GitHubSponsor {...style4} />
  <GitHubSponsor {...style5} />
</div>

Color #

Background color of the right part (hex, rgb, rgba, hsl, hsla and css named colors supported).

GitHub Sponsor - shinokada GitHub Sponsor - shinokada GitHub Sponsor - shinokada GitHub Sponsor - shinokada GitHub Sponsor - shinokada GitHub Sponsor - shinokada
<script lang="ts">
  import { GitHubSponsor, type GitHubSponsorPropsType } from 'svelte-shields';

  const color1: GitHubSponsorPropsType = {
    user: 'shinokada',
    color: 'orange'
  };

  const color2: GitHubSponsorPropsType = {
    user: 'shinokada',
    color: 'FF7F00' // Hex (Orange)
  };

  const color3: GitHubSponsorPropsType = {
    user: 'shinokada',
    color: 'rgb(255, 127, 0)' // RGB (Orange)
  };

  const color4: GitHubSponsorPropsType = {
    user: 'shinokada',
    color: 'rgba(255, 127, 0, 1)' // RGBA (Orange, fully opaque)
  };

  const color5: GitHubSponsorPropsType = {
    user: 'shinokada',
    color: 'hsl(40, 100%, 50%)' // HSL (Orange)
  };

  const color6: GitHubSponsorPropsType = {
    user: 'shinokada',
    color: 'hsla(40, 100%, 50%, 1)' // HSLA (Orange, fully opaque)
  };
</script>

<div class="grid gap-4">
  <GitHubSponsor {...color1} />
  <GitHubSponsor {...color2} />
  <GitHubSponsor {...color3} />
  <GitHubSponsor {...color4} />
  <GitHubSponsor {...color5} />
  <GitHubSponsor {...color6} />
</div>

Logo & Label #

GitHub Sponsor - sveltejs
<script lang="ts">
  import { GitHubSponsor, type GitHubSponsorPropsType } from 'svelte-shields';

  const logo_label: GitHubSponsorPropsType = {
    user: 'sveltejs',
    logo: 'svelte',
    label: 'SVELTE'
  };
</script>

<GitHubSponsor {...logo_label} />

Link #

Specify what clicking on the left/right of a badge should do.

<script lang="ts">
  import { GitHubSponsor, type GitHubSponsorPropsType } from 'svelte-shields';

  const linkEx: GitHubSponsorPropsType = {
    user: 'shinokada',
    label: 'TERA',
    link: ['https://tera.codewithshin.com', 'https://github.com/shinokada/tera']
  };
</script>

<GitHubSponsor {...linkEx} />

Other #

cacheSeconds is HTTP cache lifetime (rules are applied to infer a default value on a per-badge basis, any values specified below the default will be ignored).

GitHub Sponsor - shinokada
<script lang="ts">
  import { GitHubSponsor, type GitHubSponsorPropsType } from 'svelte-shields';

  const otherEx: GitHubSponsorPropsType = {
    user: 'shinokada',
    cacheSeconds: '86400'
  };
</script>

<GitHubSponsor {...otherEx} />