-
Notifications
You must be signed in to change notification settings - Fork 1
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
타이어 커스텀 페이지 구현 - 측면 디자인 close #23 #24
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e755f1a
feat: 측면 디자인 색상 전역상태 구현 #23
jinlee1703 7929016
feat: 측면 디자인 글꼴 전역상태 구현 #23
jinlee1703 32df3ec
refactor: custom 데이터 훅 분리 #23
jinlee1703 1e40d79
refactor: 폰트 및 색상 항목추가에 따른 항목 선택 상자 리팩토링 #23
jinlee1703 c82b2c2
fix: 측면 디자인 선택에 따른 컴포넌트 css 수정 #23
jinlee1703 db8ffe1
refactor: 측면 디자인 선택에 따른 summary 컴포넌트 css 수정 #23
jinlee1703 4ec7a69
fix: 주석 제거 및 css 수정 #23
jinlee1703 31d992d
fix: 폰트 선택 시 summary 컴포넌트에 반영되도록 수정 #23
jinlee1703 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { atom } from 'recoil'; | ||
|
||
export const selectedColorIdState = atom<number>({ | ||
key: 'selectedColorIdState', | ||
default: 0, | ||
}); |
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,6 @@ | ||
import { atom } from 'recoil'; | ||
|
||
export const selectedFontIdState = atom<number>({ | ||
key: 'selectedFontIdState', | ||
default: 0, | ||
}); |
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 { Accessory } from '@api/accessory'; | ||
import { AccessoryData } from '@api/accessory.types'; | ||
import { Color } from '@api/color'; | ||
import { ColorData } from '@api/color.types'; | ||
import { Font } from '@api/font'; | ||
import { FontData } from '@api/font.types'; | ||
import { Pattern } from '@api/pattern'; | ||
import { PatternData } from '@api/pattern.types'; | ||
import { Wheel } from '@api/wheel'; | ||
import { WheelData } from '@api/wheel.types'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
function useCustomData() { | ||
const [pattern, setPattern] = useState<PatternData[]>([]); | ||
const [wheel, setWheel] = useState<WheelData[]>([]); | ||
const [font, setFont] = useState<FontData[]>([]); | ||
const [color, setColor] = useState<ColorData[]>([]); | ||
const [accessory, setAccessory] = useState<AccessoryData[]>([]); | ||
|
||
useEffect(() => { | ||
const getData = async () => { | ||
const [patterns, wheels, fonts, colors, accessories] = await Promise.all([ | ||
Pattern.list(), | ||
Wheel.list(), | ||
Font.list(), | ||
Color.list(), | ||
Accessory.list(), | ||
]); | ||
setPattern(patterns); | ||
setWheel(wheels); | ||
setFont(fonts); | ||
setColor(colors); | ||
setAccessory(accessories); | ||
}; | ||
getData(); | ||
}, []); | ||
|
||
return { pattern, wheel, font, color, accessory }; | ||
} | ||
|
||
export default useCustomData; |
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,11 +1,19 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Container = styled.div` | ||
interface ContainerProps { | ||
position?: 'default' | 'absolute'; | ||
} | ||
|
||
export const Container = styled.div<ContainerProps>` | ||
background-color: #cdd1d9; | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 5px; | ||
|
||
${({ position }) => | ||
position === 'absolute' && | ||
'position: absolute; bottom: 0; right: 0; height: 50px; background-color: #ffffff; width: 22%; margin: 30px;'} | ||
`; |
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
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,29 +1,77 @@ | ||
import useCustomData from '@hooks/useCustomData'; | ||
import { Container, Explanation, Name, Price } from './index.style'; | ||
import { PatternData } from '@api/pattern.types'; | ||
import { WheelData } from '@api/wheel.types'; | ||
import { AccessoryData } from '@api/accessory.types'; | ||
|
||
interface SummaryProps { | ||
data: PatternData | WheelData | AccessoryData; | ||
} | ||
import { useSearchParams } from 'react-router-dom'; | ||
import { selectedPatternIdState } from '@context/pattern'; | ||
import { useRecoilState } from 'recoil'; | ||
import { selectedWheelIdState } from '@context/wheel'; | ||
import { selectedFontIdState } from '@context/font'; | ||
import { selectedColorIdState } from '@context/color'; | ||
|
||
function formatCurrency(price: number) { | ||
return '+ ' + price.toLocaleString('ko-KR') + '원'; | ||
} | ||
|
||
function Summary(props: SummaryProps) { | ||
return ( | ||
<Container className="summary"> | ||
<div className="top"> | ||
<Name>{props.data.name}</Name> | ||
<Price>{formatCurrency(props.data.price)}</Price> | ||
</div> | ||
<hr className="sep" /> | ||
<Explanation> | ||
<p>{props.data.explanation}</p> | ||
</Explanation> | ||
</Container> | ||
); | ||
function Summary() { | ||
const [searchParams] = useSearchParams(); | ||
const step: number = Number(searchParams.get('step')); | ||
const { pattern, wheel, font, color, accessory } = useCustomData(); | ||
const [selectedPattern] = useRecoilState(selectedPatternIdState); | ||
const [selectedWheel] = useRecoilState(selectedWheelIdState); | ||
const [selectedFont] = useRecoilState(selectedFontIdState); | ||
const [selectedColor] = useRecoilState(selectedColorIdState); | ||
|
||
if (!pattern.length || !wheel.length || !font.length || !color.length || !accessory.length) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
switch (step) { | ||
case 0: | ||
return ( | ||
<Container className="summary"> | ||
<div className="top"> | ||
<Name>{pattern[selectedPattern].name}</Name> | ||
<Price>{formatCurrency(pattern[selectedPattern].price)}</Price> | ||
</div> | ||
<hr className="sep" /> | ||
<Explanation> | ||
<p>{pattern[selectedPattern].explanation}</p> | ||
</Explanation> | ||
</Container> | ||
); | ||
case 1: | ||
return ( | ||
<Container className="summary"> | ||
<div className="top"> | ||
<Name>{wheel[selectedWheel].name}</Name> | ||
<Price>{formatCurrency(wheel[selectedWheel].price)}</Price> | ||
</div> | ||
<hr className="sep" /> | ||
<Explanation> | ||
<p>{wheel[selectedWheel].explanation}</p> | ||
</Explanation> | ||
</Container> | ||
); | ||
case 2: | ||
return ( | ||
<Container className="summary"> | ||
<div className="top"> | ||
<Name>{`${font[selectedFont].name}/${color[selectedColor].name}`}</Name> | ||
<Price>{formatCurrency(font[selectedFont].price)}</Price> | ||
</div> | ||
<hr className="sep" /> | ||
<Explanation> | ||
<p | ||
className="font_example" | ||
style={{ color: color[selectedColor].name, fontFamily: font[selectedFont].name }} | ||
> | ||
Outfit Of Tire | ||
</p> | ||
</Explanation> | ||
</Container> | ||
); | ||
default: | ||
return <div>Error...</div>; | ||
} | ||
} | ||
|
||
export default Summary; |
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
Oops, something went wrong.
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.
올바르지 않은 접근일 때는 어떻게 처리가 되나요?
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.
그냥 빈 화면에 "올바르지 않은 접근입니다."라고 출력돼서 나옵니다~