-
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
Segment Examples #113
Merged
Merged
Segment Examples #113
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
9dce27e
Initial Segment Example
8b130fd
Knocked out Segment Types
cae7084
Segment groups
df62ab3
:lipstick:
4bf1b8d
Merge branch 'master' into segment-examples
80ccd17
Merge branch 'master' into segment-examples
38885cc
Add Segments component
dc85c6b
Segments only allow Segment children
0405e82
Removing unintended required prop
d624f49
Backpedal on use of invariant
3569ae1
Add custom prop type validator childrenOfTypesOnly
b5dd826
Nested Segments Example
db8404d
Segment groups and better doc
3d843d2
Segment states examples
216390b
Two Segment varation examples
66120db
Segment variation complex attach example
69161f9
Moar Segment variation examples
2ab92cc
Segment variations up to Circular
2a5d081
Last of the Segment examples
36956a6
Incorporating review feedback from @kyleturco
86ce4f2
Make use of chai's lengthOf assertion and simplify test
cb22811
Fixing style
5582082
Adding DocBlock defaults for known Component props
41753af
Merge branch 'master' into segment-examples
bdf9e19
Segments as class property; Refactor Statistic to use customPropType
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
42 changes: 42 additions & 0 deletions
42
docs/app/Examples/elements/Segment/Groups/SegmentGroupsExamples.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,42 @@ | ||
import React, {Component} from 'react'; | ||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'; | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'; | ||
|
||
export default class SegmentGroupsExamples extends Component { | ||
render() { | ||
return ( | ||
<ExampleSection title='Groups'> | ||
<ComponentExample | ||
title='Segments' | ||
description='A group of segments can be formatted to appear together.' | ||
examplePath='elements/Segment/Groups/SegmentSegmentsExample' | ||
/> | ||
<ComponentExample | ||
title='Nested Segments' | ||
description='A group of segments can be nested in another group of segments.' | ||
examplePath='elements/Segment/Groups/SegmentNestedSegmentsExample' | ||
/> | ||
<ComponentExample | ||
title='Horizontal Segments' | ||
description='A segment group can appear horizontally.' | ||
examplePath='elements/Segment/Groups/SegmentHorizontalSegmentsExample' | ||
/> | ||
<ComponentExample | ||
title='Raised Segments' | ||
description='A segment group can be raised.' | ||
examplePath='elements/Segment/Groups/SegmentRaisedSegmentsExample' | ||
/> | ||
<ComponentExample | ||
title='Stacked Segments' | ||
description='A segment group can be stacked.' | ||
examplePath='elements/Segment/Groups/SegmentStackedSegmentsExample' | ||
/> | ||
<ComponentExample | ||
title='Piled Segments' | ||
description='A segment group can be piled.' | ||
examplePath='elements/Segment/Groups/SegmentPiledSegmentsExample' | ||
/> | ||
</ExampleSection> | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
docs/app/Examples/elements/Segment/Groups/SegmentHorizontalSegmentsExample.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,14 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment, Segments} from 'stardust'; | ||
|
||
export default class SegmentHorizontalSegmentsExample extends Component { | ||
render() { | ||
return ( | ||
<Segments className='horizontal'> | ||
<Segment>Left</Segment> | ||
<Segment>Middle</Segment> | ||
<Segment>Right</Segment> | ||
</Segments> | ||
); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
docs/app/Examples/elements/Segment/Groups/SegmentNestedSegmentsExample.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,23 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment, Segments} from 'stardust'; | ||
|
||
export default class SegmentNestedSegmentsExample extends Component { | ||
render() { | ||
return ( | ||
<Segments> | ||
<Segment>Top</Segment> | ||
<Segments> | ||
<Segment>Nested Top</Segment> | ||
<Segment>Nested Middle</Segment> | ||
<Segment>Nested Bottom</Segment> | ||
</Segments> | ||
<Segments className='horizontal'> | ||
<Segment>Top</Segment> | ||
<Segment>Middle</Segment> | ||
<Segment>Bottom</Segment> | ||
</Segments> | ||
<Segment>Bottom</Segment> | ||
</Segments> | ||
); | ||
} | ||
} | ||
14 changes: 14 additions & 0 deletions
14
docs/app/Examples/elements/Segment/Groups/SegmentPiledSegmentsExample.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,14 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment, Segments} from 'stardust'; | ||
|
||
export default class SegmentPiledSegmentsExample extends Component { | ||
render() { | ||
return ( | ||
<Segments className='piled'> | ||
<Segment>Top</Segment> | ||
<Segment>Middle</Segment> | ||
<Segment>Bottom</Segment> | ||
</Segments> | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
docs/app/Examples/elements/Segment/Groups/SegmentRaisedSegmentsExample.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,14 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment, Segments} from 'stardust'; | ||
|
||
export default class SegmentRaisedSegmentsExample extends Component { | ||
render() { | ||
return ( | ||
<Segments className='raised'> | ||
<Segment>Left</Segment> | ||
<Segment>Middle</Segment> | ||
<Segment>Right</Segment> | ||
</Segments> | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
docs/app/Examples/elements/Segment/Groups/SegmentSegmentsExample.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,16 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment, Segments} from 'stardust'; | ||
|
||
export default class SegmentSegmentsExample extends Component { | ||
render() { | ||
return ( | ||
<Segments> | ||
<Segment>Top</Segment> | ||
<Segment>Middle</Segment> | ||
<Segment>Middle</Segment> | ||
<Segment>Middle</Segment> | ||
<Segment>Bottom</Segment> | ||
</Segments> | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
docs/app/Examples/elements/Segment/Groups/SegmentStackedSegmentsExample.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,14 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment, Segments} from 'stardust'; | ||
|
||
export default class SegmentStackedSegmentsExample extends Component { | ||
render() { | ||
return ( | ||
<Segments className='stacked'> | ||
<Segment>Top</Segment> | ||
<Segment>Middle</Segment> | ||
<Segment>Bottom</Segment> | ||
</Segments> | ||
); | ||
} | ||
} |
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,18 @@ | ||
import React, {Component} from 'react'; | ||
import SegmentTypesExamples from './Types/SegmentTypesExamples'; | ||
import SegmentGroupsExamples from './Groups/SegmentGroupsExamples'; | ||
import SegmentStatesExamples from './States/SegmentStatesExamples'; | ||
import SegmentVariationsExamples from './Variations/SegmentVariationsExamples'; | ||
|
||
export default class SegmentExamples extends Component { | ||
render() { | ||
return ( | ||
<div> | ||
<SegmentTypesExamples /> | ||
<SegmentGroupsExamples /> | ||
<SegmentStatesExamples /> | ||
<SegmentVariationsExamples /> | ||
</div> | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/app/Examples/elements/Segment/States/SegmentDisabledExample.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, {Component} from 'react'; | ||
import {Segment} from 'stardust'; | ||
|
||
export default class SegmentDisabledExample extends Component { | ||
render() { | ||
return ( | ||
<Segment className='disabled'> | ||
Disabled content | ||
</Segment> | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/app/Examples/elements/Segment/States/SegmentLoadingExample.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, {Component} from 'react'; | ||
import {Segment} from 'stardust'; | ||
|
||
export default class SegmentLoadingExample extends Component { | ||
render() { | ||
return ( | ||
<Segment className='loading'> | ||
Loading content. | ||
</Segment> | ||
); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
docs/app/Examples/elements/Segment/States/SegmentStatesExamples.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,22 @@ | ||
import React, {Component} from 'react'; | ||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'; | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'; | ||
|
||
export default class SegmentStatesExamples extends Component { | ||
render() { | ||
return ( | ||
<ExampleSection title='States'> | ||
<ComponentExample | ||
title='Disabled' | ||
description='A segment may show its content is disabled.' | ||
examplePath='elements/Segment/States/SegmentDisabledExample' | ||
/> | ||
<ComponentExample | ||
title='Loading' | ||
description='A segment may show its content is being loaded.' | ||
examplePath='elements/Segment/States/SegmentLoadingExample' | ||
/> | ||
</ExampleSection> | ||
); | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
docs/app/Examples/elements/Segment/Types/SegmentPiledExample.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,8 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment} from 'stardust'; | ||
|
||
export default class SegmentPiledExample extends Component { | ||
render() { | ||
return <Segment className='piled'>Pellentesque habitant morbi tristique senectus.</Segment>; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
docs/app/Examples/elements/Segment/Types/SegmentRaisedExample.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,8 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment} from 'stardust'; | ||
|
||
export default class SegmentRaisedExample extends Component { | ||
render() { | ||
return <Segment>Pellentesque habitant morbi tristique senectus.</Segment>; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
docs/app/Examples/elements/Segment/Types/SegmentSegmentExample.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,8 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment} from 'stardust'; | ||
|
||
export default class SegmentSegmentExample extends Component { | ||
render() { | ||
return <Segment>Pellentesque habitant morbi tristique senectus.</Segment>; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
docs/app/Examples/elements/Segment/Types/SegmentStackedExample.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,8 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment} from 'stardust'; | ||
|
||
export default class SegmentStackedExample extends Component { | ||
render() { | ||
return <Segment className='stacked'>Pellentesque habitant morbi tristique senectus.</Segment>; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
docs/app/Examples/elements/Segment/Types/SegmentTypesExamples.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,43 @@ | ||
import React, {Component} from 'react'; | ||
import ComponentExample from 'docs/app/Components/ComponentDoc/ComponentExample'; | ||
import ExampleSection from 'docs/app/Components/ComponentDoc/ExampleSection'; | ||
import {Message} from 'stardust'; | ||
|
||
export default class SegmentTypesExamples extends Component { | ||
render() { | ||
return ( | ||
<ExampleSection title='Types'> | ||
<ComponentExample | ||
title='Segment' | ||
description='A segment of content.' | ||
examplePath='elements/Segment/Types/SegmentSegmentExample' | ||
/> | ||
<ComponentExample | ||
title='Raised' | ||
description='A segment may be formatted to raise above the page.' | ||
examplePath='elements/Segment/Types/SegmentRaisedExample' | ||
/> | ||
<ComponentExample | ||
title='Stacked' | ||
description='A segment can be formatted to show it contains multiple pages.' | ||
examplePath='elements/Segment/Types/SegmentStackedExample' | ||
/> | ||
<ComponentExample | ||
title='Piled' | ||
description='A segment can be formatted to look like a pile of pages.' | ||
examplePath='elements/Segment/Types/SegmentPiledExample' | ||
> | ||
<Message className='warning'> | ||
Piled segments use <b>negative z-index</b> to format the additional pages below the segment. | ||
In order for them to appear correctly, your segment's offset container must have a z-index declared. | ||
</Message> | ||
</ComponentExample> | ||
<ComponentExample | ||
title='Vertical Segment' | ||
description='A vertical segment formats content to be aligned as part of a vertical group.' | ||
examplePath='elements/Segment/Types/SegmentVerticalSegmentExample' | ||
/> | ||
</ExampleSection> | ||
); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
docs/app/Examples/elements/Segment/Types/SegmentVerticalSegmentExample.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,14 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment} from 'stardust'; | ||
|
||
export default class SegmentVerticalExample extends Component { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tiny difference between file & class name |
||
render() { | ||
return ( | ||
<Segment> | ||
<Segment className='vertical'>Te eum doming eirmod, nominati pertinacia argumentum ad his.</Segment> | ||
<Segment className='vertical'>Pellentesque habitant morbi tristique senectus.</Segment> | ||
<Segment className='vertical'>Eu quo homero blandit intellegebat. Incorrupte consequuntur mei id.</Segment> | ||
</Segment> | ||
); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
docs/app/Examples/elements/Segment/Variations/SegmentAttachedComplexExample.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,33 @@ | ||
import React, {Component} from 'react'; | ||
import {Header, Message, Segment, Segments} from 'stardust'; | ||
|
||
export default class SegmentAttachedComplexExample extends Component { | ||
render() { | ||
return ( | ||
<Segments> | ||
<Header.H5 className='attached'> | ||
Dogs | ||
</Header.H5> | ||
<Segment className='attached segment'> | ||
Dogs are one type of animal | ||
</Segment> | ||
<Header.H5 className='attached header'> | ||
Cats | ||
</Header.H5> | ||
<Segment className='attached segment'> | ||
Cats are thought of as being related to dogs, but only humans think this. | ||
</Segment> | ||
<Header.H5 className='attached header'> | ||
Lions | ||
</Header.H5> | ||
<Segment className='attached segment'> | ||
Humans don't think of lions as being like cats, but they are. | ||
</Segment> | ||
<Message className='bottom attached warning'> | ||
<i className='warning icon'></i> | ||
You've reached the end of this content segment! | ||
</Message> | ||
</Segments> | ||
); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
docs/app/Examples/elements/Segment/Variations/SegmentAttachedExample.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,20 @@ | ||
import React, {Component} from 'react'; | ||
import {Segment, Segments} from 'stardust'; | ||
|
||
export default class SegmentAttachedExample extends Component { | ||
render() { | ||
return ( | ||
<Segments> | ||
<Segment className='top attached'> | ||
This segment is on top | ||
</Segment> | ||
<Segment className='attached'> | ||
This segment is attached on both sides | ||
</Segment> | ||
<Segment className='bottom attached'> | ||
This segment is on bottom | ||
</Segment> | ||
</Segments> | ||
); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/app/Examples/elements/Segment/Variations/SegmentInvertedExample.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, {Component} from 'react'; | ||
import {Segment} from 'stardust'; | ||
|
||
export default class SegmentInvertedExample extends Component { | ||
render() { | ||
return ( | ||
<Segment className='inverted'> | ||
Inverted content. | ||
</Segment> | ||
); | ||
} | ||
} |
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.
Posing a question here - would it make sense here for the text to be taken in as a child and have all these be self closing? As in -
<Segment caption="Nested Top" />
. From a readability standpoint, it feels a bit cluttered.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 can see where that could get pretty unwieldy looking at the examples below with longer lines of text.
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.
Agreed on the clutter. I'm not sure how many IRL use cases we'll have were we'll be using a simple text body. Regardless I'm happy to make a prop for text-only tag body content.
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.
Yeah that's what I was wondering. The docs examples definitely have situations that rarely happen in the wild, so this might not be a big issue.