-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(button): add example button variants with tailwind
- Loading branch information
Showing
5 changed files
with
66 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,27 @@ | ||
import * as React from "react"; | ||
|
||
function Button( | ||
props: React.DetailedHTMLProps< | ||
React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
HTMLButtonElement | ||
> | ||
): JSX.Element { | ||
const { className = "", ...rest } = props; | ||
return <button className={`czedi-btn ${className}`} {...rest}></button>; | ||
import cx from "classnames"; | ||
|
||
// Temporary props for button to test out css options for variants | ||
type ButtonProps = React.DetailedHTMLProps< | ||
React.ButtonHTMLAttributes<HTMLButtonElement>, | ||
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 className={classNames} {...rest}></button>; | ||
} | ||
|
||
Button.defaultProps = { | ||
variant: "primary", | ||
}; | ||
|
||
export default Button; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |