This repository was archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
feat(segment): add inverted prop and improved styles #389
Merged
Merged
Changes from all commits
Commits
Show all changes
2 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 hidden or 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
12 changes: 12 additions & 0 deletions
12
docs/src/examples/components/Segment/Variations/SegmentExampleInverted.shorthand.tsx
This file contains hidden or 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 * as React from 'react' | ||
| import { Segment } from '@stardust-ui/react' | ||
|
|
||
| const SegmentExampleInvertedShorthand = () => ( | ||
| <div> | ||
| <Segment content="Colored segment." color="purple" /> | ||
| <br /> | ||
| <Segment inverted content="Colored inverted segment" color="purple" /> | ||
| </div> | ||
| ) | ||
|
|
||
| export default SegmentExampleInvertedShorthand |
14 changes: 14 additions & 0 deletions
14
docs/src/examples/components/Segment/Variations/SegmentExampleInverted.tsx
This file contains hidden or 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 * as React from 'react' | ||
| import { Segment } from '@stardust-ui/react' | ||
|
|
||
| const SegmentExampleInvertedShorthand = () => ( | ||
| <div> | ||
| <Segment color="purple">Colored segment.</Segment> | ||
| <br /> | ||
| <Segment inverted color="purple"> | ||
| Colored inverted segment | ||
| </Segment> | ||
| </div> | ||
| ) | ||
|
|
||
| export default SegmentExampleInvertedShorthand |
This file contains hidden or 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,15 @@ | ||
| import React from 'react' | ||
| import ComponentExample from 'docs/src/components/ComponentDoc/ComponentExample' | ||
| import ExampleSection from 'docs/src/components/ComponentDoc/ExampleSection' | ||
|
|
||
| const Variations = () => ( | ||
| <ExampleSection title="Variations"> | ||
| <ComponentExample | ||
| title="Inverted" | ||
| description="A segment can have its colors inverted for contrast." | ||
| examplePath="components/Segment/Variations/SegmentExampleInverted" | ||
| /> | ||
| </ExampleSection> | ||
| ) | ||
|
|
||
| export default Variations |
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,14 +1,26 @@ | ||
| import { ICSSInJSStyle } from '../../../types' | ||
| import { SegmentProps } from 'semantic-ui-react' | ||
| import { ICSSInJSStyle, ComponentSlotStylesInput } from '../../../types' | ||
| import { SegmentVariables } from './segmentVariables' | ||
|
|
||
| export default { | ||
| root: ({ variables }: { variables: SegmentVariables }): ICSSInJSStyle => { | ||
| const segmentStyles: ComponentSlotStylesInput<SegmentProps, SegmentVariables> = { | ||
| root: ({ props: p, variables: v }): ICSSInJSStyle => { | ||
| const color = p.color || v.color | ||
| return { | ||
| padding: variables.padding, | ||
| background: variables.background, | ||
| border: '1px solid rgba(34,36,38,.15)', | ||
| borderRadius: variables.borderRadius, | ||
| boxShadow: '0 1px 2px 0 rgba(34,36,38,.15)', | ||
| padding: v.padding, | ||
| background: v.background, | ||
| borderRadius: v.borderRadius, | ||
| boxShadow: '0 1px 1px 1px rgba(34,36,38,.15)', | ||
| ...(color && | ||
| (p.inverted | ||
| ? { | ||
| background: color, | ||
| color: '#eee', | ||
| } | ||
| : { | ||
| borderTop: `2px solid ${color}`, | ||
| })), | ||
| } | ||
| }, | ||
| } | ||
|
|
||
| export default segmentStyles |
This file contains hidden or 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 |
|---|---|---|
| @@ -1,16 +1,17 @@ | ||
| import { pxToRem } from '../../../../lib' | ||
| import { ComponentVariablesPrepared } from '@stardust-ui/react' | ||
|
|
||
| export interface SegmentVariables { | ||
| padding: string | ||
| background: string | ||
| borderRadius: string | ||
| color: string | ||
| } | ||
|
|
||
| const segmentVariables: ComponentVariablesPrepared = siteVariables => ({ | ||
| padding: '1em', | ||
| background: siteVariables.bodyBackground, | ||
| borderRadius: pxToRem(5), | ||
| borderRadius: 0, | ||
| color: undefined, | ||
| }) | ||
|
|
||
| export default segmentVariables |
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.
Uh oh!
There was an error while loading. Please reload this page.