import {
  forwardRef,
  ForwardRefRenderFunction,
  MouseEventHandler,
  ReactNode,
} from 'react';
import styles from './buttons.module.scss';

export type ButtonProps = {
  /**
   * Button accessible label.
   */
  'aria-label'?: string;
  /**
   * Indicates the current "pressed" state of a toggle button.
   */
  'aria-pressed'?: boolean | 'mixed';
  /**
   * The button body.
   */
  children: ReactNode;
  /**
   * Set additional classnames to the button wrapper.
   */
  className?: string;
  /**
   * Button state. Default: false.
   */
  disabled?: boolean;
  /**
   * Button kind. Default: secondary.
   */
  kind?: 'primary' | 'secondary' | 'tertiary' | 'neutral';
  /**
   * A callback function to handle click.
   */
  onClick?: MouseEventHandler<HTMLButtonElement>;
  /**
   * Button shape. Default: rectangle.
   */
  shape?: 'circle' | 'rectangle' | 'square' | 'initial';
  /**
   * Button type attribute. Default: button.
   */
  type?: 'button' | 'reset' | 'submit';
};

/**
 * Button component
 *
 * Use a button as call to action.
 */
const Button: ForwardRefRenderFunction<HTMLButtonElement, ButtonProps> = (
  {
    className = '',
    children,
    disabled = false,
    kind = 'secondary',
    shape = 'rectangle',
    type = 'button',
    ...props
  },
  ref
) => {
  const kindClass = styles[`btn--${kind}`];
  const shapeClass = styles[`btn--${shape}`];

  return (
    <button
      className={`${styles.btn} ${kindClass} ${shapeClass} ${className}`}
      disabled={disabled}
      ref={ref}
      type={type}
      {...props}
    >
      {children}
    </button>
  );
};

export default forwardRef(Button);
min.js?id=355625b5dd1b4e2e52e6e5d0eee1a13d76c09fda'>tree</a><a href='/www.armandphilippot.com/commit/public/prism/prism-git.min.js?id=355625b5dd1b4e2e52e6e5d0eee1a13d76c09fda'>commit</a><a href='/www.armandphilippot.com/diff/public/prism/prism-git.min.js?id=355625b5dd1b4e2e52e6e5d0eee1a13d76c09fda'>diff</a><a href='/www.armandphilippot.com/stats/public/prism/prism-git.min.js'>stats</a></td><td class='form'><form class='right' method='get' action='/www.armandphilippot.com/log/public/prism/prism-git.min.js'>
<input type='hidden' name='id' value='355625b5dd1b4e2e52e6e5d0eee1a13d76c09fda'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/www.armandphilippot.com/tree/?id=355625b5dd1b4e2e52e6e5d0eee1a13d76c09fda'>root</a>/<a href='/www.armandphilippot.com/tree/public?id=355625b5dd1b4e2e52e6e5d0eee1a13d76c09fda'>public</a>/<a href='/www.armandphilippot.com/tree/public/prism?id=355625b5dd1b4e2e52e6e5d0eee1a13d76c09fda'>prism</a>/<a href='/www.armandphilippot.com/tree/public/prism/prism-git.min.js?id=355625b5dd1b4e2e52e6e5d0eee1a13d76c09fda'>prism-git.min.js</a></div><div class='content'>blob: 502dd0ecd4b8fcc4072886708a8bb489d92699bb (<a href='/www.armandphilippot.com/plain/public/prism/prism-git.min.js?id=355625b5dd1b4e2e52e6e5d0eee1a13d76c09fda'>plain</a>)
<table summary='blob content' class='blob'>
<tr><td class='linenumbers'><pre><a id='n1' href='#n1'>1</a>
<a id='n2' href='#n2'>2</a>
<a id='n3' href='#n3'>3</a>
<a id='n4' href='#n4'>4</a>
<a id='n5' href='#n5'>5</a>
<a id='n6' href='#n6'>6</a>
<a id='n7' href='#n7'>7</a>
<a id='n8' href='#n8'>8</a>
<a id='n9' href='#n9'>9</a>
</pre></td>
<td class='lines'><pre><code>