diff --git a/package.json b/package.json index 5a10f81..380bf92 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "@storybook/addons": "^5.3.17", "@storybook/react": "^5.3.17", "babel-loader": "^8.1.0", - "helix-ui": "^0.24.0", + "helix-ui": "^2.0.0", "husky": "^4.2.5", "microbundle": "^0.12.3", "prettier": "^2.0.4", @@ -68,7 +68,7 @@ "use-onclickoutside": "^0.3" }, "peerDependencies": { - "helix-ui": "^0.24.0", + "helix-ui": "^2.0.0", "prop-types": "^15.7.2", "react": "^16.6.3" }, diff --git a/src/Alert/index.js b/src/Alert/index.js index cde272f..b27c9a1 100644 --- a/src/Alert/index.js +++ b/src/Alert/index.js @@ -1,18 +1,23 @@ -import React from 'react'; +import React, { useRef } from 'react'; import PropTypes from 'prop-types'; import useEventListener from '../hooks/useEventListener'; +import useCombinedRefs from '../hooks/useCombinedRefs'; -const Alert = ({ onOpen, onClose, className, children, onDismiss, onSubmit, ...rest }) => { - const hxRef = useEventListener({ onDismiss, onSubmit }); - return ( -
- {/* Wrappping element needed: Otherwise when alert removes itself from DOM on close, it will cause error */} - - {children} - -
- ); -}; +const Alert = React.forwardRef( + ({ onOpen, onClose, className, children, onDismiss, onSubmit, ...rest }, ref) => { + const hxRef = useEventListener({ onDismiss, onSubmit }, ref); + return ( +
+ {/* Wrappping element needed: Otherwise when alert removes itself from DOM on close, it will cause error */} + + {children} + +
+ ); + } +); + +Alert.displayName = 'Alert'; Alert.propTypes = { className: PropTypes.string, diff --git a/src/Breadcrumb/index.js b/src/Breadcrumb/index.js index aab8349..8f6a1f2 100644 --- a/src/Breadcrumb/index.js +++ b/src/Breadcrumb/index.js @@ -8,7 +8,7 @@ const Breadcrumb = ({ children, icon = 'angle-right', addDelimiter = true, ...re ? children.map((child, index) => [ child, addDelimiter && index + 1 < children.length && ( - + ), ]) : children; @@ -22,7 +22,7 @@ const Breadcrumb = ({ children, icon = 'angle-right', addDelimiter = true, ...re Breadcrumb.propTypes = { icon: PropTypes.string, - children: PropTypes.func, + children: PropTypes.node, }; export default Breadcrumb; diff --git a/src/Breadcrumb/stories.js b/src/Breadcrumb/stories.js index d884a11..db6f076 100644 --- a/src/Breadcrumb/stories.js +++ b/src/Breadcrumb/stories.js @@ -1,5 +1,6 @@ import React from 'react'; import { addParameters, storiesOf } from '@storybook/react'; +import { text } from '@storybook/addon-knobs/react'; import Breadcrumb from './index'; addParameters({ @@ -8,18 +9,22 @@ addParameters({ storiesOf('Breadcrumb', module) .add('Multiple Breadcrumbs', () => { + let item1 = text('item1', 'Home'); + let item2 = text('item2', 'Library'); + let item3 = text('item3', 'Current'); return ( - Home - Library - Current + {item1} + {item2} + {item3} ); }) .add('Single Breadcrumb', () => { + let item1 = text('item1', 'Home'); return ( - Home + {item1} ); }); diff --git a/src/Busy/index.js b/src/Busy/index.js index bb5515e..4edd27e 100644 --- a/src/Busy/index.js +++ b/src/Busy/index.js @@ -3,7 +3,7 @@ import React from 'react'; // Storybook story lives in /Progress folder const Busy = ({ className, children, ...rest }) => { - return ; + return ; }; Busy.propTypes = { diff --git a/src/Button/index.js b/src/Button/index.js index 957ad4c..df103e1 100644 --- a/src/Button/index.js +++ b/src/Button/index.js @@ -1,6 +1,7 @@ import React from 'react'; import PropTypes from 'prop-types'; import Icon from '../Icon'; +import Busy from '../Busy'; function cssFor(modifier) { return { @@ -34,7 +35,7 @@ class Button extends React.Component { ); } diff --git a/src/Button/stories.js b/src/Button/stories.js index 3a6d9c9..e5bf8ce 100644 --- a/src/Button/stories.js +++ b/src/Button/stories.js @@ -10,24 +10,25 @@ addParameters({ }); const SIZES = { - small: 'Small', - '': 'Medium', - large: 'Large', + small: 'small', + medium: 'medium', + large: 'large', }; + const VARIANTS = { - primary: 'Primary', - '': 'Secondary', - tertiary: 'Tertiary', + primary: 'primary', + secondary: 'secondary', + tertiary: 'tertiary', }; storiesOf('Button', module) .addDecorator(centered) .add('Sizes', () => { - const size = select('size', SIZES, ''); + const size = select('size', SIZES, 'medium'); return ; }) .add('Variants', () => { - const variant = select('variant', VARIANTS, ''); + const variant = select('variant', VARIANTS, 'primary'); return ; }) .add('Icon Only', () => { diff --git a/src/Checkbox/index.js b/src/Checkbox/index.js index 08706fb..cdada02 100644 --- a/src/Checkbox/index.js +++ b/src/Checkbox/index.js @@ -1,22 +1,27 @@ import PropTypes from 'prop-types'; import React, { useRef, useEffect } from 'react'; +import useCombinedRefs from '../hooks/useCombinedRefs'; -const Checkbox = ({ id, label, indeterminate, className, style, ...rest }) => { - const inputRef = useRef(); - useEffect(() => { - inputRef.current.indeterminate = indeterminate; - }, [indeterminate]); +const Checkbox = React.forwardRef( + ({ id, label, indeterminate, className, style, ...rest }, ref) => { + const hxRef = useCombinedRefs(ref, useRef()); + useEffect(() => { + hxRef.current.indeterminate = indeterminate; + }, [indeterminate]); - return ( - - - - - ); -}; + return ( + + + + + ); + } +); + +Checkbox.displayName = 'Checkbox'; Checkbox.propTypes = { className: PropTypes.string, diff --git a/src/ChoiceTile/index.js b/src/ChoiceTile/index.js index 8807a00..2fc5c16 100644 --- a/src/ChoiceTile/index.js +++ b/src/ChoiceTile/index.js @@ -18,19 +18,24 @@ const ChoiceTile = ({ subdued, title, style, + radioInput, ...rest }) => { return (