| 1 |
import { RichText } from '@wordpress/block-editor'; |
| 2 |
import { __ } from '@wordpress/i18n'; |
| 3 |
|
| 4 |
/** |
| 5 |
* Field Label Class. |
| 6 |
* |
| 7 |
* @param props |
| 8 |
*/ |
| 9 |
export default function FieldLabel(props) { |
| 10 |
const { attributes, setAttributes, isSelected } = props; |
| 11 |
|
| 12 |
const { label, hideLabel } = attributes; |
| 13 |
|
| 14 |
if (!label && !isSelected) { |
| 15 |
return null; |
| 16 |
} |
| 17 |
|
| 18 |
if (hideLabel && !isSelected) { |
| 19 |
return null; |
| 20 |
} |
| 21 |
|
| 22 |
return ( |
| 23 |
// eslint-disable-next-line jsx-a11y/label-has-associated-control |
| 24 |
<label className="ghostkit-form-field-label"> |
| 25 |
<RichText |
| 26 |
inlineToolbar |
| 27 |
tagName="span" |
| 28 |
value={label} |
| 29 |
placeholder={__('Write label…', 'ghostkit')} |
| 30 |
onChange={(val) => setAttributes({ label: val })} |
| 31 |
/> |
| 32 |
{attributes.required ? <span className="required">*</span> : ''} |
| 33 |
</label> |
| 34 |
); |
| 35 |
} |
| 36 |
|