-
Notifications
You must be signed in to change notification settings - Fork 3
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
[Feat/#53] Stepper 공통 컴포넌트 추가 #56
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { SVGProps } from "react"; | ||
const SvgIconMinus = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" {...props}> | ||
<path stroke="currentColor" strokeMiterlimit={10} strokeWidth={1.2} d="M17 12H7" /> | ||
</svg> | ||
); | ||
export default SvgIconMinus; |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import * as React from "react"; | ||
import type { SVGProps } from "react"; | ||
const SvgIconPlus = (props: SVGProps<SVGSVGElement>) => ( | ||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" {...props}> | ||
<path stroke="currentColor" strokeMiterlimit={10} strokeWidth={1.2} d="M12 7v10M17 12H7" /> | ||
</svg> | ||
); | ||
export default SvgIconPlus; |
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 +1,3 @@ | ||
export { default as IconMinus } from "./IconMinus"; | ||
export { default as IconPlus } from "./IconPlus"; | ||
export { default as IconTextfiedlDelete } from "./IconTextfiedlDelete"; |
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { Meta, StoryFn, StoryObj } from "@storybook/react"; | ||
import Stepper, { StepperProps } from "./Stepper"; | ||
import { useState } from "react"; | ||
|
||
const meta = { | ||
title: "Stepper", | ||
component: Stepper, | ||
parameters: { | ||
layout: "centered", | ||
}, | ||
argTypes: {}, | ||
args: { max: 3, round: 1 }, | ||
} satisfies Meta<typeof Stepper>; | ||
|
||
export default meta; | ||
type Story = StoryObj<StepperProps>; | ||
|
||
const Template: StoryFn<StepperProps> = (args) => { | ||
const [round, setRound] = useState(args.round); | ||
|
||
return <Stepper {...args} round={round} setRound={setRound} />; | ||
}; | ||
|
||
export const Default: Story = Template.bind({}); | ||
Default.args = {}; |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { Generators } from "@styles/generator"; | ||
import styled from "styled-components"; | ||
|
||
export const StepperWrapper = styled.div` | ||
${Generators.flexGenerator()}; | ||
gap: 0.6rem; | ||
width: 11.5rem; | ||
height: 4rem; | ||
padding: 0.8rem 1rem; | ||
|
||
background: ${({ theme }) => theme.colors.gray_900}; | ||
border: 1px solid ${({ theme }) => theme.colors.gray_700}; | ||
border-radius: 6px; | ||
`; | ||
|
||
export const StepperBtn = styled.button` | ||
${Generators.flexGenerator()}; | ||
width: 2.4rem; | ||
height: 2.4rem; | ||
|
||
color: ${({ theme }) => theme.colors.white}; | ||
|
||
cursor: pointer; | ||
|
||
&:disabled { | ||
color: ${({ theme }) => theme.colors.gray_500}; | ||
|
||
cursor: not-allowed; | ||
} | ||
`; | ||
|
||
export const StepperNum = styled.p` | ||
${Generators.flexGenerator()}; | ||
|
||
width: 3.5rem; | ||
height: 1.3rem; | ||
|
||
color: ${({ theme }) => theme.colors.white}; | ||
|
||
${({ theme }) => theme.fonts.heading4} | ||
`; |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import * as S from "./Stepper.styled"; | ||
import { IconMinus, IconPlus } from "@assets/svgs"; | ||
|
||
export interface StepperProps { | ||
max: number; | ||
round: number; | ||
setRound: (round: number) => void; | ||
} | ||
|
||
const Stepper = ({ round, max, setRound }: StepperProps) => { | ||
return ( | ||
<S.StepperWrapper> | ||
<S.StepperBtn | ||
disabled={round === 1} | ||
onClick={() => { | ||
setRound(round - 1); | ||
}} | ||
> | ||
<IconMinus /> | ||
</S.StepperBtn> | ||
<S.StepperNum>{round}</S.StepperNum> | ||
<S.StepperBtn | ||
disabled={max === round} | ||
onClick={() => { | ||
setRound(round + 1); | ||
}} | ||
> | ||
<IconPlus /> | ||
</S.StepperBtn> | ||
</S.StepperWrapper> | ||
); | ||
}; | ||
|
||
export default Stepper; |
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.
p3) setState 자체를 props로 넘기면 안된다? 와 관련해서 화랑이가 적은 아티클이 있어서 링크 남겨놓겠습니다!
props로 onMinusClick, onPlusClick 이렇게 넘기는 방식은 어떨까요!?
https://velog.io/@thisishwarang/React-setState-%EC%9E%90%EC%B2%B4%EB%A5%BC-props%EB%A1%9C-%EC%A0%84%EB%8B%AC%ED%95%98%EC%A7%80-%EB%A7%90%EC%95%84%EC%95%BC-%ED%95%98%EB%8A%94-%EC%9D%B4%EC%9C%A0
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.
넵!! onMinusClick, onPlusClick으로 prop 넘기는 방향으로 수정했습니다!!