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

feat: add dev-test draft #22

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
3644102
feat: set global style
Jun99uu Feb 5, 2023
cf38722
feat: add _document file
Jun99uu Feb 5, 2023
4e43b67
feat: add Page-Wrapper for mobile viewport
Jun99uu Feb 5, 2023
544c64c
feat: set DevTest empty Page
Jun99uu Feb 5, 2023
ff07208
feat: add community-StartButton Component
Jun99uu Feb 5, 2023
64f6196
feat: add community-Button Component
Jun99uu Feb 5, 2023
5092f7c
feat: add community-Title Box Component
Jun99uu Feb 5, 2023
8e79f75
feat: add community-Visitor Component
Jun99uu Feb 5, 2023
7b4f980
feat: add design token for community spec
Jun99uu Feb 5, 2023
a4a5534
fix: apply design token
Jun99uu Feb 5, 2023
9029cd1
fix: fix Page Wrapper
Jun99uu Feb 5, 2023
dc97fcc
feat: add absolute path
Jun99uu Feb 5, 2023
b7aa0f8
fix: fix mobile web vh-bug
Jun99uu Feb 5, 2023
db62045
feat: add devtest inner content changing
Jun99uu Feb 5, 2023
1c65c1e
fix: fix font in TitleBox
Jun99uu Feb 5, 2023
6d18e79
fix: fix Font in Button
Jun99uu Feb 5, 2023
6b6cbd8
feat: add questions content page
Jun99uu Feb 5, 2023
9f79c93
fix : change community directory name
Jun99uu Feb 12, 2023
20369b1
fix : fix component dependency and props
Jun99uu Feb 12, 2023
d299b47
fix : take out DevTestPage
Jun99uu Feb 12, 2023
4557271
fix : styling by vanilla-extract
Jun99uu Feb 12, 2023
1fb23c0
feat : add dev-test questions
Jun99uu Feb 13, 2023
0cb2a72
fix : fix Image and fontSize
Jun99uu Feb 14, 2023
b166518
feat : add progress bar
Jun99uu Feb 14, 2023
9aa6685
feat : add feat caculating test-result
Jun99uu Feb 19, 2023
a0bf7ea
fix : fix init value in Progressbar
Jun99uu Feb 19, 2023
d2e4f8a
feat : add result resources(svg)
Jun99uu Feb 19, 2023
1563edb
feat : print dev-test result
Jun99uu Feb 19, 2023
80dab9c
Merge branch 'main' of https://github.com/gdsc-ssu/web into feat/20_d…
Jun99uu Feb 19, 2023
f382802
fix : fix Result type
Jun99uu Feb 20, 2023
4d08f40
feat : add result dom to image function
Jun99uu Feb 28, 2023
89e41d1
feat : add loading spinner
Jun99uu Feb 28, 2023
a38b00e
feat : add useInterval hooks
Jun99uu Feb 28, 2023
7cec2fe
feat : add loading spinner in result page (3s)
Jun99uu Feb 28, 2023
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
3 changes: 3 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const withVanillaExtract = createVanillaExtractPlugin();
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
images: {
domains: ['horosocular.s3.ap-northeast-1.amazonaws.com'],
},
};

