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