From a6ae3df115a22ba84a5e234bdb5dda9fda49c106 Mon Sep 17 00:00:00 2001 From: Nicko Winner-Arroyo Date: Fri, 31 Jul 2020 17:23:08 -0400 Subject: [PATCH 01/10] Text & Text Area - Using `container` prefix to describe the outer most tag. IE: containId, or containsClass --- src/Search/SearchAssist.js | 4 +-- src/Search/index.js | 6 ++-- src/Select/index.js | 11 ++------ src/Select/stories.js | 12 +++++--- src/Text/index.js | 40 +++++++++++++++++++++++++++ src/Text/stories.js | 56 ++++++++++++++++++++++++++++++++++++++ src/TextArea/index.js | 36 ++++++++++++++++++++++++ src/TextArea/stories.js | 26 ++++++++++++++++++ src/storyUtils.js | 2 +- 9 files changed, 175 insertions(+), 18 deletions(-) create mode 100644 src/Text/index.js create mode 100644 src/Text/stories.js create mode 100644 src/TextArea/index.js create mode 100644 src/TextArea/stories.js diff --git a/src/Search/SearchAssist.js b/src/Search/SearchAssist.js index 09e7a15..95c56da 100644 --- a/src/Search/SearchAssist.js +++ b/src/Search/SearchAssist.js @@ -25,7 +25,7 @@ const SearchAssist = ({ children, onFocus, onBlur, position, ...rest }) => { setOpen(true); onFocus && onFocus(e); }} - wrapperId={`${rest.id}-hx-search-control`} + containerId={`${rest.id}-hx-search-control`} /> {hasChildren && ( { @@ -39,7 +39,7 @@ const Search = ({ }, [value]); return ( - + { +const Select = ({ children, containerClass, disabled, id, label, onChange, optional, required, ...rest }) => { return ( - + @@ -26,6 +26,7 @@ const Select = ({ children, disabled, id, label, onChange, optional, required, . Select.propTypes = { children: PropTypes.node.isRequired, + containerClass: PropTypes.string, disabled: PropTypes.bool.isRequired, id: PropTypes.string.isRequired, label: PropTypes.string, @@ -34,10 +35,4 @@ Select.propTypes = { required: PropTypes.bool, }; -Select.defaultProps = { - disabled: false, - optional: false, - required: false, -}; - export default Select; diff --git a/src/Select/stories.js b/src/Select/stories.js index 890f58d..1965766 100644 --- a/src/Select/stories.js +++ b/src/Select/stories.js @@ -5,32 +5,36 @@ import { storiesOf } from '@storybook/react'; import React from 'react'; import Select from '../Select'; +import { InputContainer } from '../storyUtils'; storiesOf('Select', module) .addDecorator(centered) .add('All Knobs', () => { let disabled = boolean('disabled', false); - let label = text('label', ''); let optional = boolean('optional', false); let required = boolean('required', false); + let help = text('help', '' ); + let error = text('error', '' ); return ( ); }); const Demo = (props) => { return ( -
+ -
+ ); }; diff --git a/src/Text/index.js b/src/Text/index.js new file mode 100644 index 0000000..c2ba1ff --- /dev/null +++ b/src/Text/index.js @@ -0,0 +1,40 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import classnames from 'classnames'; + +const Text = ({ id, label, containerClass, required, optional, children, prefix, suffix, ...rest }) => { + return ( + + + + + {prefix && {prefix}} + {suffix && {suffix}} + {children} + + ); +}; + +Text.propTypes = { + id: PropTypes.string.isRequired, + containerClass: PropTypes.string, + children: PropTypes.node, + optional: PropTypes.bool, + disabled: PropTypes.bool, + required: PropTypes.bool, + label: PropTypes.bool, + name: PropTypes.string, + prefix: PropTypes.node, + suffix: PropTypes.node, + onChange: PropTypes.func, +}; + +export default Text; diff --git a/src/Text/stories.js b/src/Text/stories.js new file mode 100644 index 0000000..831353c --- /dev/null +++ b/src/Text/stories.js @@ -0,0 +1,56 @@ +import React from 'react'; +import { action } from '@storybook/addon-actions'; +import { boolean, text } from '@storybook/addon-knobs/react'; +import { storiesOf } from '@storybook/react'; +import Text from './index'; +import { InputContainer } from '../storyUtils'; + +storiesOf('Text', module) + .add('All Knobs', () => { + let disabled = boolean('disabled', false); + let required = boolean('required', false); + let optional = boolean('optional', false); + let prefix = text('prefix', '@' ); + let suffix = text('suffix', '.example.com' ); + + return ( + <> + + + + +

Prefix

+ + + + +

Suffix

+ + + + + ); + }); diff --git a/src/TextArea/index.js b/src/TextArea/index.js new file mode 100644 index 0000000..bf650e1 --- /dev/null +++ b/src/TextArea/index.js @@ -0,0 +1,36 @@ +import PropTypes from 'prop-types'; +import React from 'react'; +import classnames from 'classnames'; + +const TextArea = ({ id, label, containerClass, required, optional, children, ...rest }) => { + return ( + +