Skip to content

Instantly share code, notes, and snippets.

@PierreAndreis
Created August 17, 2020 17:59
Show Gist options
  • Save PierreAndreis/e6fa613bf584040d9aca601129382695 to your computer and use it in GitHub Desktop.
Save PierreAndreis/e6fa613bf584040d9aca601129382695 to your computer and use it in GitHub Desktop.
import theme from '@chakra-ui/theme';
import { mode } from '@chakra-ui/theme-tools';
const defaultButton = theme.components.Button;
type Dict = Record<string, any>;
function variantSolid(props: Dict) {
const { colorScheme: c } = props;
const defaultVariantTheme = defaultButton.variants?.solid(props) ?? {};
if (c === 'gray') return defaultVariantTheme;
return {
...defaultVariantTheme,
bg: mode(`${c}.500`, `${c}.500`)(props),
color: mode(`white`, `white`)(props),
_hover: { bg: mode(`${c}.600`, `${c}.600`)(props) },
_active: { bg: mode(`${c}.700`, `${c}.400`)(props) },
};
}
const variants = {
...defaultButton.variants,
solid: variantSolid,
};
const button = {
...defaultButton,
variants,
};
export default button;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment