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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"@storybook/addons": "^5.3.17",
"@storybook/react": "^5.3.17",
"babel-loader": "^8.1.0",
"helix-ui": "^0.23.0",
"helix-ui": "^0.24.0",
"husky": "^4.2.5",
"parcel-bundler": "^1.12.4",
"prettier": "^2.0.4",
Expand Down
9 changes: 5 additions & 4 deletions src/Checkbox/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import PropTypes from 'prop-types';
import React, { useRef, useEffect } from 'react';

const Checkbox = ({ id, label, indeterminate, ...rest }) => {
const Checkbox = ({ id, label, indeterminate, className, ...rest }) => {
const inputRef = useRef();
useEffect(() => {
inputRef.current.indeterminate = indeterminate;
}, [indeterminate]);

return (
<hx-checkbox-control>
<hx-checkbox-control class={className}>
<input ref={inputRef} {...rest} id={id} type="checkbox" />
<label htmlFor={id}>
<hx-checkbox></hx-checkbox>
Expand All @@ -19,12 +19,13 @@ const Checkbox = ({ id, label, indeterminate, ...rest }) => {
};

Checkbox.propTypes = {
checked: PropTypes.bool.isRequired,
className: PropTypes.string,
checked: PropTypes.bool,
id: PropTypes.string.isRequired,
disabled: PropTypes.bool,
indeterminate: PropTypes.bool,
required: PropTypes.bool,
label: PropTypes.bool,
label: PropTypes.string,
name: PropTypes.string,
onChange: PropTypes.func,
};
Expand Down
9 changes: 8 additions & 1 deletion src/Drawer/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
import React from 'react';
import classnames from 'classnames';

import { SIZES } from '../constants';
import useEventListener from '../hooks/useEventListener';
Expand All @@ -8,7 +9,13 @@ import { wcBool } from '../utils';
const Drawer = ({ children, className, id, onClose, onOpen, open, size, ...rest }) => {
const hxRef = useEventListener({ onOpen, onClose });
return (
<hx-drawer class={(className, SIZES[size])} id={id} open={wcBool(open)} ref={hxRef} {...rest}>
<hx-drawer
class={classnames(className, SIZES[size])}
id={id}
open={wcBool(open)}
ref={hxRef}
{...rest}
>
{children}
</hx-drawer>
);
Expand Down
3 changes: 2 additions & 1 deletion src/Drawer/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ storiesOf('Drawer', module).add('All Knobs', () => {
const defaultBody = <p>{getLongText()}</p>;
const defaultHeader = 'Drawer Header';
const defaultFooter = (
<div class="hxButtonSet">
<div className="hxButtonSet">
<Button variant="primary">Confirm</Button>
<Button variant="tertiary">Cancel</Button>
</div>
Expand All @@ -36,6 +36,7 @@ storiesOf('Drawer', module).add('All Knobs', () => {
{...(size && { size })}
onOpen={action('onOpen')}
onClose={action('onClose')}
id="drawer-id"
>
{<header>{header || defaultHeader}</header>}
{<Div className="hxMd">{body || defaultBody}</Div>}
Expand Down
2 changes: 1 addition & 1 deletion src/Modal/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ storiesOf('Modal', module).add('All Knobs', () => {
let footer = text('footer', '');
let open = boolean('open', true);
let size = select('size', SIZES, 'medium');
let scroll = boolean('scroll', false);
let scroll = boolean('scroll', undefined);

const smallText =
'This is the body of a demo modal. Interaction with content behind this modal cannot take place until this modal is closed.\n';
Expand Down
24 changes: 24 additions & 0 deletions src/Pill/Status.js
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;
20 changes: 20 additions & 0 deletions src/Pill/index.js
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;
27 changes: 27 additions & 0 deletions src/Pill/stories.js
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>
);
});
2 changes: 1 addition & 1 deletion src/Popover/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ storiesOf('Popover', module)
let header = text('header', 'Popover Header');
let footer = text('footer', '');
let position = select('positions', POSITIONS, 'bottom-right');
let scroll = boolean('scroll', false);
let scroll = boolean('scroll', undefined);

const smallText = 'This is the body of a demo popover\n';
const longText = [1, 2, 3, 4, 5].map(() => <p>{getLongText()}</p>);
Expand Down
7 changes: 4 additions & 3 deletions src/Radio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';

const Radio = ({ id, label, className, ...rest }) => {
return (
<hx-radio-control>
<hx-radio-control class={className}>
<input {...rest} id={id} type="radio" />
<label htmlFor={id}>
<hx-radio></hx-radio>
Expand All @@ -14,11 +14,12 @@ const Radio = ({ id, label, className, ...rest }) => {
};

Radio.propTypes = {
checked: PropTypes.bool.isRequired,
label: PropTypes.string.isRequired,
className: PropTypes.string,
checked: PropTypes.bool,
id: PropTypes.string.isRequired,
disabled: PropTypes.bool,
required: PropTypes.bool,
label: PropTypes.bool,
name: PropTypes.string,
onChange: PropTypes.func,
};
Expand Down
3 changes: 1 addition & 2 deletions src/Search/SearchAssist.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 && (
<SearchAssistance
Expand All @@ -48,7 +48,6 @@ SearchAssist.propTypes = {
clearLabel: PropTypes.string,
label: PropTypes.string,
id: PropTypes.string.isRequired,
wrapperId: PropTypes.string,
disabled: PropTypes.bool,
onChange: PropTypes.func,
onFocus: PropTypes.func,
Expand Down
6 changes: 3 additions & 3 deletions src/Search/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const Search = ({
onClear,
optional,
required,
wrapperId,
containerId,
value,
...rest
}) => {
Expand All @@ -39,7 +39,7 @@ const Search = ({
}, [value]);

return (
<hx-search-control class={className} id={wrapperId}>
<hx-search-control class={className} id={containerId}>
<input
id={id}
value={value}
Expand Down Expand Up @@ -72,7 +72,7 @@ Search.propTypes = {
clearLabel: PropTypes.string,
label: PropTypes.string,
id: PropTypes.string.isRequired,
wrapperId: PropTypes.string,
containerId: PropTypes.string,
disabled: PropTypes.bool,
onChange: PropTypes.func,
onFocus: PropTypes.func,
Expand Down
4 changes: 2 additions & 2 deletions src/Search/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ storiesOf('Search', module)
{...(required && { required })}
{...(position && { position })}
onChange={action('change')}
autocomplete="off"
autoComplete="off"
/>
</InputContainer>
);
Expand All @@ -50,7 +50,7 @@ storiesOf('Search', module)
}}
onFocus={(e) => action('onFocus')}
onBlur={(e) => action('onBlur')}
autocomplete="off"
autoComplete="off"
{...(disabled && { disabled })}
{...(label && { label })}
{...(optional && { optional })}
Expand Down
23 changes: 14 additions & 9 deletions src/Select/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,19 @@ import classnames from 'classnames';
import PropTypes from 'prop-types';
import React from 'react';

const Select = ({ children, disabled, id, label, onChange, optional, required, ...rest }) => {
const Select = ({
children,
className,
disabled,
id,
label,
onChange,
optional,
required,
...rest
}) => {
return (
<hx-select-control>
<hx-select-control class={className}>
<select id={id} disabled={disabled} onChange={onChange} required={required} {...rest}>
{children}
</select>
Expand All @@ -26,18 +36,13 @@ const Select = ({ children, disabled, id, label, onChange, optional, required, .

Select.propTypes = {
children: PropTypes.node.isRequired,
disabled: PropTypes.bool.isRequired,
className: PropTypes.string,
disabled: PropTypes.bool,
id: PropTypes.string.isRequired,
label: PropTypes.string,
onChange: PropTypes.func.isRequired,
optional: PropTypes.bool,
required: PropTypes.bool,
};

Select.defaultProps = {
disabled: false,
optional: false,
required: false,
};

export default Select;
10 changes: 5 additions & 5 deletions src/Select/stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ 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);

return (
<Demo
{...(disabled && { disabled })}
{...(label && { label })}
label="Select Me"
{...(optional && { optional })}
{...(required && { required })}
/>
Expand All @@ -26,11 +26,11 @@ storiesOf('Select', module)

const Demo = (props) => {
return (
<div style={{ padding: 25, width: 500 }}>
<Select label="Select" onChange={action(`selected`)} {...props}>
<InputContainer>
<Select id="my-select" label="Select" onChange={action(`selected`)} {...props}>
<Options />
</Select>
</div>
</InputContainer>
);
};

Expand Down
33 changes: 33 additions & 0 deletions src/Switch/index.js
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;
25 changes: 25 additions & 0 deletions src/Switch/stories.js
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>
);
});
Loading