Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit d7166b6

Browse files
committed
add used by button and prepare v0.3.0
1 parent 81cb8d9 commit d7166b6

File tree

10 files changed

+67
-10
lines changed

10 files changed

+67
-10
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to the "react-github-buttons" project will be documented in
44

55
## [Unreleased]
66

7+
## [0.3.0] 2019-6-15
8+
### Added
9+
10+
- Used by button
11+
712
## [0.2.0] 2019-6-13
813
### Added
914

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,26 @@ npm install --save react-github-buttons
1919
```tsx
2020
import React from 'react';
2121

22-
import { Fork, Star, Watch } from 'react-github-buttons';
22+
import { Fork, Star, UsedBy, Watch } from 'react-github-buttons';
2323

2424
function App() {
2525
return (
2626
<div>
2727
<Star owner='facebook' repo='react' />
2828
<Fork owner='facebook' repo='react' />
2929
<Watch owner='facebook' repo='react' />
30+
<UsedBy owner='facebook' repo='react' count={2077841} />
3031
</div>
3132
)
3233
}
3334
```
3435

3536
## Release Notes
3637

37-
### 0.2.0
38+
### 0.3.0
3839
#### Added
3940

40-
- Watch Button
41+
- Used by button
4142

4243
## Issues
4344

example/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-github-buttons-example",
33
"homepage": "https://vaibhavhrt.github.io/react-github-buttons",
4-
"version": "0.2.0",
4+
"version": "0.3.0",
55
"license": "MIT",
66
"private": true,
77
"dependencies": {

example/src/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22

3-
import { Fork, Star, Watch } from 'react-github-buttons';
3+
import { Fork, Star, Watch, UsedBy } from 'react-github-buttons';
44

55
export default class App extends Component {
66
render () {
@@ -9,6 +9,7 @@ export default class App extends Component {
99
<Star owner='vaibhavhrt' repo='react-github-buttons' />
1010
<Fork owner='vaibhavhrt' repo='react-github-buttons' />
1111
<Watch owner='vaibhavhrt' repo='react-github-buttons' />
12+
<UsedBy owner='vaibhavhrt' repo='react-github-buttons' count={0} />
1213
</div>
1314
)
1415
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-github-buttons",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "React Components for dynamic buttons for github repo's star, fork etc.",
55
"keywords": ["react", "github", "component", "utility"],
66
"author": {

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Star from "./star";
22
import Fork from "./fork";
33
import Watch from "./watch";
4+
import UsedBy from './usedBy';
45

5-
export { Fork, Star, Watch };
6+
export { Fork, Star, UsedBy, Watch };

src/lib/githubButton.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import classes from "../styles.css";
99
import ForkIcon from "./icons/forkIcon";
1010
import StarIcon from "./icons/starIcon";
1111
import WatchIcon from "./icons/watchIcon";
12+
import UsedByIcon from './icons/usedByIcon';
1213

1314
function getDataForVariant(
1415
variant: string,
@@ -44,8 +45,14 @@ function getDataForVariant(
4445
label = `${count} users are watching this repository`;
4546
countUrl = `https://github.com/${owner}/${repo}/watchers`;
4647
return { title, btnTitle, label, countUrl, Icon: WatchIcon };
48+
} else if (variant === "usedby") {
49+
title = "Used by";
50+
btnTitle = "";
51+
label = `${count} repositories depend on this package`;
52+
countUrl = `https://github.com/${owner}/${repo}/network/dependents`;
53+
return { title, btnTitle, label, countUrl, Icon: UsedByIcon };
4754
}
48-
throw new Error("Invalid Variant, supply one of [star, fork, watch]");
55+
throw new Error("Invalid Variant, supply one of [star, fork, watch, usedby]");
4956
}
5057

5158
export interface IPropTypes {
@@ -82,5 +89,5 @@ GithubButton.propTypes = {
8289
count: PropTypes.node.isRequired,
8390
owner: PropTypes.string.isRequired,
8491
repo: PropTypes.string.isRequired,
85-
variant: PropTypes.oneOf(["star", "fork", "watch"]),
92+
variant: PropTypes.oneOf(["star", "fork", "watch", "usedby"]),
8693
};

src/lib/icons/usedByIcon.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import * as React from "react";
2+
import classes from "../../styles.css";
3+
4+
export default function UsedByIcon() {
5+
return (
6+
<svg
7+
className={classes.svgicon}
8+
viewBox="0 0 16 16"
9+
version="1.1"
10+
width="16"
11+
height="16"
12+
>
13+
<path
14+
fill-rule="evenodd"
15+
// tslint:disable-next-line:max-line-length
16+
d="M1 4.27v7.47c0 .45.3.84.75.97l6.5 1.73c.16.05.34.05.5 0l6.5-1.73c.45-.13.75-.52.75-.97V4.27c0-.45-.3-.84-.75-.97l-6.5-1.74a1.4 1.4 0 0 0-.5 0L1.75 3.3c-.45.13-.75.52-.75.97zm7 9.09l-6-1.59V5l6 1.61v6.75zM2 4l2.5-.67L11 5.06l-2.5.67L2 4zm13 7.77l-6 1.59V6.61l2-.55V8.5l2-.53V5.53L15 5v6.77zm-2-7.24L6.5 2.8l2-.53L15 4l-2 .53z"
17+
/>
18+
</svg>
19+
);
20+
}

src/usedBy.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* @function UsedBy
3+
*/
4+
import * as PropTypes from "prop-types";
5+
import * as React from "react";
6+
7+
import GithubButton from "./lib/githubButton";
8+
9+
export interface IPropTypes {
10+
owner: string;
11+
repo: string;
12+
}
13+
14+
export default function UsedBy(props: IPropTypes) {
15+
return <GithubButton variant="usedby" { ...props } />;
16+
}
17+
18+
UsedBy.propTypes = {
19+
owner: PropTypes.string.isRequired,
20+
repo: PropTypes.string.isRequired,
21+
count: PropTypes.number.isRequired,
22+
};

0 commit comments

Comments
 (0)