diff --git a/.eslintrc.js b/.eslintrc.js
index 82e9e31..69a6be6 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -8,7 +8,13 @@ module.exports = {
],
rules: {
'import/no-unresolved': [2, { ignore: ['minerva-ui', '@docusaurus', '@theme'] }],
- "import/no-unused-modules": 0,
+ 'import/no-unused-modules': 0,
+ // "import/no-unused-modules": [
+ // 1,
+ // {
+ // "unusedExports": true,
+ // }
+ // ],
'react/display-name': 1,
'react/react-in-jsx-scope': 0,
},
diff --git a/src/Button/Button.stories.tsx b/src/Button/Button.stories.tsx
index f82398c..ab5e334 100644
--- a/src/Button/Button.stories.tsx
+++ b/src/Button/Button.stories.tsx
@@ -37,6 +37,13 @@ export const Variants = () => (
);
+export const Sizes = () => (
+
+
+
+
+);
+
export const LoadingButton = Template.bind({});
LoadingButton.args = {
children: 'Basic Button',
diff --git a/src/Button/index.tsx b/src/Button/index.tsx
index e8d3568..70f56e5 100644
--- a/src/Button/index.tsx
+++ b/src/Button/index.tsx
@@ -35,7 +35,9 @@ export const buttonVariants = {
},
};
-export interface ButtonProps extends MinervaProps, PseudoBoxProps {
+export interface ButtonProps
+ extends Omit,
+ Omit {
children?: React.ReactNode;
/** Toggles disabled pseudo class */
disabled?: boolean;
@@ -45,35 +47,38 @@ export interface ButtonProps extends MinervaProps, PseudoBoxProps {
name?: string;
/** Button variant styles inherited from theme */
variant?: string;
+ /** Size variants defined using Styled System variants (https://styled-system.com/variants) */
+ size?: any;
/** HTML Button Type (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) */
type?: 'button' | 'reset' | 'submit';
}
-// export const Button = forwardRefWithAs(function Button(
-// {
-// children,
-// disabled = false,
-// as: Comp = 'button',
-// isLoading = false,
-// name,
-// variant,
-// ...props
-// },
-// forwardedRef
-// ) {
+export function useVariant(componentName: string, variant?: string) {
+ const theme = useTheme();
+
+ const componentVariants = theme?.variants?.[componentName];
+
+ const variantExistsInTheme =
+ variant &&
+ componentVariants &&
+ Object.keys(componentVariants).includes(variant);
+
+ // if a variant is provided and it doesn't exist in the current theme, warn in development
+ warning(
+ !variant || variantExistsInTheme,
+ `Variant "${variant}" not found in theme variants for :\n\n${theme
+ ?.variants?.Button &&
+ `Expected one of:\n[${Object.keys(theme.variants.Button).join(', ')}]`}`
+ );
+
+ const variantStyles =
+ variant && theme?.variants?.[componentName]
+ ? theme.variants[componentName][variant]
+ : {};
+
+ return variantStyles;
+}
-// export const Button = forwardRef(function Button(
-// {
-// children,
-// disabled = false,
-// as: Comp = 'button',
-// isLoading = false,
-// name,
-// variant,
-// ...props
-// }: ButtonProps,
-// forwardedRef
-// ) {
export const Button = forwardRefWithAs(function Button(
{
children,
@@ -86,29 +91,14 @@ export const Button = forwardRefWithAs(function Button(
},
forwardedRef
) {
- const theme = useTheme();
-
- // if a variant is provided and it doesn't exist in the current theme, warn in development
- warning(
- !variant ||
- (variant &&
- theme?.variants?.Button &&
- Object.keys(theme?.variants?.Button).includes(variant)),
- `Variant "${variant}" not found in theme variants for :\n\n${theme
- ?.variants?.Button &&
- `Expected one of:\n[${Object.keys(theme.variants.Button).join(', ')}]`}`
- );
+ const componentStyles = useComponentStyles('Button');
+ const variantStyles = useVariant('Button', variant);
warning(
children || (!children && name),
'Buttons without children require a `name` attribute to be accessible.'
);
- const variantStyles =
- variant && theme?.variants?.Button ? theme.variants.Button[variant] : {};
-
- const componentStyles = useComponentStyles('Button');
-
return (
(
diff --git a/src/theme.ts b/src/theme.ts
index 677ab7d..b699ec4 100644
--- a/src/theme.ts
+++ b/src/theme.ts
@@ -80,10 +80,10 @@ const defaultTheme: MinervaTheme = {
fontSize: '14px',
_hover: { backgroundColor: 'red' },
lineHeight: '20px',
- paddingTop: '8px',
- paddingBottom: '8px',
- paddingLeft: '16px',
- paddingRight: '16px',
+ paddingTop: '16px',
+ paddingBottom: '16px',
+ paddingLeft: '60px',
+ paddingRight: '60px',
borderRadius: '5px',
borderStyle: 'solid',
borderColor: '#d2d6dc',