ghost-portal/packages/ui-app/src/Labelled.js
Jaco Greeff 1489a1c4e6
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
2018-05-12 10:29:54 +02:00

32 lines
716 B
JavaScript

// Copyright 2017-2018 Jaco Greeff
// This software may be modified and distributed under the terms
// of the ISC license. See the LICENSE file for details.
// @flow
import type { BareProps } from './types';
import React from 'react';
import Label from 'semantic-ui-react/dist/es/elements/Label';
type Props = BareProps & {
// flowlint-next-line unclear-type:off
label?: any,
children: 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>{label}</Label>
{children}
</div>
);
}