Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add github star and fork icons in home page #309

Merged
merged 4 commits into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added img/fork.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/star.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions src/pages/home/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class Home extends Language {
super(props);
this.state = {
headerType: 'primary',
starCount: 0,
forkCount: 0,
};
}

Expand All @@ -33,9 +35,19 @@ class Home extends Language {
});
}
});

fetch('//api.github.com/repos/apache/incubator-dubbo')
.then(res => res.json())
.then((data) => {
this.setState({
starCount: data.stargazers_count,
forkCount: data.forks_count,
});
});
}

render() {
const { starCount, forkCount } = this.state;
const language = this.getLanguage();
const dataSource = homeConfig[language];
const { headerType } = this.state;
Expand All @@ -61,6 +73,24 @@ class Home extends Language {
<Button type="primary" link={getLink(dataSource.brand.getStartedButton.link)}>{dataSource.brand.getStartedButton.text}</Button>
<Button type="normal" link={getLink(dataSource.brand.viewOnGithubButton.link)}>{dataSource.brand.viewOnGithubButton.text}</Button>
</div>
<div className="github-buttons">
<a href="https://github.com/apache/incubator-dubbo">
<div className="star">
<img src="img/star.png" />
<span className="type">Star</span>
<span className="line" />
<span className="count">{starCount}</span>
</div>
</a>
<a href="https://github.com/apache/incubator-dubbo/fork">
<div className="fork">
<img src="img/fork.png" />
<span className="type">Fork</span>
<span className="line" />
<span className="count">{forkCount}</span>
</div>
</a>
</div>
</div>
<div className="animation animation1" />
<div className="animation animation2" />
Expand Down
35 changes: 34 additions & 1 deletion src/pages/home/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,39 @@
margin-right: 20px;
}
}
.github-buttons {
margin-top: 20px;
a {
margin-right: 0px;
margin-left: 20px;
img {
width: 16px;
height: 16px;
}
div {
border-radius: 2px;
display: inline-block;
height: 24px;
line-height: 24px;
padding-left: 5px;
color: #fff;
background: rgba(255, 255, 255, 0.2);
.type {
padding: 0 8px 0 4px;
}
.line {
display: inline-block;
box-sizing: border-box;
width: 1px;
height: 12px;
border-left: 1px solid rgba(255, 255, 255, 0.2);
}
.count {
padding: 0 14px;
}
}
}
}
}
.introduction-section {
background: #F9FAFA;
Expand Down Expand Up @@ -431,4 +464,4 @@
padding-right: 20px;
}
}
}
}