Add defaultLabel for Labelled (#40)

* Add defaultLabel

* Typing for defaultLabel

* Add null for label prop

* Try to fix (in the dark)

* Allow anything for label
This commit is contained in:
Jaco Greeff 2018-05-12 10:29:54 +02:00 committed by GitHub
parent a4a83f9795
commit 1489a1c4e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,21 +9,22 @@ import React from 'react';
import Label from 'semantic-ui-react/dist/es/elements/Label';
type Props = BareProps & {
label?: React$Node,
// flowlint-next-line unclear-type:off
label?: any,
children: React$Node
};
export default function Labelled ({ className, children, label, style }: Props): React$Node {
const defaultLabel: React$Node = (
<div>&nbsp;</div>
);
export default function Labelled ({ className, children, label = defaultLabel, style }: Props): React$Node {
return (
<div
className={className}
style={style}
>
<Label>{
typeof label === 'undefined'
? <div>&nbsp;</div>
: label
}</Label>
<Label>{label}</Label>
{children}
</div>
);