Skip to content

Commit 681907b

Browse files
committed
Add loading class, Odometer, and polling
1 parent b3ed68d commit 681907b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/StarCount.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,16 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33
import { Query } from 'react-apollo'
44
import gql from 'graphql-tag'
5+
import classNames from 'classnames'
6+
import Odometer from 'react-odometerjs'
57

68
const StarCount = ({ githubStars, loading }) => {
79
return (
8-
<a className="StarCount" href="https://github.com/GraphQLGuide/guide">
9-
{githubStars}
10+
<a
11+
className={classNames('StarCount', { loading })}
12+
href="https://github.com/GraphQLGuide/guide"
13+
>
14+
{githubStars && <Odometer value={githubStars} />}
1015
</a>
1116
)
1217
}
@@ -23,7 +28,7 @@ const STARS_QUERY = gql`
2328
`
2429

2530
export default () => (
26-
<Query query={STARS_QUERY}>
31+
<Query query={STARS_QUERY} pollInterval={5 * 1000}>
2732
{({ data: { githubStars }, loading }) => (
2833
<StarCount githubStars={githubStars} loading={loading} />
2934
)}

0 commit comments

Comments
 (0)