1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/frontend/src/component/context/ContectFormChip/ContextFormChip.tsx
olav cb8add5c30 feat: add context value descriptions (#874)
* feat: add context value descriptions

* refcator: use ConditionallyRender for ...conditional render

* refactor: fix context form enter behaviour

* refactor: decrease margin between inputs

* refactor: show error on missing value

* refactor: disable add button on error

* refactor: avoid clearing value error on name focus
2022-04-19 15:20:01 +02:00

35 lines
1010 B
TypeScript

import { useStyles } from 'component/context/ContectFormChip/ContextFormChip.styles';
import { Cancel } from '@material-ui/icons';
import ConditionallyRender from 'component/common/ConditionallyRender';
interface IContextFormChipProps {
label: string;
description?: string;
onRemove: () => void;
}
export const ContextFormChip = ({
label,
description,
onRemove,
}: IContextFormChipProps) => {
const styles = useStyles();
return (
<li className={styles.container}>
<div>
<div className={styles.label}>{label}</div>
<ConditionallyRender
condition={Boolean(description)}
show={() => (
<div className={styles.description}>{description}</div>
)}
/>
</div>
<button onClick={onRemove} className={styles.button}>
<Cancel titleAccess="Remove" />
</button>
</li>
);
};