github-buttons
GitHub Buttons
Last updated 4 months ago by ntkme .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ npm install github-buttons 
SYNC missed versions from official npm registry.

github-buttons

build npm

Usage

Use as a Snippet

Get started quickly with github:button configurator.

Use as a Component

Use as a Module

import { render } from 'github-buttons'

// export function render(options: object, callback: (el: HTMLElement) => void): void;
render(options, function (el) {
  document.body.appendChild(el) 
})

// export function render(anchor: HTMLAnchorElement, callback: (el: HTMLElement) => void): void;
render(anchor, function (el) {
  anchor.parentNode.replaceChild(el, anchor)
})

Options

  • For snippet usage, an option is an attribute on <a> element.
  • For component usage, an option is a prop on component.
  • For module usage, an option is a property on options object.
href
  • Type: string
  • Default: '#'

Assign href attribute (GitHub link) for button.

title
  • Type: string
  • Default: undefined

Assign title attribute for button.

data-icon
  • Type: string
  • Default: 'octicon-mark-github'

Set icon on button. A subset of Octicons is bundled.

data-color-scheme
  • Type: string
  • Default: undefined

Define a mapping of system color scheme to widget color scheme in css-like syntax.

This is an opt-in feature since version >=2.3.0. It means if data-color-scheme is undefined, it would still behave like version <2.3.0, where light color scheme is used under all conditions.

Once data-color-scheme is set to a string, it will inherit the default mapping: no-preference: light; light: light; dark: dark;.

  • no-preference: light; means when system has no preference on color scheme, light color scheme will be used.
  • light: light; means when system prefers light color scheme, light color scheme will be used.
  • dark: dark; means when system prefers dark color scheme, dark color scheme will be used.

User declarations would override the default. For example:

  • To enable color scheme using default, set data-color-scheme="".
  • To use dark color scheme when system has no preference, set data-color-scheme="no-preference: dark;".
  • To force light color scheme everywhere, set data-color-scheme="dark: light;".
  • To force dark color scheme everywhere, set data-color-scheme="no-preference: dark; light: dark;".

A single word can be used to force the color scheme everywhere since version >=2.11.0. For example:

  • To force light color scheme everywhere, set data-color-scheme="light".
  • To force dark color scheme everywhere, set data-color-scheme="dark".
data-size
  • Type: string
  • Default: undefined

Set button size. Possible values are undefined and 'large'.

data-show-count
  • Type: boolean
  • Default: false

Show a dynamic count based on button type (detected from href):

  • https://github.com/:user (follow)
  • https://github.com/:user/:repo (star)
  • https://github.com/:user/:repo/subscription (watch)
  • https://github.com/:user/:repo/fork (fork)
  • https://github.com/:user/:repo/issues (issues)
  • https://github.com/:user/:repo/issues/new (issues)

Tailing slash, query string, and hash in the href won't affect type detection:

  • https://github.com/:user/ (follow)
  • https://github.com/:user?tab=repositories (follow)
  • https://github.com/:user/:repo#readme (star)
  • https://github.com/:user/:repo/#readme (star)
data-text
  • Type: string
  • Default: undefined

Set button text. When button is generated from <a> element and data-text is undefined, the button text will be anchor's textContent.

aria-label
  • Type: string
  • Default: undefined

Set aira-label for button.


See also


License

See LICENSE.

Current Tags

  • 2.29.1                                ...           latest (3 months ago)

74 Versions

  • 2.29.1                                ...           3 months ago
  • 2.29.0                                ...           4 months ago
  • 2.28.1                                ...           5 months ago
  • 2.28.0                                ...           8 months ago
  • 2.27.0                                ...           2 years ago
  • 2.26.0                                ...           2 years ago
  • 2.25.0                                ...           2 years ago
  • 2.24.0                                ...           2 years ago
  • 2.23.0                                ...           2 years ago
  • 2.22.3                                ...           2 years ago
  • 2.22.2                                ...           2 years ago
  • 2.22.1                                ...           2 years ago
  • 2.22.0                                ...           2 years ago
  • 2.21.1                                ...           3 years ago
  • 2.21.0                                ...           3 years ago
  • 2.20.2                                ...           3 years ago
  • 2.20.1                                ...           3 years ago
  • 2.20.0                                ...           3 years ago
  • 2.19.1                                ...           3 years ago
  • 2.19.0                                ...           3 years ago
  • 2.18.1                                ...           4 years ago
  • 2.18.0                                ...           4 years ago
  • 2.17.0                                ...           4 years ago
  • 2.16.0                                ...           4 years ago
  • 2.15.0                                ...           4 years ago
  • 2.14.4                                ...           4 years ago
  • 2.14.3                                ...           4 years ago
  • 2.14.2                                ...           4 years ago
  • 2.14.1                                ...           4 years ago
  • 2.14.0                                ...           4 years ago
  • 2.13.0                                ...           4 years ago
  • 2.12.0                                ...           4 years ago
  • 2.11.3                                ...           4 years ago
  • 2.11.2                                ...           4 years ago
  • 2.11.1                                ...           4 years ago
  • 2.11.0                                ...           5 years ago
  • 2.10.1                                ...           5 years ago
  • 2.10.0                                ...           5 years ago
  • 2.9.0                                ...           5 years ago
  • 2.8.1                                ...           5 years ago
  • 2.8.0                                ...           5 years ago
  • 2.7.0                                ...           5 years ago
  • 2.6.0                                ...           5 years ago
  • 2.5.0                                ...           5 years ago
  • 2.4.2                                ...           5 years ago
  • 2.4.1                                ...           5 years ago
  • 2.4.0                                ...           5 years ago
  • 2.3.6                                ...           5 years ago
  • 2.3.5                                ...           5 years ago
  • 2.3.4                                ...           5 years ago
  • 2.3.3                                ...           5 years ago
  • 2.3.2                                ...           5 years ago
  • 2.3.1                                ...           5 years ago
  • 2.3.0                                ...           5 years ago
  • 2.2.10                                ...           5 years ago
  • 2.2.9                                ...           6 years ago
  • 2.2.8                                ...           6 years ago
  • 2.2.7                                ...           6 years ago
  • 2.2.6                                ...           6 years ago
  • 2.2.5                                ...           6 years ago
  • 2.2.4                                ...           6 years ago
  • 2.2.3                                ...           6 years ago
  • 2.2.2                                ...           6 years ago
  • 2.2.1                                ...           6 years ago
  • 2.2.0                                ...           6 years ago
  • 2.1.0                                ...           6 years ago
  • 2.0.5                                ...           6 years ago
  • 2.0.4                                ...           6 years ago
  • 2.0.3                                ...           6 years ago
  • 2.0.2                                ...           6 years ago
  • 2.0.1                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.1-security                                ...           8 years ago
Maintainers (1)
Downloads
Total 1
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (0)
None
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE