@@ -6,14 +6,15 @@ import * as React from "react";
66
77import classes from "../styles.css" ;
88
9- import StarIcon from "./icons/starIcon" ;
109import ForkIcon from "./icons/forkIcon" ;
10+ import StarIcon from "./icons/starIcon" ;
11+ import WatchIcon from "./icons/watchIcon" ;
1112
1213function getDataForVariant (
1314 variant : string ,
1415 count : number ,
1516 owner : string ,
16- repo : string
17+ repo : string ,
1718 ) : {
1819 title : string ;
1920 btnTitle : string ;
@@ -35,10 +36,16 @@ function getDataForVariant(
3536 title = "Fork" ;
3637 btnTitle = `Fork your own copy of ${ owner } /${ repo } to your account` ;
3738 label = `${ count } users forked this repository` ;
38- countUrl = `https://github.com/vaibhavhrt/react-github-buttons /network/members` ;
39+ countUrl = `https://github.com/${ owner } / ${ repo } /network/members` ;
3940 return { title, btnTitle, label, countUrl, Icon : ForkIcon } ;
41+ } else if ( variant === "watch" ) {
42+ title = "Watch" ;
43+ btnTitle = "" ;
44+ label = `${ count } users are watching this repository` ;
45+ countUrl = `https://github.com/${ owner } /${ repo } /watchers` ;
46+ return { title, btnTitle, label, countUrl, Icon : WatchIcon } ;
4047 }
41- throw new Error ( "Invalid Variant, supply one of [star, fork]" ) ;
48+ throw new Error ( "Invalid Variant, supply one of [star, fork, watch ]" ) ;
4249}
4350
4451export interface IPropTypes {
@@ -56,7 +63,7 @@ export default function GithubButton(props: IPropTypes) {
5663 < div className = { classes . root } >
5764 < button title = { btnTitle } className = { classes . button } >
5865 < Icon />
59- { title }
66+ { ` ${ title } ` }
6067 </ button >
6168 < a
6269 className = { classes . count }
@@ -75,5 +82,5 @@ GithubButton.propTypes = {
7582 count : PropTypes . node . isRequired ,
7683 owner : PropTypes . string . isRequired ,
7784 repo : PropTypes . string . isRequired ,
78- variant : PropTypes . oneOf ( [ "star" , "fork" ] ) ,
85+ variant : PropTypes . oneOf ( [ "star" , "fork" , "watch" ] ) ,
7986} ;
0 commit comments