Creating combo input with label, naming and input for Text, Select and DateRange (#1553)

* Issues: OHIF-46, OHIF-47, OHIF-48
This commit is contained in:
Gustavo André Lelis authored and James A. Petts committed 2020-05-15 13:42:28 +02:00
1 parent 3fe3634475
commit de484275e8
18 files changed
+646 -218

No files matched your search

@@ -0,0 +1,63 @@
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { Icon } from '@ohif/ui';
const baseLabelClassName =
'flex flex-col flex-1 text-white text-lg pl-1 select-none';
const spanClassName = 'flex flex-row items-center cursor-pointer';
const sortIconMap = {
ascending: 'sorting-active-up',
descending: 'sorting-active-down',
none: 'sorting',
};
const InputLabelWrapper = ({
label,
isSortable,
sortDirection,
onLabelClick,
className,
children,
}) => {
return (
<label className={classnames(baseLabelClassName, className)}>
<span
className={spanClassName}
onClick={onLabelClick}
onKeyDown={onLabelClick}
>
{label}
{isSortable && (
<Icon
name={sortIconMap[sortDirection]}
className={classnames(
'mx-2 w-2',
sortDirection !== 'none'
? 'text-custom-aquaBright'
: 'text-custom-blue'
)}
/>
)}
</span>
<span>{children}</span>
</label>
);
};
InputLabelWrapper.defaultProps = {
className: '',
};
InputLabelWrapper.propTypes = {
label: PropTypes.string.isRequired,
isSortable: PropTypes.bool.isRequired,
sortDirection: PropTypes.oneOf(['ascending', 'descending', 'none'])
.isRequired,
onLabelClick: PropTypes.func.isRequired,
className: PropTypes.string,
children: PropTypes.node,
};
export default InputLabelWrapper;
@@ -0,0 +1,2 @@
import InputLabelWrapper from './InputLabelWrapper';
export default InputLabelWrapper;