packages/travix-ui-kit/components/button/button.js
function Button(props) {
  warnAboutDeprecatedProp(props.mods, 'mods', 'className');

  const {
    children,
    className,
    dataAttrs = {},
    disabled,
    href,
    id,
    onClick,
    onMouseUp,
    size,
    type,
    variation,
  } = props;
  const restProps = getDataAttributes(dataAttrs);
  const mods = props.mods ? props.mods.slice() : [];

  /** This props have default values */
  mods.push(`size_${size}`);
  mods.push(`variation_${variation}`);

  if (disabled) {
    mods.push(`disabled_true`);
  }

  const classes = classnames(
    getClassNamesWithMods('ui-button', mods),
    className
  );

  if (type === 'link') {
    if (!href) {
      console.warn('Missing href'); // eslint-disable-line no-console
      return null;
    }

    return (
      <a
        {...restProps}
        className={classes}
        href={href}
        id={id}
        onMouseUp={onMouseUp}
      >
        {children}
      </a>
    );
  }

  if (type === 'submit' || type === 'reset') {
    return (
      <button
        {...restProps}
        className={classes}
        disabled={disabled}
        id={id}
        onMouseUp={onMouseUp}
        type={type}
      >
        {children}
      </button>
    );
  }

  return (
    <button
      {...restProps}
      className={classes}
      disabled={disabled}
      id={id}
      onClick={onClick}
      onMouseUp={onMouseUp}
      type="button"
    >
      {children}
    </button>
  );
}
function Button(props) {
  warnAboutDeprecatedProp(props.mods, 'mods', 'className');

  const {
    children,
    className,
    dataAttrs = {},
    disabled,
    href,
    id,
    onClick,
    onMouseUp,
    size,
    type,
    variation,
  } = props;
  const restProps = getDataAttributes(dataAttrs);
  const mods = props.mods ? props.mods.slice() : [];

  /** This props have default values */
  mods.push(`size_${size}`);
  mods.push(`variation_${variation}`);

  if (disabled) {
    mods.push(`disabled_true`);
  }

  const classes = classnames(
    getClassNamesWithMods('ui-button', mods),
    className
  );

  if (type === 'link') {
    if (!href) {
      console.warn('Missing href'); // eslint-disable-line no-console
      return null;
    }

    return (
      <a
        {...restProps}
        className={classes}
        href={href}
        id={id}
        onMouseUp={onMouseUp}
      >
        {children}
      </a>
    );
  }

  if (type === 'submit' || type === 'reset') {
    return (
      <button
        {...restProps}
        className={classes}
        disabled={disabled}
        id={id}
        onMouseUp={onMouseUp}
        type={type}
      >
        {children}
      </button>
    );
  }

  return (
    <button
      {...restProps}
      className={classes}
      disabled={disabled}
      id={id}
      onClick={onClick}
      onMouseUp={onMouseUp}
      type="button"
    >
      {children}
    </button>
  );
}
function Button ( props ) { warnAboutDeprecatedProp ( props . mods , 'mods' , 'className' ) ; const { children , className , dataAttrs = { } , disabled , href , id , onClick , onMouseUp , size , type , variation , } = props ; const restProps = getDataAttributes ( dataAttrs ) ; const mods = props . mods ? props . mods . slice ( ) : [ ] ; /** This props have default values */ mods . push ( ` ${ size } ` ) ; mods . push ( ` ${ variation } ` ) ; if ( disabled ) { mods . push ( ` ` ) ; } const classes = classnames ( getClassNamesWithMods ( 'ui-button' , mods ) , className ) ; if ( type === 'link' ) { if ( ! href ) { console . warn ( 'Missing href' ) ; // eslint-disable-line no-console return null ; } return ( < a { ... restProps } className = { classes } href = { href } id = { id } onMouseUp = { onMouseUp } > { children } < / a > ) ; } if ( type === 'submit' || type === 'reset' ) { return ( < button { ... restProps } className = { classes } disabled = { disabled } id = { id } onMouseUp = { onMouseUp } type = { type } > { children } < / button > ) ; } return ( < button { ... restProps } className = { classes } disabled = { disabled } id = { id } onClick = { onClick } onMouseUp = { onMouseUp } type = "button" > { children } < / button > ) ; }
General Button component. Use when you need button or a link that looks like button
General Button component . Use when you need button or a link that looks like button