import './label.scss';
import {createElement} from "../../_global/scripts/helpers";

export const createLabel = ({
  text = 'Benutzername',
  forAttribute = 'name',
  isRequired = false,
  isHidden = false,
}) => {
  const label = createElement('label', isHidden ? ['visually-hidden'] : [], text);
  label.htmlFor = forAttribute;
  if (isRequired) {
    const asterix = createElement('sup', [], '*', label);
    asterix.title = 'Pflichtfeld';
  }

  return label;
}