-
Notifications
You must be signed in to change notification settings - Fork 6
Text, Text Area, Switch, Pill #106
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a6ae3df
Text & Text Area
nicko-winner a9bf5eb
make it pretty
nicko-winner 274ba8c
Remove Help Error
nicko-winner 069d38e
Put class names on wrapping element.
nicko-winner 0ef74be
make it pretty
nicko-winner e2be307
Update Helix React, Fix Prop warnings, Add Pill and Switch
nicko-winner 380e839
make sure all imports are included
nicko-winner 5b43054
Make it pretty
nicko-winner 8c757b2
Merge branch 'master' into TextAndTextArea
nicko-winner 94948f5
Core Review Changes
nicko-winner 4e3639a
make it pretty
nicko-winner 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import PropTypes from 'prop-types'; | ||
| import React from 'react'; | ||
| import classnames from 'classnames'; | ||
|
|
||
| const PILL_VARIANTS = { | ||
| grey: 'hxEmphasisGray', | ||
| purple: 'hxEmphasisPurple', | ||
| subdued: 'hxSubdued', | ||
| }; | ||
|
|
||
| const Status = ({ className, children, variant, filled, ...rest }) => { | ||
| return ( | ||
| <hx-status class={classnames(className, PILL_VARIANTS[variant], { hxFill: filled })} {...rest}> | ||
| {children} | ||
| </hx-status> | ||
| ); | ||
| }; | ||
|
|
||
| Status.propTypes = { | ||
| variant: PropTypes.oneOf(Object.keys(PILL_VARIANTS)), | ||
| filled: PropTypes.bool, | ||
| }; | ||
|
|
||
| export default Status; |
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,20 @@ | ||
| import PropTypes from 'prop-types'; | ||
| import React from 'react'; | ||
| import classnames from 'classnames'; | ||
| import useEventListener from '../hooks/useEventListener'; | ||
|
|
||
| const Pill = ({ className, children, onDismiss, ...rest }) => { | ||
| const hxRef = useEventListener({ onDismiss }); | ||
| return ( | ||
| <hx-pill class={className} {...rest} ref={hxRef}> | ||
| {children} | ||
| </hx-pill> | ||
| ); | ||
| }; | ||
|
|
||
| Pill.propTypes = { | ||
| persist: PropTypes.bool, | ||
| onDismiss: PropTypes.func, | ||
| }; | ||
|
|
||
| export default Pill; |
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,27 @@ | ||
| import React from 'react'; | ||
| import { action } from '@storybook/addon-actions'; | ||
| import { boolean, text, select } from '@storybook/addon-knobs/react'; | ||
| import { storiesOf } from '@storybook/react'; | ||
| import Pill from './index'; | ||
| import Status from './Status'; | ||
|
|
||
| storiesOf('Pill', module) | ||
| .add('All Knobs', () => { | ||
| let persist = boolean('persist', false); | ||
| let pillText = text('pill text', 'status: unicorns!'); | ||
| return ( | ||
| <Pill onDismiss={action('onDismiss')} {...(persist && { persist })}> | ||
| {pillText} | ||
| </Pill> | ||
| ); | ||
| }) | ||
| .add('Status Pill', () => { | ||
| let filled = boolean('filled', false); | ||
| let pillText = text('pill text', 'default'); | ||
| let variant = select('variant', ['default', 'grey', 'purple', 'subdued']); | ||
| return ( | ||
| <Status variant={variant} {...(filled && { filled })}> | ||
| {pillText} | ||
| </Status> | ||
| ); | ||
| }); |
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 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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import PropTypes from 'prop-types'; | ||
| import React from 'react'; | ||
| import classnames from 'classnames'; | ||
|
|
||
| const Switch = ({ id, className, onLabel, offLabel, invalid, ...rest }) => { | ||
| return ( | ||
| <hx-switch-control class={classnames('switch', className)}> | ||
| <input type="checkbox" id={id} {...rest} invalid={invalid?.toString()} /> | ||
| <label htmlFor={id}> | ||
| <hx-switch onlabel={onLabel} offlabel={offLabel} aria-labelledby={id} /> | ||
| </label> | ||
| </hx-switch-control> | ||
| ); | ||
| }; | ||
|
|
||
| Switch.propTypes = { | ||
| id: PropTypes.string.isRequired, | ||
| onLabel: PropTypes.string, | ||
| offLabel: PropTypes.string, | ||
| className: PropTypes.string, | ||
| disabled: PropTypes.bool, | ||
| invalid: PropTypes.bool, | ||
| label: PropTypes.bool, | ||
| name: PropTypes.string, | ||
| onChange: PropTypes.func, | ||
| }; | ||
|
|
||
| Switch.defaultProps = { | ||
| onLabel: '', | ||
| offLabel: '', | ||
| }; | ||
|
|
||
| export default Switch; |
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,25 @@ | ||
| import React from 'react'; | ||
| import { action } from '@storybook/addon-actions'; | ||
| import { boolean, text } from '@storybook/addon-knobs/react'; | ||
| import { storiesOf } from '@storybook/react'; | ||
| import { InputContainer } from '../storyUtils'; | ||
| import Switch from './index'; | ||
|
|
||
| storiesOf('Switch', module).add('All Knobs', () => { | ||
| let disabled = boolean('disabled', false); | ||
| let invalid = boolean('invalid', false); | ||
| let onLabel = text('onLabel', ''); | ||
| let offLabel = text('offLabel', ''); | ||
| return ( | ||
| <InputContainer> | ||
| <Switch | ||
| id="textDemo" | ||
| {...(disabled && { disabled })} | ||
| {...(invalid && { invalid })} | ||
| {...(onLabel && { onLabel })} | ||
| {...(offLabel && { offLabel })} | ||
| onChange={action('onChange')} | ||
| /> | ||
| </InputContainer> | ||
| ); | ||
| }); |
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.
Uh oh!
There was an error while loading. Please reload this page.