Skip to content
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

[포스트 생성] step 순서 및 sns option 순서 변경 #69

Merged
merged 5 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions public/svg/icon_event_emoji.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions public/svg/icon_menu_emoji.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions src/assets/svg/IconEventEmoji.tsx

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions src/assets/svg/IconMenuEmoji.tsx

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/assets/svg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ export { default as IcHome01 } from './IcHome01';
export { default as IcPosting01 } from './IcPosting01';
export { default as IcPosting02 } from './IcPosting02';
export { default as IconArrow } from './IconArrow';

export { default as IconEventEmoji } from './IconEventEmoji';
export { default as IconMenuEmoji } from './IconMenuEmoji';
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,29 @@ import carrot from '../../../assets/Image/carrot.png';
import kakaoMap from '../../../assets/Image/kakaoMap.png';
import insta from '../../../assets/Image/Instagram.png';
import { useOnboardingContext } from '../../../context/PostNew/PostNewContext';
import Step1Title from './Step1Title/Step1Title';
import Step1Title from './SelectSnsTitle';
import NextButton from '../PostFooter/NextButton';
import { POSTING_CHANNEL } from '../../../core/Post';

export interface NameInputProps {
onNext: VoidFunction;
}

export default function Step1(props: NameInputProps) {
const SNS_ORDER_DEFAULT = [
POSTING_CHANNEL.INSTAGRAM,
POSTING_CHANNEL.KAKAO_CHANNEL,
POSTING_CHANNEL.DANGUEN,
POSTING_CHANNEL.KAKAO_TALK,
];

const SNS_ORDER_40s_50s = [
POSTING_CHANNEL.KAKAO_CHANNEL,
POSTING_CHANNEL.DANGUEN,
POSTING_CHANNEL.KAKAO_TALK,
POSTING_CHANNEL.INSTAGRAM,
];

export default function SelectSns(props: NameInputProps) {
const { onNext } = props;
const { onboardingInfo, updatePostInfo } = useOnboardingContext();
const [selectedSNS, setSelectedSNS] = useState<string | null>(
Expand All @@ -28,6 +42,16 @@ export default function Step1(props: NameInputProps) {
{ name: POSTING_CHANNEL.KAKAO_TALK, icon: kakaoMap },
];

const getOrderedSnsOptions = () => {
const ageGroups = onboardingInfo.targetAge || [];
const is40sOr50sSelected = ageGroups.includes('40대') && ageGroups.includes('50대');
const order = is40sOr50sSelected ? SNS_ORDER_40s_50s : SNS_ORDER_DEFAULT;

return snsOptions.sort((a, b) => order.indexOf(a.name) - order.indexOf(b.name));
};

const orderedSnsOptions = getOrderedSnsOptions();

const handleSelectSNS = (sns: string) => {
setSelectedSNS((prev) => {
const newSelectedSNS = prev === sns ? null : sns;
Expand All @@ -41,7 +65,7 @@ export default function Step1(props: NameInputProps) {
<PostTitleContainer>
<Step1Title />
<SNSOptionContainer>
{snsOptions.map((sns) => (
{orderedSnsOptions.map((sns) => (
<SNSOption
key={sns.name}
selected={selectedSNS === sns.name}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Title from '../../../common/Title/Title';
import Title from '../../common/Title/Title';
import styled from 'styled-components';

export default function Step1Title() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import styled from 'styled-components';
import Title from '../../../common/Title/Title';
import Title from '../../common/Title/Title';

export default function PostTitle() {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState } from 'react';
import styled from 'styled-components';
import { AgeBoxProps } from '../../../../types/PostNew';
import { useOnboardingContext } from '../../../../context/PostNew/PostNewContext';
import { AgeBoxProps } from '../../../types/PostNew';
import { useOnboardingContext } from '../../../context/PostNew/PostNewContext';

export default function SelectAge() {
const { onboardingInfo, updatePostInfo } = useOnboardingContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useState } from 'react';
import styled from 'styled-components';
import { GenderOptionProps } from '../../../../types/PostNew';
import { useOnboardingContext } from '../../../../context/PostNew/PostNewContext';
import maleIc from '../../../../assets/Icon/maleIc.png';
import femaleIc from '../../../../assets/Icon/femalIc.png';
import { GenderOptionProps } from '../../../types/PostNew';
import { useOnboardingContext } from '../../../context/PostNew/PostNewContext'
import maleIc from '../../../assets/Icon/maleIc.png';
import femaleIc from '../../../assets/Icon/femalIc.png';

export default function SelectGender() {
const { onboardingInfo, updatePostInfo } = useOnboardingContext();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { useState } from 'react';
import { styled } from 'styled-components';
import PostTitle from './PostTitle/PostTitle';
import { NameInputProps } from '../Step1/Step1';
import PostTitle from './PostTitle';
import { NameInputProps } from '../SelectSns/SelectSns';
import NextButton from '../PostFooter/NextButton';
import { AgeBoxProps } from '../../../types/PostNew';
import SelectGender from './SelectGender/SelectGender';
import SelectGender from './SelectGender';
import { useOnboardingContext } from '../../../context/PostNew/PostNewContext';

export default function Step2(props: NameInputProps) {
export default function SelectTarget(props: NameInputProps) {
const { onNext } = props;
const { onboardingInfo, updatePostInfo } = useOnboardingContext();
const [selectedAges, setSelectedAges] = useState<string[]>(onboardingInfo.targetAge || []);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';
import SelectType from './SelectType/SelectType';
import SelectType from './SelectTypeOptions';
import Title from '../../common/Title/Title';
import { NameInputProps } from '../Step1/Step1';
import { NameInputProps } from '../SelectSns/SelectSns';

export default function Step3(props: NameInputProps) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { useState } from 'react';
import styled from 'styled-components';
import { GenderOptionProps } from '../../../../types/PostNew';
import { useOnboardingContext } from '../../../../context/PostNew/PostNewContext';
import NextButton from '../../PostFooter/NextButton';
import { NameInputProps } from '../../Step1/Step1';
import menuIc from '../../../../assets/Icon/menuIc.png';
import eventIc from '../../../../assets/Icon/eventIc.png';
import { GenderOptionProps } from '../../../types/PostNew';
import { useOnboardingContext } from '../../../context/PostNew/PostNewContext';
import NextButton from '../PostFooter/NextButton';
import { NameInputProps } from '../SelectSns/SelectSns';
import { IconEventEmoji, IconMenuEmoji } from '../../../assets/svg';

export default function SelectType(props: NameInputProps) {
const { onNext } = props;
Expand All @@ -27,8 +26,13 @@ export default function SelectType(props: NameInputProps) {
}

const typeOptions = [
{ label: '메뉴 홍보', value: '메뉴', image: menuIc },
{ label: '이벤트 홍보', value: '이벤트', image: eventIc },
{ label: '메뉴 홍보', labelSub: 'ex. 신메뉴 홍보', value: '메뉴', image: IconMenuEmoji },
{
label: '이벤트 홍보',
labelSub: 'ex. 첫 오픈 할인 이벤트',
value: '이벤트',
image: IconEventEmoji,
},
];

return (
Expand All @@ -40,8 +44,11 @@ export default function SelectType(props: NameInputProps) {
selected={selectedType === option.value}
onClick={() => handleMenuSelect(option.value)}
>
<img src={option.image} />
{option.label}
<option.image className='nav-icon' />
<LabelContainer>
{option.label}
<p>{option.labelSub}</p>
</LabelContainer>
</TypeOption>
))}
</TypeSelection>
Expand All @@ -54,23 +61,31 @@ export default function SelectType(props: NameInputProps) {

const TypeSelection = styled.div`
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;

margin-top: 5rem;
gap: 1rem;
`;

const LabelContainer = styled.article`
p {
margin-top: 0.5rem;
color: ${({ theme }) => theme.colors.G_06};
${({ theme }) => theme.fonts.type_option};
}
`;
const TypeOption = styled.div<GenderOptionProps>`
display: flex;
justify-content: center;
justify-content: flex-start;
align-items: center;

width: 7.875rem;
height: 11.125rem;
width: 17rem;
height: 6rem;
gap: 2rem;
padding-left: 1rem;
cursor: pointer;
flex-direction: column;

border-radius: 0.625rem;
background: #fff;
Expand All @@ -80,8 +95,7 @@ const TypeOption = styled.div<GenderOptionProps>`
${({ theme, selected }) =>
selected ? `border: 1px solid ${theme.colors.main}; color: ${theme.colors.main}; ` : ''}

img {
.nav-icon {
width: 3.75rem;
margin-top: 16%;
}
`;
2 changes: 1 addition & 1 deletion src/components/PostNew/Step4/Step4.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import styled from 'styled-components';
import Title from '../../common/Title/Title';
import { Xmark } from '../../../assets/svg';
import useMenuInput from '../../../hooks/PostNew/useMenuInput';
import { NameInputProps } from '../Step1/Step1';
import { NameInputProps } from '../SelectSns/SelectSns';
import NextButton from '../PostFooter/NextButton';
import { useEffect, useState } from 'react';

Expand Down
2 changes: 1 addition & 1 deletion src/components/PostNew/Step5/Step5.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import styled from 'styled-components';
import Title from '../../common/Title/Title';
import { Xmark } from '../../../assets/svg';
import { NameInputProps } from '../Step1/Step1';
import { NameInputProps } from '../SelectSns/SelectSns';
import NextButton from '../PostFooter/NextButton';
import { useEffect, useRef, useState } from 'react';
import Keywords from './Keywords/Keywords';
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Feed/FeedPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Highlight } from '../../components/PostNew/Step1/Step1Title/Step1Title';
import { Highlight } from '../../components/PostNew/SelectSns/SelectSnsTitle';
import RelatedPosts from '../../components/common/Card/RelatedPosts';
import SubTitle from '../../components/common/Title/SubTitle';
import styled from 'styled-components';
Expand Down Expand Up @@ -45,7 +45,7 @@ const ImgContainer = styled.section`
top: 20%;
left: 50%;
gap: 1rem;
padding: 0 1rem;
padding: 0 1.5rem;
transform: translateX(-50%);
overflow-x: auto;
`;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Home/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useEffect } from 'react';
import styled from 'styled-components';
import { Highlight } from '../../components/PostNew/Step1/Step1Title/Step1Title';
import { Highlight } from '../../components/PostNew/SelectSns/SelectSnsTitle';
import CommonCard from '../../components/common/Card/CommonCard';

export default function Home() {
Expand Down
12 changes: 6 additions & 6 deletions src/pages/PostNew/PostNewPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { useNavigate } from 'react-router-dom';
import { useFunnel } from '../../hooks/useFunnel';
import { ONBOARDING_FORM_STEP } from '../../core/PostNew/Onboarding';
import { useOnboardingContext } from '../../context/PostNew/PostNewContext';
import Step1 from '../../components/PostNew/Step1/Step1';
import Step2 from '../../components/PostNew/Step2/Step2';
import Step3 from '../../components/PostNew/Step3/Step3';
import SelectSns from '../../components/PostNew/SelectSns/SelectSns';
import SelectTarget from '../../components/PostNew/SelectTarget/SelectTarget';
import SelectType from '../../components/PostNew/SelectType/SelectType';
import Step4 from '../../components/PostNew/Step4/Step4';
import Step5 from '../../components/PostNew/Step5/Step5';
import Step6 from '../../components/PostNew/Step6/Step6';
Expand Down Expand Up @@ -38,19 +38,19 @@ export default function PostNewPage() {
<Funnel.Step name='POSTING_CHANNEL'>
<PostNewHeader onClickBackBtn={() => onClickBackBtn(1)} />
<ProcessBar currentStep={1} stepCount={6} />
<Step1 onNext={() => setStep(() => 'AGE_GENDER')} />
<SelectType onNext={() => setStep(() => 'AGE_GENDER')} />
</Funnel.Step>

<Funnel.Step name='AGE_GENDER'>
<PostNewHeader onClickBackBtn={() => onClickBackBtn(2)} />
<ProcessBar currentStep={2} stepCount={6} />
<Step2 onNext={() => setStep(() => 'TYPE')} />
<SelectTarget onNext={() => setStep(() => 'TYPE')} />
</Funnel.Step>

<Funnel.Step name='TYPE'>
<PostNewHeader onClickBackBtn={() => onClickBackBtn(3)} />
<ProcessBar currentStep={3} stepCount={6} />
<Step3 onNext={() => setStep(() => 'POSTING_SUBJECT')} />
<SelectSns onNext={() => setStep(() => 'POSTING_SUBJECT')} />
</Funnel.Step>

<Funnel.Step name='POSTING_SUBJECT'>
Expand Down
7 changes: 7 additions & 0 deletions src/style/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ const fonts = {
font-weight: 400;
line-height: normal;
`,
type_option: css`
font-family: Pretendard;
font-size: 0.9rem;
font-style: normal;
font-weight: 700;
line-height: 144.583%;
`,
card_button: css`
font-family: Pretendard;
font-size: 0.8rem;
Expand Down
Loading