module.exports = withVanillaExtract(nextConfig);
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
"dependencies": {
"@prisma/client": "4.9.0",
"@tanstack/react-query": "4.16.1",
"@types/dom-to-image": "^2.6.4",
"@types/file-saver": "^2.0.5",
"@types/node": "18.11.9",
"@types/react": "18.0.25",
"@types/react-dom": "18.0.9",
"@vanilla-extract/css": "1.9.2",
"dom-to-image": "^2.6.0",
"eslint": "8.28.0",
"eslint-config-next": "13.1.6",
"file-saver": "^2.0.5",
"framer-motion": "7.6.7",
"jotai": "1.10.0",
"next": "13.1.6",
Expand Down
5 changes: 5 additions & 0 deletions src/components/community/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import StartPage from './playground/DevTest/StartPage';
import PlayPage from './playground/DevTest/PlayPage';
import ResultPage from './playground/DevTest/ResultPage';

export { StartPage, PlayPage, ResultPage };
109 changes: 109 additions & 0 deletions src/components/community/playground/DevTest/PlayPage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { questions } from '@/resources/devTestQustions';
import { useState, useEffect } from 'react';
import { Button, TitleBox } from '../common';
import type { StepProps } from './types';
import * as styles from './devtest.css';
import ProgressBar from './ProgressBar/ProgressBar';
import { DevType, results } from '@/resources/devTestQustions';

interface Props extends StepProps {
saveResult?: (res: DevType) => void;
}

type Count = {
[key: number]: number;
};

const PlayPage = (props: Props) => {
const { onEnd, saveResult } = props;
const [idx, setIdx] = useState(0);
const [answers, setAnswers] = useState<Array<number>>(
Array(questions.length).fill(0),
);
const [choices, setChoices] = useState<Array<DevType>>(
questions[0].select[0].type,
);
const [types, setTypes] = useState<Array<DevType>>([]);

const choice = (aIdx: number, devType: Array<DevType>) => {
setChoices(devType);
setAnswers((prev) => prev.map((p, pi) => (idx === pi ? aIdx : p)));
};

const moveToNext = () => {
setTypes((prev) => [...prev, ...choices]);
setIdx((prev) => prev + 1);
};

const getMode = () => {
const devTypes = types.map((type) => type.name);

const counts: Count = {
0: 0,
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
};

const newObject = devTypes.reduce((acc, cur) => {
acc.hasOwnProperty(cur) ? (acc[cur] += 1) : (acc[cur] = 1);
return acc;
}, counts);

const modeKey: number = Object.keys(newObject)
.map((a) => Number(a))
.reduce((acc, cur) => (newObject[acc] > newObject[cur] ? acc : cur));

saveResult!(results[modeKey]);
};

useEffect(() => {
if (idx === questions.length) {
getMode();
onEnd();
} else {
setChoices(questions[idx].select[0].type);
}
}, [idx]);

return (
<div className={styles.playPage}>
{questions[idx] ? (
<>
<span className={styles.progress}>
<ProgressBar curIdx={idx} />
</span>
<div className={styles.questionArea}>
<TitleBox
title={`Q${idx + 1}`}
subtitle={questions[idx].question}
/>
</div>
<div className={styles.questionArea}>
{questions[idx].select.map((s, aIdx) => (
<Button
selected={answers[idx] === aIdx ? 0 : 1}
title={s.answer}
onClick={() => choice(aIdx, s.type)}
key={s.answer}
/>
))}
</div>
<Button
selected={2}
title={
idx !== questions.length - 1 ? '다음 질문으로!' : '결과 확인하기!'
}
onClick={moveToNext}
/>
</>
) : (
<></>
)}
</div>
);
};

export default PlayPage;
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import { styleVariants, style } from '@vanilla-extract/css';
import { COLORS } from '../../common/colorToken';

const innerBase = style({
transition: 'all 0.25s',
background: `linear-gradient(135deg, ${COLORS.SSU.DeepBlue}, ${COLORS.SSU.SkyBlue})`,
height: '100%',
borderRadius: '500px',
});

export const progress = styleVariants({
outer: [
{
width: '100%',
height: '15px',
borderRadius: '500px',
backgroundColor: `${COLORS.grayscale.Gray2}`,
overflow: 'hidden',
padding: '2px',
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'flex-start',
},
],
inner__0: [
innerBase,
{
width: `2%`,
},
],
inner__1: [
innerBase,
{
width: `9%`,
},
],
inner__2: [
innerBase,
{
width: `18%`,
},
],
inner__3: [
innerBase,
{
width: `27%`,
},
],
inner__4: [
innerBase,
{
width: `36%`,
},
],
inner__5: [
innerBase,
{
width: `45%`,
},
],
inner__6: [
innerBase,
{
width: `54%`,
},
],
inner__7: [
innerBase,
{
width: `63%`,
},
],
inner__8: [
innerBase,
{
width: `72%`,
},
],
inner__9: [
innerBase,
{
width: `81%`,
},
],
inner__10: [
innerBase,
{
width: `90%`,
},
],
inner__11: [
innerBase,
{
width: `100%`,
},
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import * as styles from './ProgressBar.css';

interface Props {
curIdx: number;
}

const ProgressBar = ({ curIdx }: Props) => {
return (
<div className={styles.progress['outer']}>
<div className={styles.progress[`inner__${curIdx}`]} />
</div>
);
};

export default ProgressBar;
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { style, styleVariants } from '@vanilla-extract/css';
import { COLORS } from '../../common/colorToken';
import { bodyText } from '../../common/textToken.css';
import { titleText } from '../../common/textToken.css';

export const resultBox = styleVariants({
box: [
{
width: '100%',
backgroundColor: 'white',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
borderRadius: '20px',
padding: '40px 10px',
gap: '40px',
},
],
titleBox: [
{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
textAlign: 'center',
gap: '3px',
whiteSpace: 'pre-line',
wordBreak: 'keep-all',
},
],
title: [
bodyText.body2R,
{
color: COLORS.grayscale.Gray8,
},
],
subtitle: [
bodyText.body1B,
{
color: COLORS.grayscale.Gray9,
},
],
img: [
{
position: 'relative',
width: '90%',
height: '200px',
},
],
list: [
bodyText.body3,
{
listStyleType: 'none',
margin: '0px',
padding: '0px',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
textAlign: 'center',
whiteSpace: 'pre-line',
wordBreak: 'keep-all',
gap: '8px',
color: COLORS.grayscale.Gray9,
},
],
logo: [
{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
gap: '4px',
},
],
recDetail: [
{
fontSize: '14px',
textAlign: 'center',
color: COLORS.grayscale.Gray7,
},
],
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { DevType, images } from '@/resources/devTestQustions';
import * as styles from './ResultBox.css';
import Image from 'next/image';
import { Button } from '../../common';
import Logo from '@/resources/assets/logo.svg';

interface Props {
result: DevType;
}

const ResultBox = ({ result }: Props) => {
return (
<div className={styles.resultBox['box']}>
<div className={styles.resultBox['titleBox']}>
<span className={styles.resultBox['title']}>{result.title}</span>
<span className={styles.resultBox['subtitle']}>{result.subtitle}</span>
</div>
<span className={styles.resultBox['img']}>
<Image src={images[result.name]} alt={result.type} fill />
</span>
<ul className={styles.resultBox['list']}>
{result.content.map((r) => (
<li className={r} key={r}>
{r}
</li>
))}
</ul>
<div className={styles.resultBox['logo']}>
<Image src={Logo} width={50} height={34.25} alt="logo" />
<span className={styles.resultBox['recDetail']}>
GDSC Soongsil Univ.
</span>
</div>

{/* <span className={styles.resultBox['recDetail']}>
나와 비슷한 개발자들이 모여있는...
</span>
<Button selected={4} title={`GDSC ${result?.part} 지원하기`} /> */}
</div>
);
};

export default ResultBox;
Loading