@@ -6,14 +6,15 @@ import { theme } from "@/styles/theme";
66import NavigatorBar from "@/components/common/NavigatorBar" ;
77import Button from "@/components/common/Button" ;
88import { useRouter , useSearchParams } from "next/navigation" ;
9- import Image from "next/image" ;
109import Letter from "@/components/letter/Letter" ;
1110import { useRecoilValue , useSetRecoilState } from "recoil" ;
1211import {
1312 registerLetterState ,
1413 useSsrComplectedState ,
1514} from "@/recoil/letterStore" ;
1615import Loader , { LoaderContainer } from "@/components/common/Loader" ;
16+ import LetterTemplateList from "@/components/letter/LetterTemplateList" ;
17+ import { ALL_TEMPLATES } from "@/constants/templates" ;
1718
1819const LetterTemplatePage = ( ) => {
1920 const router = useRouter ( ) ;
@@ -24,7 +25,9 @@ const LetterTemplatePage = () => {
2425 useRecoilValue ( registerLetterState ) ;
2526 const setRegisterLetterState = useSetRecoilState ( registerLetterState ) ;
2627
27- const [ template , setTemplateType ] = useState < number > ( templateType || 0 ) ;
28+ const [ template , setTemplateType ] = useState < number > (
29+ templateType || ALL_TEMPLATES [ 0 ]
30+ ) ;
2831 const totalPage = 10 ;
2932
3033 /* SSR 완료 시 상태 업데이트 */
@@ -58,14 +61,14 @@ const LetterTemplatePage = () => {
5861 return (
5962 < Layout >
6063 < NavigatorBar
61- title = { letterId ? "편지 수정하기" : "새 편지 등록하기 " }
64+ title = { letterId ? "편지 수정하기" : "받은 편지 보관하기 " }
6265 cancel = { false }
6366 />
6467 < Container >
6568 < Essential > * 필수</ Essential >
6669 < Column >
6770 < Label > 편지지를 골라볼까요? *</ Label >
68- < SmallText > 마음에 드는 배경으로 편지를 저장할 수 있어요</ SmallText >
71+ < SmallText > 마음에 드는 배경으로 편지를 보관할 수 있어요</ SmallText >
6972 < LetterWrapper >
7073 < LetterContainer >
7174 < Letter
@@ -82,22 +85,11 @@ const LetterTemplatePage = () => {
8285 />
8386 </ LetterContainer >
8487 </ LetterWrapper >
85- < TemplatesList >
86- { [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] . map ( ( item ) => (
87- < TemplateImage
88- key = { item }
89- src = { `/assets/letter/background_${ item } .png` }
90- width = { 70 }
91- height = { 70 }
92- alt = "편지지"
93- $selected = { template === item }
94- onClick = { ( ) => hanleChangeTemplate ( item ) }
95- />
96- ) ) }
97- </ TemplatesList >
98- < Page >
99- < Current > { template + 1 } </ Current > /{ totalPage }
100- </ Page >
88+ < LetterTemplateList
89+ selectedTemplate = { template }
90+ onChangeTemplate = { hanleChangeTemplate }
91+ templates = { ALL_TEMPLATES }
92+ />
10193 </ Column >
10294 < ButtonWrapper >
10395 < Button
@@ -241,87 +233,6 @@ const LetterContainer = styled.div`
241233 min-height: 182px;
242234 }
243235` ;
244-
245- const TemplatesList = styled . div `
246- display: flex;
247- justify-content: flex-start;
248- align-items: center;
249- gap: 12px;
250- height: 78px;
251- padding-left: 4px;
252- margin-top: 69px;
253- margin-bottom: 14px;
254- overflow-x: scroll;
255-
256- ::-webkit-scrollbar {
257- display: none;
258- }
259- -ms-overflow-style: none; /* IE, Edge */
260- scrollbar-width: none; /* Firefox */
261-
262- @media (max-height: 740px) {
263- margin-top: 30px;
264- margin-bottom: 5px;
265- ${ theme . fonts . body14 } ;
266- gap: 11px;
267- }
268-
269- @media (max-height: 680px) {
270- margin-top: 15px;
271- margin-bottom: 5px;
272- ${ theme . fonts . body14 } ;
273- gap: 11px;
274- }
275-
276- @media (max-height: 628px) {
277- margin-top: 12px;
278- margin-bottom: 5px;
279- ${ theme . fonts . body14 } ;
280- gap: 11px;
281- }
282- ` ;
283-
284- const TemplateImage = styled ( Image ) < { $selected : boolean } > `
285- width: 70px;
286- height: 70px;
287- border-radius: 8px;
288- box-sizing: content-box;
289-
290- ${ ( { $selected, theme } ) =>
291- $selected &&
292- css `
293- box-shadow: 0 0 0 4px ${ theme . colors . sub03 } ;
294- ` }
295-
296- @media (max-height: 628px) {
297- width: 50px;
298- height: 50px;
299- border-radius: 4px;
300- ${ ( { $selected, theme } ) =>
301- $selected &&
302- css `
303- box-shadow: 0 0 0 2px ${ theme . colors . sub03 } ;
304- ` }
305- }
306- ` ;
307-
308- const Page = styled . div `
309- width: 100%;
310- display: flex;
311- justify-content: flex-end;
312- color: ${ theme . colors . gray500 } ;
313- ${ theme . fonts . caption03 } ;
314- ` ;
315-
316- const Current = styled . span `
317- color: ${ theme . colors . white } ;
318- margin-bottom: 100px;
319-
320- @media (max-height: 628px) {
321- margin-bottom: 50px;
322- }
323- ` ;
324-
325236const ButtonWrapper = styled . div `
326237 width: 100%;
327238 position: absolute;
0 commit comments