Skip to content

Commit d140ea9

Browse files
authored
Merge pull request #45 from DevKor-github/feat/#37/post-layout
feat: post ๊ณตํ†ต ๋ ˆ์ด์•„์›ƒ ์„ค์ •
2 parents 56fbdea + 1512b19 commit d140ea9

18 files changed

Lines changed: 284 additions & 67 deletions

File tree

โ€Žsrc/common/components/Button/index.tsxโ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as s from './style.css';
44
interface Props extends PropsWithChildren {
55
color?: 'gray' | 'main' | 'softgray' | 'deemedgray';
66
onClick?: () => void;
7-
style? : HTMLAttributes<HTMLDivElement>['style'];
7+
style?: HTMLAttributes<HTMLDivElement>['style'];
88
}
99
const Btn = ({ children, color = 'softgray', onClick, style }: Props) => {
1010
return (

โ€Žsrc/common/components/Button/style.css.tsโ€Ž

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const Button = cva({
1515
fontStyle: 'normal',
1616
fontWeight: '500',
1717
lineHeight: 'normal',
18-
letterSpacing: '-0.05rem'
18+
letterSpacing: '-0.05rem',
1919
},
2020
variants: {
2121
color: {
@@ -25,16 +25,16 @@ export const Button = cva({
2525
},
2626
gray: {
2727
backgroundColor: 'systemGray5',
28-
color: '100'
28+
color: '100',
2929
},
3030
softgray: {
3131
backgroundColor: 'systemGray5',
32-
color: '80'
32+
color: '80',
3333
},
3434
deemedgray: {
3535
backgroundColor: 'systemGray5',
36-
color: '54'
37-
}
38-
}
39-
}
40-
})
36+
color: '54',
37+
},
38+
},
39+
},
40+
});

โ€Žsrc/common/components/SafeArea/style.css.tsโ€Ž

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ import { css } from '@styled-system/css';
22

33
export const Container = css({
44
position: 'absolute',
5+
bottom: 0
56
});

โ€Žsrc/pages/PostPage/index.tsxโ€Ž

Lines changed: 0 additions & 26 deletions
This file was deleted.

โ€Žsrc/pages/PostPage/postCard.tsxโ€Ž

Lines changed: 0 additions & 15 deletions
This file was deleted.

โ€Žsrc/pages/PostPage/style.css.tsโ€Ž

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { useNavigate } from 'react-router';
2+
import * as s from './style.css';
3+
4+
const Header = () => {
5+
const navigator = useNavigate();
6+
7+
const handleClose = () => {
8+
navigator(-1);
9+
};
10+
11+
return (
12+
<header>
13+
<div className={s.Container}>
14+
<button className={`mgc_close_line ${s.closeBtn}`} onClick={handleClose}></button>
15+
<span className={s.headerText}> ๊ธ€์“ฐ๊ธฐ </span>
16+
</div>
17+
</header>
18+
);
19+
};
20+
21+
export default Header;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import Header from './header';
2+
import Navigator from './navigator';
3+
import Step1 from '@/pages/PostPages/StepPages/step1';
4+
import Step2 from '@/pages/PostPages/StepPages/step2';
5+
import Step3 from '@/pages/PostPages/StepPages/step3';
6+
import Step4 from '@/pages/PostPages/StepPages/step4';
7+
import Step5 from '@/pages/PostPages/StepPages/step5';
8+
import Step6 from '@/pages/PostPages/StepPages/step6';
9+
// import StepIndicator from './' // [TODO] stepindicator ๋งŒ๋“ค์–ด์„œ ์ถ”๊ฐ€ํ•˜๊ธฐ
10+
import { useState } from 'react';
11+
12+
import * as s from './style.css';
13+
14+
const MAX_STEP = 6;
15+
16+
const steps = [
17+
<Step1 />,
18+
<Step2 />,
19+
<Step3 />,
20+
<Step4 />,
21+
<Step5 />,
22+
<Step6 />,
23+
];
24+
25+
const WriteLayout = () => {
26+
27+
const [step, setStep] = useState(1);
28+
29+
const isFirst = step === 1;
30+
const isLast = step === MAX_STEP;
31+
32+
const goPrev = () => {
33+
setStep((prev) => Math.max(1, prev - 1)); // ์ด์ „ ์ƒํƒœ ๊ณ ๋ ค (prev), ์ตœ์†Œ 1
34+
}
35+
36+
const goNext = () => {
37+
if (step < MAX_STEP) setStep(step + 1);
38+
else console.log('์ž‘์„ฑ ์™„๋ฃŒ');
39+
};
40+
41+
return (
42+
<div className={s.entireLayout}>
43+
<Header />
44+
<div className={s.innerPage}>{steps[step - 1]}</div>
45+
<Navigator goNext={goNext} goPrev={goPrev} isFirst={isFirst} isLast={isLast} />
46+
</div>
47+
);
48+
};
49+
50+
export default WriteLayout;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Btn from '@/common/components/Button';
2+
import * as s from './style.css';
3+
4+
interface NavigatorProps {
5+
goNext: () => void;
6+
goPrev: () => void;
7+
isFirst: boolean;
8+
isLast: boolean;
9+
}
10+
11+
const Navigator = ({ goNext, goPrev, isFirst, isLast }: NavigatorProps) => {
12+
13+
const label = isLast ? '์™„๋ฃŒ' : '๋‹ค์Œ';
14+
15+
return (
16+
<footer>
17+
<div className={s.stepBtn}>
18+
{!isFirst && (
19+
<div className={s.halfFlex}>
20+
<Btn onClick={goPrev}>
21+
์ด์ „
22+
</Btn>
23+
</div>
24+
)}
25+
<Btn onClick={goNext} color="main" style={isFirst ? { width: '100%' } : { flex: '1 1 0' }}>
26+
{label}
27+
</Btn>
28+
</div>
29+
</footer>
30+
);
31+
};
32+
33+
export default Navigator;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { css } from '@styled-system/css';
2+
3+
export const stepBtn = css({
4+
display: 'flex',
5+
justifyContent: 'space-evenly',
6+
gap: '1rem',
7+
padding: '0rem 1rem 2.625rem 1rem',
8+
});
9+
10+
export const entireLayout = css({
11+
display: 'flex',
12+
flexDirection: 'column',
13+
height: '100%',
14+
});
15+
16+
export const innerPage = css({
17+
flex: 1,
18+
overflowY: 'auto',
19+
});
20+
21+
export const Container = css({
22+
display: 'flex',
23+
alignItems: 'center',
24+
position: 'relative',
25+
height: '4.44rem',
26+
});
27+
28+
export const closeBtn = css({
29+
position: 'absolute',
30+
left: '1rem',
31+
cursor: 'pointer',
32+
width: '1.25rem',
33+
color: '80',
34+
flexShrink: '1',
35+
aspectRatio: '1/1',
36+
fontSize: '1.25rem',
37+
});
38+
39+
export const headerText = css({
40+
flex: '1',
41+
textAlign: 'center',
42+
fontSize: '1.25rem',
43+
fontWeight: '600',
44+
});
45+
46+
export const halfFlex = css ({
47+
flex: '1 1 0'
48+
})

0 commit comments

Comments
ย (0)