diff --git a/packages/components/package.json b/packages/components/package.json index 8e64a9eb1..25da3c8b3 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -39,7 +39,8 @@ }, "dependencies": { "@chanzuckerberg/czedi-kit-styles": "^0.0.0", - "@chanzuckerberg/czedi-kit-tokens": "^0.0.0" + "@chanzuckerberg/czedi-kit-tokens": "^0.0.0", + "classnames": "^2.2.6" }, "devDependencies": { "@babel/core": "^7.6.4", diff --git a/packages/components/src/button/button.spec.tsx b/packages/components/src/button/button.spec.tsx index efe92f00c..b52777d6b 100644 --- a/packages/components/src/button/button.spec.tsx +++ b/packages/components/src/button/button.spec.tsx @@ -1,21 +1,28 @@ import { axe } from "jest-axe"; import { render } from "@testing-library/react"; -import { text } from "./button.stories"; +import { variants } from "./button.stories"; describe(" +
+ + +
`); }); it("passes accessibility checks", async () => { - const { container } = render(text()); + const { container } = render(variants()); const results = await axe(container); expect(results).toHaveNoViolations(); }); diff --git a/packages/components/src/button/button.stories.tsx b/packages/components/src/button/button.stories.tsx index 18eebc378..fc1c05d15 100644 --- a/packages/components/src/button/button.stories.tsx +++ b/packages/components/src/button/button.stories.tsx @@ -12,6 +12,17 @@ export const text = (): JSX.Element => ( ); +export const variants = (): JSX.Element => ( +
+ + +
+); + export const emoji = (): JSX.Element => ( ; +import cx from "classnames"; + +// Temporary props for button to test out css options for variants +type ButtonProps = React.DetailedHTMLProps< + React.ButtonHTMLAttributes, + HTMLButtonElement +> & { + variant: "primary" | "secondary"; +}; + +function Button(props: ButtonProps): JSX.Element { + const { className = "", variant, ...rest } = props; + const classNames = cx("czedi-btn", className, { + "czedi-btn-primary": variant === "primary", + "czedi-btn-secondary": variant === "secondary", + }); + + return ; } +Button.defaultProps = { + variant: "primary", +}; + export default Button; diff --git a/packages/styles/src/button/button.scss b/packages/styles/src/button/button.scss index 0b536e60a..0b25f9ed0 100644 --- a/packages/styles/src/button/button.scss +++ b/packages/styles/src/button/button.scss @@ -1,10 +1,20 @@ -@import "./_variables.scss"; -@import "@chanzuckerberg/czedi-kit-tokens/scss/_variables.scss"; - .btn { - @apply font-bold py-2 px-4 rounded bg-blue-500 text-white; + @apply font-bold py-2 px-4 rounded text-white; } -.btn:hover { - @apply bg-blue-700; +.btn, +.btn-primary { + @apply bg-blue-300; + + &:hover { + @apply bg-blue-400; + } +} + +.btn-secondary { + @apply bg-gray-600; + + &:hover { + @apply bg-gray-800; + } }