feat(component): add Button

This commit is contained in:
Ash Monty 2022-11-27 12:28:23 +01:00
parent bc6ed9ee3e
commit 97e47b20cd
No known key found for this signature in database
GPG Key ID: 740B7C88251D49B6
2 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,24 @@
import classNames from 'classnames';
import styles from './Button.module.css';
/**
* A reusable component for buttons.
*
* @param {boolean} isPrimary - Whether the button is primary or not. Defaults to false.
* @param className - An optional classname.
* @param {string} style - Custom styles to apply to the title.
*
* @example
* <Button isPrimary={true} onClick={(e) => alert(e.target.textContent)}>Pizza</Title>
*
*/
export default function Button(ctx) {
const { children, className, isPrimary, onClick } = ctx;
return (
<button className={classNames(styles.button, { [styles.primary]: isPrimary }, className)} onClick={onClick}>
{children}
</button>
);
}

View File

@ -0,0 +1,23 @@
.button {
appearance: none;
background: var(--bg-shade-3);
color: var(--text-shade-3);
border: 0;
border-radius: 6px;
padding: 12px 48px;
font-size: 1rem;
font-family: var(--font-family);
cursor: pointer;
}
.button:hover {
background: var(--bg-shade-3-5);
}
.button.primary {
background: var(--accent-shade-0);
}
.button.primary:hover {
background: var(--accent-shade-1);
}