-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[UI lib] Button, Link & ButtonLink components #7438
Changes from 13 commits
d72276d
e82c63d
d40a004
80ef4d0
ed06eb8
e3f03e2
89dd33f
032a1bc
321e53d
bb06888
72b33f5
416ee6a
08bf701
4a473d2
c23aa97
575f4f2
8f8ae9b
963a128
11176a0
fbfe7a6
9fb65ff
bffac7b
017479c
921889c
7911694
0c96ebb
07ccf07
e81291e
da1e20c
0d718ea
9365546
23d6bf1
8102b6e
32b69e4
6008fbe
5a40de1
3372f93
d1855b4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import type { ComponentStyleConfig } from "@chakra-ui/theme" | ||
|
||
export const Button: ComponentStyleConfig = { | ||
baseStyle: { | ||
fontWeight: "normal", | ||
borderRadius: "base", | ||
_hover: { | ||
textDecoration: "none", | ||
boxShadow: "primary", | ||
}, | ||
}, | ||
sizes: { | ||
md: { | ||
h: 42, | ||
}, | ||
}, | ||
variants: { | ||
// solid is the default variant used by chakra | ||
solid: { | ||
color: "buttonColor", | ||
bg: "primary", | ||
border: 0, | ||
_hover: { | ||
bg: "primary", | ||
opacity: 0.8, | ||
}, | ||
_active: { | ||
bg: "primaryActive", | ||
}, | ||
}, | ||
outline: { | ||
color: "text", | ||
bg: "transparent", | ||
borderColor: "text", | ||
_hover: { | ||
color: "primary", | ||
bg: "transparent", | ||
border: "1px", | ||
borderColor: "primary", | ||
}, | ||
_active: { | ||
bg: "secondaryButtonBackgroundActive", | ||
}, | ||
}, | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { ComponentStyleConfig } from "@chakra-ui/theme" | ||
|
||
export const Link: ComponentStyleConfig = { | ||
baseStyle: { | ||
color: "primary", | ||
textDecoration: "underline", | ||
}, | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./Link" | ||
export * from "./Button" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
import colors from "./colors" | ||
import shadows from "./shadows" | ||
|
||
const foundations = { | ||
// breakpoints, | ||
// zIndices, | ||
// radii, | ||
// blur, | ||
colors, | ||
// ...typography, | ||
// sizes, | ||
shadows, | ||
// space: spacing, | ||
// borders, | ||
// transition, | ||
} | ||
|
||
export default foundations |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const shadows = { | ||
// using css variables bc shadows do not support color tokens yet | ||
primary: `4px 4px 0px 0px var(--eth-colors-primaryLight)`, | ||
} | ||
|
||
export default shadows |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from "react" | ||
import { Button as ChakraButton, ButtonProps } from "@chakra-ui/react" | ||
|
||
import { scrollIntoView } from "../utils/scrollIntoView" | ||
|
||
export interface IProps extends ButtonProps { | ||
toId?: string | ||
} | ||
|
||
const Button: React.FC<IProps> = ({ toId, children, ...props }) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm calling this component import Button from 'components/Button' On the other hand, we could break them out by calling this component import ButtonScroll from 'components/ButtonScroll'
// for the rest, we use the native chakra button
import Button from 'chakra/Button' I just wanted to check if you have a preference. |
||
const handleOnClick = () => { | ||
if (!toId) { | ||
return | ||
} | ||
|
||
scrollIntoView(toId) | ||
} | ||
|
||
return ( | ||
<ChakraButton onClick={handleOnClick} {...props}> | ||
{children} | ||
</ChakraButton> | ||
) | ||
} | ||
|
||
export default Button |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have enabled the reset from Chakra. It does seem to be working fine so far. I haven't seen any conflict yet.