-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Statistic: enhance shorthand props and propTypes #390
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react' | ||
import { Statistic } from 'stardust' | ||
|
||
const items = [ | ||
{ label: 'Saves', value: '22' }, | ||
{ label: 'Signups', text: true, value: 'Three Thousand' }, | ||
{ label: 'Flights', value: '5' }, | ||
{ label: 'Team Members', value: '42' }, | ||
] | ||
|
||
const Props = () => ( | ||
<div> | ||
<Statistic.Group> | ||
<Statistic label='Saves' value='22' /> | ||
<Statistic label='Signups' value='Three Thousand' text /> | ||
<Statistic label='Flights' value='5' /> | ||
<Statistic label='Team Members' value='42' /> | ||
</Statistic.Group> | ||
|
||
<Statistic.Group items={items} /> | ||
</div> | ||
) | ||
|
||
export default Props |
39 changes: 0 additions & 39 deletions
39
docs/app/Examples/views/Statistic/Content/StatisticValuePropsExample.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react' | ||
|
||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' | ||
|
||
const Content = () => ( | ||
<ExampleSection title='Content'> | ||
<ComponentExample | ||
title='Value' | ||
description='A statistic can contain a numeric, icon, image, or text value' | ||
examplePath='views/Statistic/Content/Values' | ||
/> | ||
<ComponentExample examplePath='views/Statistic/Content/Props' /> | ||
|
||
<ComponentExample | ||
title='Label' | ||
description='A statistic can contain a label to help provide context for the presented value' | ||
examplePath='views/Statistic/Content/Labels' | ||
/> | ||
</ExampleSection> | ||
) | ||
|
||
export default Content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from 'react' | ||
|
||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample' | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection' | ||
|
||
const Types = () => ( | ||
<ExampleSection title='Types'> | ||
<ComponentExample | ||
title='Statistic' | ||
description='A statistic can display a value with a label above or below it' | ||
examplePath='views/Statistic/Types/BottomLabel' | ||
/> | ||
<ComponentExample examplePath='views/Statistic/Types/TopLabel' /> | ||
|
||
<ComponentExample | ||
title='Statistic Group' | ||
description='A group of statistics' | ||
examplePath='views/Statistic/Types/Groups' | ||
/> | ||
</ExampleSection> | ||
) | ||
|
||
export default Types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
docs/app/Examples/views/Statistic/Variations/EvenlyDivided.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react' | ||
import { Icon, Image, Statistic } from 'stardust' | ||
|
||
const { Group, Label, Value } = Statistic | ||
|
||
const EvenlyDivided = () => ( | ||
<Group widths='four'> | ||
<Statistic> | ||
<Value>22</Value> | ||
<Label>Saves</Label> | ||
</Statistic> | ||
|
||
<Statistic> | ||
<Value text> | ||
Three | ||
<br />Thousand | ||
</Value> | ||
<Label>Signups</Label> | ||
</Statistic> | ||
|
||
<Statistic> | ||
<Value> | ||
<Icon name='plane' /> | ||
5 | ||
</Value> | ||
<Label>Flights</Label> | ||
</Statistic> | ||
|
||
<Statistic> | ||
<Value> | ||
<Image src='http://semantic-ui.com/images/avatar/small/joe.jpg' className='circular inline' /> | ||
42 | ||
</Value> | ||
<Label>Team Members</Label> | ||
</Statistic> | ||
</Group> | ||
) | ||
|
||
export default EvenlyDivided |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react' | ||
import { Statistic } from 'stardust' | ||
|
||
const Horizontal = () => <Statistic horizontal value='2,204' label='Views' /> | ||
|
||
export default Horizontal |
12 changes: 12 additions & 0 deletions
12
docs/app/Examples/views/Statistic/Variations/HorizontalGroup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import { Statistic } from 'stardust' | ||
|
||
const items = [ | ||
{ label: 'Views', value: '2,204' }, | ||
{ label: 'Downloads', value: '3,322' }, | ||
{ label: 'Tasks', value: '22' }, | ||
] | ||
|
||
const HorizontalGroup = () => <Statistic.Group horizontal items={items} /> | ||
|
||
export default HorizontalGroup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI I think these would work as numbers as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope 😄
22
is number, while'22'
is string.Ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just change the propType validation to string/number. Since technically it could support
node
as it ends up here:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It cannot be
node
, as it's used for key onStepGroup
.I think that it's not good solution. This raises the question of the behavior of other properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. OK, perhaps we only stick with string/number then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we use string/number, we need allow it to all shorthand props.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I suppose you are right about this. Feel free to update here or we can merge this and make that update next.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make a separate PR for this actually. The PR will resolve #391.