Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import classnames from 'classnames';
const Text = ({
id,
label,
invalid,
className,
required,
optional,
Expand All @@ -15,7 +16,7 @@ const Text = ({
...rest
}) => {
return (
<hx-text-control class={className} style={style}>
<hx-text-control class={classnames(className, { hxInvalid: invalid })} style={style}>
<input {...rest} id={id} required={required} type="text" />
<label
className={classnames({
Expand All @@ -26,7 +27,6 @@ const Text = ({
>
{label}
</label>

{prefix && <span className="hxPrefix">{prefix}</span>}
{suffix && <span className="hxSuffix">{suffix}</span>}
{children}
Expand All @@ -41,6 +41,7 @@ Text.propTypes = {
children: PropTypes.node,
optional: PropTypes.bool,
disabled: PropTypes.bool,
invalid: PropTypes.bool,
required: PropTypes.bool,
label: PropTypes.string,
name: PropTypes.string,
Expand Down
7 changes: 6 additions & 1 deletion src/Text/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ addParameters({
storiesOf('Text', module).add('All Knobs', () => {
let disabled = boolean('disabled', false);
let required = boolean('required', false);
let invalid = boolean('invalid', false);
let optional = boolean('optional', false);
let label = text('label', 'Text Label');
let prefix = text('prefix', '@');
let suffix = text('suffix', '.example.com');

Expand All @@ -21,10 +23,11 @@ storiesOf('Text', module).add('All Knobs', () => {
<InputContainer>
<Text
id="textDemo"
{...(label && { label })}
{...(disabled && { disabled })}
{...(required && { required })}
{...(invalid && { invalid })}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few component examples in this file, it might be good to update them all with an invalid state since they all support disabled, required, etc.

{...(optional && { optional })}
label="Username"
onChange={callback(action('onChange'))}
/>

Expand All @@ -35,6 +38,7 @@ storiesOf('Text', module).add('All Knobs', () => {
{...(disabled && { disabled })}
{...(required && { required })}
{...(optional && { optional })}
{...(invalid && { invalid })}
{...(prefix && { prefix })}
label="twitter handle"
onChange={callback(action('onChange'))}
Expand All @@ -47,6 +51,7 @@ storiesOf('Text', module).add('All Knobs', () => {
{...(disabled && { disabled })}
{...(required && { required })}
{...(optional && { optional })}
{...(invalid && { invalid })}
{...(suffix && { suffix })}
label="Subdomain"
onChange={callback(action('onChange'))}
Expand Down
18 changes: 15 additions & 3 deletions src/TextArea/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,21 @@ import PropTypes from 'prop-types';
import React from 'react';
import classnames from 'classnames';

const TextArea = ({ id, label, className, required, optional, children, style, ...rest }) => {
const TextArea = ({
id,
label,
className,
required,
disabled,
optional,
invalid,
children,
style,
...rest
}) => {
return (
<hx-textarea-control class={className} style={style}>
<textarea {...rest} id={id} required={required} />
<hx-textarea-control class={classnames(className, { hxInvalid: invalid })} style={style}>
<textarea {...rest} id={id} required={required} disabled={disabled} />
<label
className={classnames({
hxOptional: optional,
Expand All @@ -28,6 +39,7 @@ TextArea.propTypes = {
optional: PropTypes.bool,
disabled: PropTypes.bool,
required: PropTypes.bool,
invalid: PropTypes.bool,
label: PropTypes.bool,
name: PropTypes.string,
onChange: PropTypes.func,
Expand Down
5 changes: 4 additions & 1 deletion src/TextArea/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ addParameters({
storiesOf('TextArea', module).add('All Knobs', () => {
let disabled = boolean('disabled', false);
let required = boolean('required', false);
let invalid = boolean('invalid', false);
let optional = boolean('optional', false);
let label = text('label', 'TextArea Label');

return (
<InputContainer>
<TextArea
id="textAreaDemo"
lable="Comments"
{...(label && { label })}
{...(disabled && { disabled })}
{...(required && { required })}
{...(invalid && { invalid })}
{...(optional && { optional })}
onChange={callback(action('onChange'))}
/>
Expand Down