Skip to content

Instantly share code, notes, and snippets.

@mpaccione
Created August 9, 2021 19:12
Show Gist options
  • Save mpaccione/2dd87eae8662405491706f4138815314 to your computer and use it in GitHub Desktop.
Save mpaccione/2dd87eae8662405491706f4138815314 to your computer and use it in GitHub Desktop.
import React from "react";
import { Button as SemanticButton } from "semantic-ui-react";
import styled from "styled-components";
const BaseButton = styled(SemanticButton)`
color: white !important;
font-family: Rubik, sans-serif !important;
font-weight: 800 !important;
&.disabled {
cursor: not-allowed !important;
opacity: 0.5 !important;
}
`;
const PrimaryButton = styled(BaseButton)`
background-color: ${(props) => props.theme.accent1};
`;
const SecondaryButton = styled(BaseButton)`
background-color: ${(props) => props.theme.primary1};
`;
const Button = ({
children = "Button",
onClick = false,
primary = false,
secondary = false,
disabled = false
}) => {
return (
<>
{primary && (
<PrimaryButton
onClick={() => {
onClick && onClick();
}}
className={disabled && "disabled"}
disabled={disabled}
>
{children}
</PrimaryButton>
)}
{secondary && (
<SecondaryButton
onClick={() => {
onClick && onClick();
}}
className={disabled && "disabled"}
disabled={disabled}
>
{children}
</SecondaryButton>
)}
{!primary && !secondary && (
<SemanticButton
onClick={() => {
onClick && onClick();
}}
className={disabled && "disabled"}
disabled={disabled}
>
{children}
</SemanticButton>
)}
</>
);
};
export default Button;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment