Compare commits
45 Commits
Author | SHA1 | Date |
---|---|---|
Jason Zhu | c913b32ddb | |
Jason Zhu | 3580e9b0b4 | |
Jason Zhu | 2319706d66 | |
Jason Zhu | 7f5df7cdf3 | |
Jason Zhu | 62e7510193 | |
Jason Zhu | 3414f20798 | |
Jason Zhu | a2d892793c | |
Jason Zhu | 943e22ffdb | |
Jason Zhu | 40b20ae730 | |
Jason Zhu | b71ce601d7 | |
Jason Zhu | dbb3d2f9b5 | |
Jason Zhu | fa83caf8a7 | |
Jason Zhu | f50dd73596 | |
Jason Zhu | a51437c7cc | |
Jason Zhu | 191d87662d | |
Jason Zhu | e87108a892 | |
Jason Zhu | f986272027 | |
Jason Zhu | 4f9e43b95e | |
Jason Zhu | 61660bf83d | |
Jason Zhu | 6d5af0a856 | |
Jason Zhu | 5c08042544 | |
Jason Zhu | 5b79adea19 | |
Jason Zhu | fbc2541230 | |
Jason Zhu | 7c3215867f | |
Jason Zhu | 4963def0bd | |
Jason Zhu | 4a04834929 | |
Jason Zhu | 1292870db9 | |
Yiqing Zhu | 055f653476 | |
Yiqing Zhu | 691840dee3 | |
Yiqing Zhu | 26f7fc4582 | |
Jason Zhu | e4f41e5d8d | |
Jason Zhu | c98972dec9 | |
Jason Zhu | 2005072dea | |
Yiqing Zhu | e90cc6b191 | |
Yiqing Zhu | 9830fb1af2 | |
Yiqing Zhu | a5d1351f92 | |
Yiqing Zhu | 2b3cbdddd5 | |
Yiqing Zhu | b4d0fed5cb | |
Yiqing Zhu | 7dd02a76ea | |
Yiqing Zhu | 0f31f492cc | |
Yiqing Zhu | 2afb204673 | |
Yiqing Zhu | cdecba7c2e | |
Yiqing Zhu | 072b7dcf88 | |
Yiqing Zhu | b6fdcbd740 | |
Yiqing Zhu | 4affa35f00 |
File diff suppressed because it is too large
Load Diff
|
@ -15,7 +15,6 @@
|
|||
"history": "^5.3.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-hook-form": "^7.29.0",
|
||||
"react-router-dom": "^6.2.2",
|
||||
"react-scripts": "5.0.0",
|
||||
"typescript": "^4.6.2",
|
||||
|
|
|
@ -1,52 +1,6 @@
|
|||
import React from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
import { Page } from './Page';
|
||||
import {
|
||||
FieldInput,
|
||||
FieldLabel,
|
||||
Fieldset,
|
||||
FieldContainer,
|
||||
FieldTextArea,
|
||||
FormButtonContainer,
|
||||
PrimaryButton,
|
||||
} from './Styles';
|
||||
|
||||
type FormData = {
|
||||
title: string;
|
||||
content: string;
|
||||
};
|
||||
|
||||
export const AskPage = () => {
|
||||
const { register } = useForm<FormData>();
|
||||
return (
|
||||
<Page title="Ask a question">
|
||||
<form>
|
||||
<Fieldset>
|
||||
<FieldContainer>
|
||||
<FieldLabel htmlFor="title">Title</FieldLabel>
|
||||
<FieldInput
|
||||
{...register('title')}
|
||||
id="title"
|
||||
name="title"
|
||||
type="text"
|
||||
/>
|
||||
</FieldContainer>
|
||||
<FieldContainer>
|
||||
<FieldLabel htmlFor="content">Content</FieldLabel>
|
||||
<FieldTextArea
|
||||
{...register('content')}
|
||||
id="content"
|
||||
name="content"
|
||||
/>
|
||||
</FieldContainer>
|
||||
<FormButtonContainer>
|
||||
<PrimaryButton type="submit">Submit Your Question</PrimaryButton>
|
||||
</FormButtonContainer>
|
||||
</Fieldset>
|
||||
</form>
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
export const AskPage = () => <Page title="Ask a question">{null}</Page>;
|
||||
|
||||
export default AskPage;
|
||||
|
|
|
@ -1,23 +1,14 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
import React from 'react';
|
||||
import { Link, useSearchParams } from 'react-router-dom';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
import { UserIcon } from './Icons';
|
||||
import { fontFamily, fontSize, gray1, gray2, gray5 } from './Styles';
|
||||
|
||||
type FormData = {
|
||||
search: string;
|
||||
};
|
||||
|
||||
export const Header = () => {
|
||||
const { register } = useForm<FormData>();
|
||||
const [searchParams] = useSearchParams();
|
||||
const criteria = searchParams.get('criteria') || '';
|
||||
|
||||
const handleSubmit = (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
const handleSearchInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
console.log(e.currentTarget.value);
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -47,13 +38,10 @@ export const Header = () => {
|
|||
>
|
||||
Q & A
|
||||
</Link>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<input
|
||||
{...register('search')}
|
||||
name="search"
|
||||
type="text"
|
||||
placeholder="Search ..."
|
||||
defaultValue={criteria}
|
||||
onChange={handleSearchInputChange}
|
||||
css={css`
|
||||
box-sizing: border-box;
|
||||
font-family: ${fontFamily};
|
||||
|
@ -70,7 +58,6 @@ export const Header = () => {
|
|||
}
|
||||
`}
|
||||
/>
|
||||
</form>
|
||||
<Link
|
||||
to="signin"
|
||||
css={css`
|
||||
|
|
|
@ -1,32 +1,17 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
import {
|
||||
FieldContainer,
|
||||
FieldLabel,
|
||||
Fieldset,
|
||||
FieldTextArea,
|
||||
FormButtonContainer,
|
||||
gray3,
|
||||
gray6,
|
||||
PrimaryButton,
|
||||
} from './Styles';
|
||||
import { gray3, gray6 } from './Styles';
|
||||
|
||||
import React from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { useForm } from 'react-hook-form';
|
||||
|
||||
import { Page } from './Page';
|
||||
import { QuestionData, getQuestion } from './QuestionsData';
|
||||
import { AnswerList } from './AnswerList';
|
||||
|
||||
type FormData = {
|
||||
content: string;
|
||||
};
|
||||
|
||||
export const QuestionPage = () => {
|
||||
const [question, setQuestion] = React.useState<QuestionData | null>(null);
|
||||
const { questionId } = useParams();
|
||||
const { register } = useForm<FormData>();
|
||||
React.useEffect(() => {
|
||||
const doGetQuestion = async (questionId: number) => {
|
||||
const foundQuestion = await getQuestion(questionId);
|
||||
|
@ -78,27 +63,6 @@ export const QuestionPage = () => {
|
|||
} on ${question.created.toLocaleDateString()} ${question.created.toLocaleTimeString()}`}
|
||||
</div>
|
||||
<AnswerList data={question.answers} />
|
||||
<form
|
||||
css={css`
|
||||
margin-top: 20px;
|
||||
`}
|
||||
>
|
||||
<Fieldset>
|
||||
<FieldContainer>
|
||||
<FieldLabel htmlFor="content">Your Answer</FieldLabel>
|
||||
<FieldTextArea
|
||||
{...register('content')}
|
||||
id="content"
|
||||
name="content"
|
||||
/>
|
||||
</FieldContainer>
|
||||
<FormButtonContainer>
|
||||
<PrimaryButton type="submit">
|
||||
Submit Your Answer
|
||||
</PrimaryButton>
|
||||
</FormButtonContainer>
|
||||
</Fieldset>
|
||||
</form>
|
||||
</React.Fragment>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import styled from '@emotion/styled';
|
||||
import { css } from '@emotion/react';
|
||||
|
||||
export const gray1 = '#383737';
|
||||
export const gray2 = '#5c5a5a';
|
||||
|
@ -34,70 +33,3 @@ export const PrimaryButton = styled.button`
|
|||
cursor: not-allowed;
|
||||
}
|
||||
`;
|
||||
|
||||
export const Fieldset = styled.fieldset`
|
||||
margin: 10px auto 0 auto;
|
||||
padding: 30px;
|
||||
width: 350px;
|
||||
background-color: ${gray6};
|
||||
border-radius: 4px;
|
||||
border: 1px solid ${gray5};
|
||||
box-shadow: 0 3px 5px 0 rgba(0, 0, 0, 0.16);
|
||||
`;
|
||||
|
||||
export const FieldContainer = styled.label`
|
||||
font-weight: 10px;
|
||||
`;
|
||||
|
||||
const baseFieldCSS = css`
|
||||
box-sizing: border-box;
|
||||
font-family: ${fontFamily};
|
||||
font-size: ${fontSize};
|
||||
margin-bottom: 5px;
|
||||
padding: 8px 10px;
|
||||
border: 1px solid ${gray5};
|
||||
border-radius: 3px;
|
||||
color: ${gray2};
|
||||
background-color: white;
|
||||
width: 100%;
|
||||
:focus {
|
||||
outline-color: ${gray5};
|
||||
}
|
||||
:disabled {
|
||||
background-color: ${gray6};
|
||||
}
|
||||
`;
|
||||
|
||||
export const FieldLabel = styled.label`
|
||||
font-weight: bold;
|
||||
`;
|
||||
|
||||
export const FieldInput = styled.input`
|
||||
${baseFieldCSS}
|
||||
`;
|
||||
|
||||
export const FieldTextArea = styled.textarea`
|
||||
${baseFieldCSS}
|
||||
height: 100px;
|
||||
`;
|
||||
|
||||
export const FieldError = styled.div`
|
||||
font-size: 12px;
|
||||
color: red;
|
||||
`;
|
||||
|
||||
export const FormButtonContainer = styled.div`
|
||||
margin: 30px 0px 0px 0px;
|
||||
padding: 20px 0px 0px 0px;
|
||||
border-top: 1px solid ${gray5};
|
||||
`;
|
||||
|
||||
export const SubmissionSussess = styled.div`
|
||||
margin-top: 10px;
|
||||
color: green;
|
||||
`;
|
||||
|
||||
export const SubmissionFailure = styled.div`
|
||||
margin-top: 10px;
|
||||
color: red;
|
||||
`;
|
||||
|
|
Loading…
Reference in New Issue