Skip to content

Commit

Permalink
docs(Rating): add Rating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
levithomason committed Aug 8, 2016
1 parent 12ecf39 commit fc71b75
Show file tree
Hide file tree
Showing 10 changed files with 171 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ Be sure to check out the above migrations before embarking on a new component.
| x Image | | | _ Nag | |
| x Input | | | _ Popup | |
| x Label | | | x Progress | |
| x List | | | _ Rating | |
| x List | | | x Rating | |
| x Loader | | | _ Search | |
| x Rail | | | _ Shape | |
| _ Reveal | | | _ Sidebar | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Rating } from 'stardust'

const RatingClearableExample = () => (
<Rating maxRating={5} clearable />
)

export default RatingClearableExample
21 changes: 21 additions & 0 deletions docs/app/Examples/modules/Rating/Types/RatingControlledExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React, { Component } from 'react'
import { Rating } from 'stardust'

export default class RatingControlledExample extends Component {
state = { rating: 0 }

handleChange = (e) => this.setState({ rating: e.target.value })

render() {
const { rating } = this.state

return (
<div>
<div>Rating: {rating}</div>
<input type='range' min={0} max={5} value={rating} onChange={this.handleChange} />
<br />
<Rating rating={this.state.rating} maxRating={5} />
</div>
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Rating } from 'stardust'

const RatingDisabledExample = () => (
<Rating defaultRating={3} maxRating={5} disabled />
)

export default RatingDisabledExample
8 changes: 8 additions & 0 deletions docs/app/Examples/modules/Rating/Types/RatingHeartExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Rating } from 'stardust'

const RatingHeartExample = () => (
<Rating icon='heart' defaultRating={1} maxRating={3} />
)

export default RatingHeartExample
17 changes: 17 additions & 0 deletions docs/app/Examples/modules/Rating/Types/RatingOnRateExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React, { Component } from 'react'
import { Rating } from 'stardust'

export default class RatingOnRateExample extends Component {
state = {}

handleRate = (e, { rating, maxRating }) => this.setState({ rating, maxRating })

render() {
return (
<div>
<Rating maxRating={5} onRate={this.handleRate} />
<pre>{JSON.stringify(this.state, null, 2)}</pre>
</div>
)
}
}
8 changes: 8 additions & 0 deletions docs/app/Examples/modules/Rating/Types/RatingRatingExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Rating } from 'stardust'

const RatingExample = () => (
<Rating />
)

export default RatingExample
8 changes: 8 additions & 0 deletions docs/app/Examples/modules/Rating/Types/RatingStarExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import { Rating } from 'stardust'

const RatingStarExample = () => (
<Rating icon='star' defaultRating={3} maxRating={4} />
)

export default RatingStarExample
35 changes: 35 additions & 0 deletions docs/app/Examples/modules/Rating/Variations/RatingSizeExample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react'
import { Rating } from 'stardust'

const RatingSizeExample = () => (
<div>
<Rating maxRating={5} defaultRating={3} icon='star' size='mini' />
<br />
<br />

<Rating maxRating={5} defaultRating={3} icon='star' size='tiny' />
<br />
<br />

<Rating maxRating={5} defaultRating={3} icon='star' size='small' />
<br />
<br />

<Rating maxRating={5} defaultRating={3} icon='star' />
<br />
<br />

<Rating maxRating={5} defaultRating={3} icon='star' size='large' />
<br />
<br />

<Rating maxRating={5} defaultRating={3} icon='star' size='huge' />
<br />
<br />

<Rating maxRating={5} defaultRating={3} icon='star' size='massive' />
<br />
<br />
</div>
)
export default RatingSizeExample
57 changes: 57 additions & 0 deletions docs/app/Examples/modules/Rating/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React, { Component } from 'react'
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'

export default class RatingExamples extends Component {
render() {
return (
<div>
<ExampleSection title='Types'>
<ComponentExample
title='Rating'
description='A basic rating'
examplePath='modules/Rating/Types/RatingRatingExample'
/>
<ComponentExample
title='Star'
description='A rating can use a set of star icons'
examplePath='modules/Rating/Types/RatingStarExample'
/>
<ComponentExample
title='Heart'
description='A rating can use a set of heart icons'
examplePath='modules/Rating/Types/RatingHeartExample'
/>
<ComponentExample
title='Clearable'
description='A rating can be cleared by clicking again'
examplePath='modules/Rating/Types/RatingClearableExample'
/>
<ComponentExample
title='Disabled'
description='A rating can be disabled'
examplePath='modules/Rating/Types/RatingDisabledExample'
/>
<ComponentExample
title='Controlled'
description='A rating can be a controlled component'
examplePath='modules/Rating/Types/RatingControlledExample'
/>
<ComponentExample
title='onRate Callback'
description='A rating calls back when the rating changes'
examplePath='modules/Rating/Types/RatingOnRateExample'
/>
</ExampleSection>

<ExampleSection title='Variations'>
<ComponentExample
title='Size'
description='A rating can vary in size'
examplePath='modules/Rating/Variations/RatingSizeExample'
/>
</ExampleSection>
</div>
)
}
}

0 comments on commit fc71b75

Please sign in to comment.