Coder Social home page Coder Social logo

lamhotsimamora / github-buttons Goto Github PK

View Code? Open in Web Editor NEW

This project forked from buttons/github-buttons

0.0 1.0 0.0 2.29 MB

:octocat: Unofficial github:buttons.

Home Page: https://buttons.github.io

License: BSD 2-Clause "Simplified" License

JavaScript 91.85% CSS 8.15%

github-buttons's Introduction

github-buttons

CircleCI Codecov

Usage

Use as a Snippet

Get started quickly with github:button configurator.

The source code for the configurator is available at ntkme/github-buttons-app.

Use as a Module

import { render } from 'github-buttons'

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

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

Use as a Component

Options

These options are the same for all the use cases described above:

Attribute Description
href GitHub link for the button.
title title attribute for the button's rendered element.
data-icon octicon-mark-github by default. A subset of Octicons is bundled.
data-size None by default or large.
data-show-count false by default or true. The dynamic count is generated based on detected button type.
data-text Text displayed on the button. It defaults to the text content within the link.
aria-label Aira label for the button link.
Built-in Button Types

Button type is 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)

Development

Clone

git clone https://github.com/ntkme/github-buttons.git
cd github-buttons && npm install

Build

npm run build

Test

npm test

See also

License

See LICENSE.

github-buttons's People

Contributors

ntkme avatar xhmikosr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.