Skip to content

Instantly share code, notes, and snippets.

@diasjuniorr
Created July 2, 2022 14:19
Show Gist options
  • Save diasjuniorr/71bd7287fe24f8113be5a9490e9887de to your computer and use it in GitHub Desktop.
Save diasjuniorr/71bd7287fe24f8113be5a9490e9887de to your computer and use it in GitHub Desktop.
import { ButtonHTMLAttributes, DetailedHTMLProps } from "react";
import {
ButtonDefault,
ButtonGoogleSignin,
ButtonInverted,
} from "./button.styles";
export const ButtonClasses = {
default: ButtonDefault,
googleSignin: ButtonGoogleSignin,
inverted: ButtonInverted,
};
type ObjectKey = keyof typeof ButtonClasses;
const getCustomButton = (type: ObjectKey = "default") => {
return ButtonClasses[type];
};
const Button: React.FC<
DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
> = ({ children, className, ...props }) => {
const CustomButton = getCustomButton(className as ObjectKey);
return <ButtonDefault {...props}>{children}</ButtonDefault>;
};
export default Button;
import { ButtonHTMLAttributes, DetailedHTMLProps } from "react";
import styled from "styled-components";
export const ButtonDefault = styled.button<
DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>
>`
min-width: 165px;
width: auto;
height: 50px;
letter-spacing: 0.5px;
line-height: 50px;
padding: 0 35px 0 35px;
font-size: 15px;
background-color: black;
color: white;
text-transform: uppercase;
font-family: "Open Sans";
font-weight: bolder;
border: none;
cursor: pointer;
display: flex;
justify-content: center;
&:hover {
background-color: white;
color: black;
border: 1px solid black;
}
`;
export const ButtonGoogleSignin = styled(ButtonDefault)`
background-color: #4285f4;
color: white;
&:hover {
background-color: #357ae8;
border: none;
}
`;
export const ButtonInverted = styled(ButtonDefault)`
background-color: white;
color: black;
border: 1px solid black;
&:hover {
background-color: black;
color: white;
border: none;
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment