-
Notifications
You must be signed in to change notification settings - Fork 0
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
25 button component #32
Open
nhistory
wants to merge
16
commits into
main
Choose a base branch
from
25-button-component
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d9a58b0
Started button component and storybook
nhistory b5110cf
Merge branch '29-heading' into 25-button-component
nhistory 934a153
Made Button stories and update semantic colors for improved accessibi…
nhistory 87e77f6
Merge branch 'main' into 25-button-component
nhistory 5aca818
Refactor Button component styles for improved color semantics and acc…
nhistory b7b77c0
Merge branch 'main' into 25-button-component
nhistory 2a5b378
feat: enhance Button component with tone and variant options
nhistory 37cd145
feat: update Button component to remove primary tone and enhance colo…
nhistory ea04e01
Fixed Button component with size and disabled properties, and update …
nhistory 66f81d9
Updated Button component in App to use 'solid' variant
nhistory 5324976
deps: update bun
DaleSeo 416cdff
deps: update vite, vitest, react, panda, storybook
DaleSeo 7ab7c7b
deps: install lucide-react vite-plugin-svgr
DaleSeo fa0c5fb
feat: add icon tokens
DaleSeo 8c98494
feat: implement icon component
DaleSeo 5b6da92
Merge branch 'main' into 25-button-component
nhistory File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,24 @@ | ||
import { css } from "../../../styled-system/css"; | ||
import React from "react"; | ||
import { css, cva } from "../../../styled-system/css"; | ||
import type { SystemStyleObject } from "@pandacss/types"; | ||
// import { colors } from "../../tokens/colors"; | ||
|
||
type ButtonVariant = | ||
| "solid" | ||
| "outline" | ||
| "outline-gradient" | ||
| "default" | ||
| "accent" | ||
| "danger" | ||
| "warning"; | ||
|
||
export interface ButtonProps { | ||
/** 버튼 텍스트 */ | ||
children: React.ReactNode; | ||
type?: "button" | "submit"; | ||
onClick?: () => void; | ||
variant?: ButtonVariant; | ||
style?: SystemStyleObject; // Add style prop for custom inline styles | ||
} | ||
|
||
/** | ||
|
@@ -14,37 +28,17 @@ export const Button = ({ | |
children, | ||
type = "button", | ||
onClick, | ||
variant = "default", | ||
style, // destructure the style prop | ||
...rest | ||
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. 요거는 자치샇면 일관성을 해칠 수 있는 독이 될 수도 있을 것 같은데, 우선은 제외하시는 게 어떠실까요? |
||
}: ButtonProps) => { | ||
return ( | ||
<button | ||
className={css({ | ||
"--button-color": "#ffffff", | ||
"--button-bg-color": "#0d6efd", | ||
"--button-hover-bg-color": "#025ce2", | ||
appearance: "none", | ||
margin: "0", | ||
padding: "0.5rem 1rem", | ||
background: "var(--button-bg-color)", | ||
color: "var(--button-color)", | ||
fontSize: "1rem", | ||
fontWeight: 400, | ||
textAlign: "center", | ||
textDecoration: "none", | ||
display: "inline-block", | ||
width: ["auto", "100%"], | ||
border: "none", | ||
borderRadius: "4px", | ||
boxShadow: | ||
"0 4px 6px -1px rgba(0, 0, 0, 0.1),\n 0 2px 4px -1px rgba(0, 0, 0, 0.06)", | ||
cursor: "pointer", | ||
transition: "0.5s", | ||
"&:active, &:hover, &:focus": { | ||
background: "var(--button-hover-bg-color)", | ||
outline: "0", | ||
}, | ||
"&:disabled": { opacity: 0.5 }, | ||
})} | ||
className={css( | ||
styles.raw({ variant }), | ||
baseStyles, | ||
...(Array.isArray(style) ? style : [style]) // Ensure style is an array | ||
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. 옷, |
||
)} | ||
type={type} | ||
onClick={onClick} | ||
{...rest} | ||
|
@@ -53,3 +47,111 @@ export const Button = ({ | |
</button> | ||
); | ||
}; | ||
|
||
const baseStyles = { | ||
appearance: "none", | ||
margin: "0", | ||
padding: "0.7rem 3rem", | ||
fontSize: "1.5rem", | ||
fontWeight: 500, | ||
textAlign: "center", | ||
textDecoration: "none", | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
width: ["auto", "100%"], | ||
borderRadius: "10px", | ||
cursor: "pointer", | ||
transition: "0.2s", | ||
lineHeight: "1", | ||
outline: "0", | ||
"&:focus": { | ||
outlineColor: { base: "{colors.violet.10}", _dark: "{colors.violet.7}" }, | ||
outline: "3px solid", | ||
outlineOffset: "2px", | ||
}, | ||
"&:disabled": { opacity: 0.5 }, | ||
}; | ||
|
||
const styles = cva({ | ||
variants: { | ||
variant: { | ||
default: { | ||
background: "bg", | ||
color: "text", | ||
"&:active, &:hover": { | ||
background: "bg.hover", | ||
}, | ||
}, | ||
accent: { | ||
background: "bg.accent", | ||
color: "text.accent", | ||
"&:active, &:hover": { | ||
background: "bg.hover.accent", | ||
}, | ||
}, | ||
danger: { | ||
background: "bg.danger", | ||
color: "text.danger", | ||
"&:active, &:hover": { | ||
background: "bg.hover.danger", | ||
}, | ||
}, | ||
warning: { | ||
background: "bg.warning", | ||
color: "text.warning", | ||
"&:active, &:hover": { | ||
background: "bg.hover.warning", | ||
}, | ||
}, | ||
solid: { | ||
background: { base: "{colors.violet.9}", _dark: "{colors.violet.9}" }, | ||
color: { base: "{colors.violet.1}", _dark: "{colors.violet.1}" }, | ||
"&:active, &:hover": { | ||
background: { | ||
base: "{colors.violet.8}", | ||
_dark: "{colors.violetDark.10}", | ||
}, | ||
}, | ||
}, | ||
outline: { | ||
background: { | ||
base: "{colors.violet.2}", | ||
_dark: "{colors.violetDark.8}", | ||
}, | ||
color: { | ||
base: "{colors.violetDark.1}", | ||
_dark: "{colors.violet.1}", | ||
}, | ||
border: "4px solid", | ||
borderColor: { | ||
base: "{colors.violetDark.10}", | ||
_dark: "{colors.violet.7}", | ||
}, | ||
"&:active, &:hover": { | ||
background: { | ||
base: "{colors.violet.4}", | ||
_dark: "{colors.violetDark.10}", | ||
}, | ||
}, | ||
}, | ||
"outline-gradient": { | ||
"--gradient-color": | ||
"linear-gradient(90deg,{colors.teal.9},{colors.violet.10})", | ||
background: "transparent", | ||
color: { | ||
base: "{colors.violetDark.1}", | ||
_dark: "{colors.violet.1}", | ||
}, | ||
border: "4px solid transparent", | ||
borderRadius: "10px", | ||
backgroundClip: "padding-box, border-box", | ||
backgroundOrigin: "padding-box, border-box", | ||
borderImage: "var(--gradient-color)", | ||
borderImageSlice: "1", | ||
borderImageOutset: "0", | ||
"&:active, &:hover": {}, | ||
}, | ||
}, | ||
}, | ||
}); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
단일 속성으로 너무 다양한 종류의 버튼을 �표현하려고 하면 나중에 속성값의 개수가 폭발적으로 증가할 수 있으며 속성값의 이름을 짓는 것도 골치거리가 될 수 있습니다. 다음과 같이 두 개의 속성으로 분리하는 것을 제안드리고 싶습니다.