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(Label): add icon, iconPosition and onIconClick props #19
Merged
+235
−19
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
3651f7e
-added onRemove and removeIcon props in the Label component
8bff779
-added the same color for the remove icon as the label text color
f989873
-added record in the changelog
c555b7e
-added tabindex 0 to the remove icon
f274f5f
-deleted children API examples for the removable variation of the Label
0e44631
-remove children API example for the circular prop
3e97c5d
-replaced tabindex with tabIndex
eed20e2
-more specific selector for the remove icon
05a1961
Merge branch 'master' into feat/label-removable
ed11d4b
-added xSpacing before to the removable icon in the label
10d0743
-fixed changelog
93cd315
Merge branch 'master' into feat/label-removable
c119d3d
-added icon, iconPosition and onIconClick props in the Label component
de4fc7a
-changed CHANGELOG
62f6d54
-added icon, iconPosition and onIconClick props in the Label component
5d0c152
-reverted test file
1cd34e0
-added test for onIconClick
08fdae2
-replaced begin and after values for the iconPosition with start and end
d169ce7
-refactored icon definition
ff1386c
-fixes
23be579
Merge branch 'master' into feat/label-removable
mnajdova 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
6 changes: 0 additions & 6 deletions
6
docs/src/examples/components/Label/Variations/LabelExampleCircular.tsx
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
docs/src/examples/components/Label/Variations/LabelExampleIcon.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,6 @@ | ||
| import React from 'react' | ||
| import { Label } from '@stardust-ui/react' | ||
|
|
||
| const LabelExampleIconShorthand = () => <Label icon="coffee" content="Label containing icon" /> | ||
|
|
||
| export default LabelExampleIconShorthand |
11 changes: 11 additions & 0 deletions
11
docs/src/examples/components/Label/Variations/LabelExampleIcon.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,11 @@ | ||
| import React from 'react' | ||
| import { Label, Icon } from '@stardust-ui/react' | ||
|
|
||
| const LabelExampleIcon = () => ( | ||
| <Label> | ||
| <Icon name="coffee" xSpacing="after" variables={() => ({ color: 'rgba(0, 0, 0, 0.6)' })} /> | ||
| Label containing icon | ||
| </Label> | ||
| ) | ||
|
|
||
| export default LabelExampleIcon | ||
33 changes: 33 additions & 0 deletions
33
docs/src/examples/components/Label/Variations/LabelExampleIconAsShorthand.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,33 @@ | ||
| import React from 'react' | ||
| import { Label } from '@stardust-ui/react' | ||
|
|
||
| class LabelExampleIconAsShorthand extends React.Component<{}, { display: string }> { | ||
| constructor(props) { | ||
| super(props) | ||
| this.state = { | ||
| display: 'inline-block', | ||
| } | ||
| } | ||
|
|
||
| public hide = () => { | ||
| this.setState({ display: 'none' }) | ||
| } | ||
|
|
||
| public render() { | ||
| const { display } = this.state | ||
| return ( | ||
| <Label | ||
| circular | ||
| style={{ display }} | ||
| icon={{ | ||
| name: 'close', | ||
| onClick: this.hide, | ||
| }} | ||
| iconPosition="end" | ||
| content="Removable label" | ||
| /> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| export default LabelExampleIconAsShorthand |
8 changes: 8 additions & 0 deletions
8
docs/src/examples/components/Label/Variations/LabelExampleIconPosition.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,8 @@ | ||
| import React from 'react' | ||
| import { Label } from '@stardust-ui/react' | ||
|
|
||
| const LabelExampleIconPositionShorthand = () => ( | ||
| <Label circular icon="close" iconPosition="end" content="Label with icon after the content" /> | ||
| ) | ||
|
|
||
| export default LabelExampleIconPositionShorthand |
11 changes: 11 additions & 0 deletions
11
docs/src/examples/components/Label/Variations/LabelExampleIconPosition.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,11 @@ | ||
| import React from 'react' | ||
| import { Label, Icon } from '@stardust-ui/react' | ||
|
|
||
| const LabelExampleIconPosition = () => ( | ||
| <Label circular> | ||
| Label with icon after the content | ||
| <Icon name="close" xSpacing="before" variables={() => ({ color: 'rgba(0, 0, 0, 0.6)' })} /> | ||
| </Label> | ||
| ) | ||
|
|
||
| export default LabelExampleIconPosition |
31 changes: 31 additions & 0 deletions
31
docs/src/examples/components/Label/Variations/LabelExampleOnIconClick.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,31 @@ | ||
| import React from 'react' | ||
| import { Label } from '@stardust-ui/react' | ||
|
|
||
| class LabelExampleIconShorthand extends React.Component<{}, { display: string }> { | ||
| constructor(props) { | ||
| super(props) | ||
| this.state = { | ||
| display: 'inline-block', | ||
| } | ||
| } | ||
|
|
||
| public hide = () => { | ||
| this.setState({ display: 'none' }) | ||
| } | ||
|
|
||
| public render() { | ||
| const { display } = this.state | ||
| return ( | ||
| <Label | ||
| circular | ||
| style={{ display }} | ||
| icon="close" | ||
| iconPosition="end" | ||
| onIconClick={this.hide} | ||
| content="Removable label" | ||
| /> | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| export default LabelExampleIconShorthand |
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
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 was deleted.
Oops, something went wrong.
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,21 @@ | ||
| import React from 'react' | ||
| import { isConformant } from 'test/specs/commonTests' | ||
|
|
||
| import Label from 'src/components/Label/Label' | ||
| import { mountWithProvider } from '../../../utils' | ||
|
|
||
| describe('Label', () => { | ||
| isConformant(Label) | ||
|
|
||
| describe('onIconClick', () => { | ||
| it('calls onIconClick when the icon is clicked', () => { | ||
| const onClick = jest.fn() | ||
| const button = mountWithProvider( | ||
| <Label icon={{ name: 'close', key: 'icon-key' }} onIconClick={onClick} />, | ||
| ).find('Icon[name="close"]') | ||
| button.simulate('click') | ||
|
|
||
| expect(onClick).toHaveBeenCalled() | ||
| }) | ||
| }) | ||
| }) |
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.
note to myself - these keywords for
xSpacingshould be changed as wellThere 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.
We should introduce separate PR for the Icon's xSpacing and the Button's iconPosition to be consistent with the rest of the components.