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
|
@ -3,6 +3,8 @@
|
|||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@emotion/react": "^11.8.2",
|
||||
"@emotion/styled": "^11.8.1",
|
||||
"@testing-library/jest-dom": "^5.16.2",
|
||||
"@testing-library/react": "^12.1.4",
|
||||
"@testing-library/user-event": "^13.5.0",
|
||||
|
@ -10,8 +12,10 @@
|
|||
"@types/node": "^16.11.26",
|
||||
"@types/react": "^17.0.41",
|
||||
"@types/react-dom": "^17.0.14",
|
||||
"history": "^5.3.0",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-router-dom": "^6.2.2",
|
||||
"react-scripts": "5.0.0",
|
||||
"typescript": "^4.6.2",
|
||||
"web-vitals": "^2.1.4"
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
|
||||
import React from 'react';
|
||||
import { AnswerData } from './QuestionsData';
|
||||
import { gray3 } from './Styles';
|
||||
|
||||
interface Props {
|
||||
data: AnswerData;
|
||||
}
|
||||
|
||||
export const Answer = ({ data }: Props) => (
|
||||
<div
|
||||
css={css`
|
||||
padding: 10px 0px;
|
||||
`}
|
||||
>
|
||||
<div
|
||||
css={css`
|
||||
padding: 10px 0px;
|
||||
font-size: 13px;
|
||||
`}
|
||||
>
|
||||
{data.content}
|
||||
</div>
|
||||
<div
|
||||
css={css`
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
color: ${gray3};
|
||||
`}
|
||||
>
|
||||
{`Answered by ${
|
||||
data.userName
|
||||
} on ${data.created.toLocaleDateString()} ${data.created.toLocaleTimeString()}`}
|
||||
</div>
|
||||
</div>
|
||||
);
|
|
@ -0,0 +1,31 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
import React from 'react';
|
||||
import { AnswerData } from './QuestionsData';
|
||||
import { Answer } from './Answer';
|
||||
import { gray5 } from './Styles';
|
||||
|
||||
interface Props {
|
||||
data: AnswerData[];
|
||||
}
|
||||
|
||||
export const AnswerList = ({ data }: Props) => (
|
||||
<ul
|
||||
css={css`
|
||||
list-style: none;
|
||||
margin: 10px 0 0 0;
|
||||
padding: 0;
|
||||
`}
|
||||
>
|
||||
{data.map((answer) => (
|
||||
<li
|
||||
css={css`
|
||||
border-top: 1px solid ${gray5};
|
||||
`}
|
||||
key={answer.answertId}
|
||||
>
|
||||
<Answer data={answer} />
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
);
|
|
@ -1,38 +0,0 @@
|
|||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: no-preference) {
|
||||
.App-logo {
|
||||
animation: App-logo-spin infinite 20s linear;
|
||||
}
|
||||
}
|
||||
|
||||
.App-header {
|
||||
background-color: #282c34;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.App-link {
|
||||
color: #61dafb;
|
||||
}
|
||||
|
||||
@keyframes App-logo-spin {
|
||||
from {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
|
@ -1,21 +1,59 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
|
||||
import React from 'react';
|
||||
import { BrowserRouter, Routes, Route } from 'react-router-dom';
|
||||
|
||||
import { Header } from './Header';
|
||||
import './App.css';
|
||||
import { HomePage } from './HomePage';
|
||||
import { fontFamily, fontSize, gray2 } from './Styles';
|
||||
import { SearchPage } from './SearchPage';
|
||||
import { SignInPage } from './SignInPage';
|
||||
import { NotFoundPage } from './NotFoundPage';
|
||||
import { QuestionPage } from './QuestionPage';
|
||||
|
||||
const AskPage = React.lazy(() => import('./AskPage'));
|
||||
|
||||
function App() {
|
||||
return (
|
||||
<div className="App">
|
||||
<BrowserRouter>
|
||||
<Header />
|
||||
<HomePage />
|
||||
</div>
|
||||
<div
|
||||
css={css`
|
||||
font-family: ${fontFamily};
|
||||
font-size: ${fontSize};
|
||||
color: ${gray2};
|
||||
`}
|
||||
>
|
||||
<Routes>
|
||||
<Route path="" element={<HomePage />} />
|
||||
<Route path="search" element={<SearchPage />} />
|
||||
<Route
|
||||
path="ask"
|
||||
element={
|
||||
<React.Suspense
|
||||
fallback={
|
||||
<div
|
||||
css={css`
|
||||
margin-top: 100px;
|
||||
text-align: center;
|
||||
`}
|
||||
>
|
||||
Loading...
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<AskPage />
|
||||
</React.Suspense>
|
||||
}
|
||||
/>
|
||||
<Route path="signin" element={<SignInPage />} />
|
||||
<Route path="questions/:questionId" element={<QuestionPage />} />
|
||||
<Route path="*" element={<NotFoundPage />} />
|
||||
</Routes>
|
||||
</div>
|
||||
</BrowserRouter>
|
||||
);
|
||||
}
|
||||
|
||||
class ProblemComponent extends React.Component {
|
||||
render() {
|
||||
return <div ref="div" />;
|
||||
}
|
||||
}
|
||||
|
||||
export default App;
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
import React from 'react';
|
||||
import { Page } from './Page';
|
||||
|
||||
export const AskPage = () => <Page title="Ask a question">{null}</Page>;
|
||||
|
||||
export default AskPage;
|
|
@ -0,0 +1,13 @@
|
|||
.container {
|
||||
position: fixed;
|
||||
box-sizing: border-box;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 20px;
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid #e3e2e2;
|
||||
box-shadow: 0 3px 7px 0 rgba(110, 112, 114, 0.21);
|
||||
}
|
|
@ -1,13 +1,84 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
import React from 'react';
|
||||
import { UserIcon } from './Icons';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
export const Header = () => (
|
||||
<div>
|
||||
<a href="./">Q & A</a>
|
||||
<input type="text" placeholder="Search ..." />
|
||||
<a href="./signin">
|
||||
<UserIcon />
|
||||
<span>Sign In</span>
|
||||
</a>
|
||||
</div>
|
||||
);
|
||||
import { UserIcon } from './Icons';
|
||||
import { fontFamily, fontSize, gray1, gray2, gray5 } from './Styles';
|
||||
|
||||
export const Header = () => {
|
||||
const handleSearchInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
console.log(e.currentTarget.value);
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
css={css`
|
||||
position: fixed;
|
||||
box-sizing: border-box;
|
||||
top: 0;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 20px;
|
||||
background-color: #fff;
|
||||
border-bottom: 1px solid ${gray5};
|
||||
box-shadow: 0 3px 7px 0 rgba(100, 112, 114, 0.21);
|
||||
`}
|
||||
>
|
||||
<Link
|
||||
to="/"
|
||||
css={css`
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: ${gray1};
|
||||
text-decoration: none;
|
||||
`}
|
||||
>
|
||||
Q & A
|
||||
</Link>
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search ..."
|
||||
onChange={handleSearchInputChange}
|
||||
css={css`
|
||||
box-sizing: border-box;
|
||||
font-family: ${fontFamily};
|
||||
font-size: ${fontSize};
|
||||
padding: 8px 10px;
|
||||
border: 1px solid ${gray5};
|
||||
border-radius: 3px;
|
||||
color: ${gray2};
|
||||
background-color: white;
|
||||
width: 200px;
|
||||
height: 30px;
|
||||
:focus {
|
||||
outline-color: ${gray5};
|
||||
}
|
||||
`}
|
||||
/>
|
||||
<Link
|
||||
to="signin"
|
||||
css={css`
|
||||
font-family: ${fontFamily};
|
||||
font-size: ${fontSize};
|
||||
padding: 5px 10px;
|
||||
background-color: transparent;
|
||||
color: ${gray2};
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
:focus {
|
||||
outline-color: ${gray5};
|
||||
}
|
||||
span {
|
||||
margin-left: 7px;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<UserIcon />
|
||||
<span>Sign In</span>
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,13 +1,51 @@
|
|||
import React from 'react';
|
||||
import { QuestionList } from './QuestionList';
|
||||
import { getUnansweredQuestions } from './QuestionsData';
|
||||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
export const HomePage = () => (
|
||||
<div>
|
||||
<div>
|
||||
<h2>Unanswered Questions</h2>
|
||||
<button>Ask a question</button>
|
||||
</div>
|
||||
<QuestionList data={getUnansweredQuestions()} />
|
||||
</div>
|
||||
);
|
||||
import React from 'react';
|
||||
import { PageTitle } from './PageTitle';
|
||||
import { Page } from './Page';
|
||||
import { QuestionList } from './QuestionList';
|
||||
import { getUnansweredQuestions, QuestionData } from './QuestionsData';
|
||||
import { PrimaryButton } from './Styles';
|
||||
|
||||
export const HomePage = () => {
|
||||
const [questions, setQuestions] = React.useState<QuestionData[]>([]);
|
||||
const [questionsLoading, setQuestionsLoading] = React.useState(true);
|
||||
|
||||
React.useEffect(() => {
|
||||
const doGetUnansweredQuestion = async () => {
|
||||
const unanswereedQuestions = await getUnansweredQuestions();
|
||||
setQuestions(unanswereedQuestions);
|
||||
setQuestionsLoading(false);
|
||||
};
|
||||
doGetUnansweredQuestion();
|
||||
}, []);
|
||||
|
||||
const navigate = useNavigate();
|
||||
const handleAskQuestionClick = () => {
|
||||
navigate('ask');
|
||||
};
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<div
|
||||
css={css`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
`}
|
||||
>
|
||||
<PageTitle>Unanswered Questions</PageTitle>
|
||||
<PrimaryButton onClick={handleAskQuestionClick}>
|
||||
Ask a question
|
||||
</PrimaryButton>
|
||||
</div>
|
||||
{questionsLoading ? (
|
||||
<div>Loading...</div>
|
||||
) : (
|
||||
<QuestionList data={questions || []} />
|
||||
)}
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
|
||||
import React from 'react';
|
||||
import user from './user.svg';
|
||||
export const UserIcon = () => <img src={user} alt="User" width="12px" />;
|
||||
export const UserIcon = () => (
|
||||
<img
|
||||
src={user}
|
||||
alt="User"
|
||||
css={css`
|
||||
width: 12px;
|
||||
opacity: 0.6;
|
||||
`}
|
||||
/>
|
||||
);
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
import React from 'react';
|
||||
import { Page } from './Page';
|
||||
|
||||
export const NotFoundPage = () => <Page title="Page Not Found">{null}</Page>;
|
|
@ -0,0 +1,24 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
|
||||
import React from 'react';
|
||||
import { PageTitle } from './PageTitle';
|
||||
|
||||
interface Props {
|
||||
title?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export const Page = ({ title, children }: Props) => (
|
||||
<div
|
||||
css={css`
|
||||
margin: 50px auto 20px auto;
|
||||
padding: 30px 20px;
|
||||
max-width: 600px;
|
||||
`}
|
||||
>
|
||||
{title && <PageTitle>{title}</PageTitle>}
|
||||
{children}
|
||||
{/* Component nested within Page component will be rendere here */}
|
||||
</div>
|
||||
);
|
|
@ -0,0 +1,20 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
|
||||
import React from 'react';
|
||||
interface Props {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
export const PageTitle = ({ children }: Props) => (
|
||||
<h2
|
||||
css={css`
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
margin: 10px 0px 5px;
|
||||
text-align: center;
|
||||
text-transform: uppercase;
|
||||
`}
|
||||
>
|
||||
{children}
|
||||
</h2>
|
||||
);
|
|
@ -1,4 +1,9 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import React from 'react';
|
||||
|
||||
import { gray2, gray3 } from './Styles';
|
||||
import { QuestionData } from './QuestionsData';
|
||||
|
||||
interface Props {
|
||||
|
@ -8,15 +13,42 @@ interface Props {
|
|||
|
||||
export const Question = ({ data, showContent }: Props) => (
|
||||
<div>
|
||||
<div>{data.title}</div>
|
||||
<div
|
||||
css={css`
|
||||
padding: 10px 0px;
|
||||
font-size: 19px;
|
||||
`}
|
||||
>
|
||||
<Link
|
||||
css={css`
|
||||
text-decoration: none;
|
||||
color: ${gray2};
|
||||
`}
|
||||
to={`/questions/${data.questionId}`}
|
||||
>
|
||||
{data.title}
|
||||
</Link>
|
||||
</div>
|
||||
{showContent && (
|
||||
<div>
|
||||
<div
|
||||
css={css`
|
||||
padding-bottom: 10px;
|
||||
font-size: 15px;
|
||||
color: ${gray2};
|
||||
`}
|
||||
>
|
||||
{data.content.length > 50
|
||||
? `${data.content.substring(0, 50)}`
|
||||
: data.content}
|
||||
</div>
|
||||
)}
|
||||
<div>
|
||||
<div
|
||||
css={css`
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
color: ${gray3};
|
||||
`}
|
||||
>
|
||||
{`Ask by ${
|
||||
data.userName
|
||||
} on ${data.created.toLocaleDateString()} ${data.created.toLocaleTimeString()}`}
|
||||
|
|
|
@ -1,15 +1,38 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
|
||||
import React from 'react';
|
||||
import { Question } from './Question';
|
||||
import { QuestionData } from './QuestionsData';
|
||||
import { accent2, gray5 } from './Styles';
|
||||
|
||||
interface Props {
|
||||
data: QuestionData[];
|
||||
}
|
||||
|
||||
export const QuestionList = ({ data }: Props) => (
|
||||
<ul>
|
||||
<ul
|
||||
css={css`
|
||||
list-style: none;
|
||||
margin: 10px 0 0 0;
|
||||
padding: 0px 20px;
|
||||
background-color: #fff;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
border-top: 3px solid ${accent2};
|
||||
box-shadow: 0 3px 5px 0 rgba(0, 0, 0, 0.16);
|
||||
`}
|
||||
>
|
||||
{data.map((question) => (
|
||||
<li key={question.questionId}>
|
||||
<li
|
||||
key={question.questionId}
|
||||
css={css`
|
||||
border-top: 1px solid ${gray5};
|
||||
:first-of-type {
|
||||
border-top: none;
|
||||
}
|
||||
`}
|
||||
>
|
||||
<Question data={question} />
|
||||
</li>
|
||||
))}
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
import { gray3, gray6 } from './Styles';
|
||||
|
||||
import React from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
|
||||
import { Page } from './Page';
|
||||
import { QuestionData, getQuestion } from './QuestionsData';
|
||||
import { AnswerList } from './AnswerList';
|
||||
|
||||
export const QuestionPage = () => {
|
||||
const [question, setQuestion] = React.useState<QuestionData | null>(null);
|
||||
const { questionId } = useParams();
|
||||
React.useEffect(() => {
|
||||
const doGetQuestion = async (questionId: number) => {
|
||||
const foundQuestion = await getQuestion(questionId);
|
||||
setQuestion(foundQuestion);
|
||||
};
|
||||
if (questionId) {
|
||||
doGetQuestion(Number(questionId));
|
||||
}
|
||||
}, [questionId]);
|
||||
return (
|
||||
<Page>
|
||||
<div
|
||||
css={css`
|
||||
background-color: white;
|
||||
padding: 15px 20px 20px 20px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid ${gray6};
|
||||
box-shadow: 0 3px 5px 0 rgba(0, 0, 0, 0.16);
|
||||
`}
|
||||
>
|
||||
<div
|
||||
css={css`
|
||||
font-size: 19px;
|
||||
font-weight: bold;
|
||||
margin: 10px 0px 5px;
|
||||
`}
|
||||
>
|
||||
{question === null ? '' : question.title}
|
||||
</div>
|
||||
{question !== null && (
|
||||
<React.Fragment>
|
||||
<p
|
||||
css={css`
|
||||
margin-top: 0px;
|
||||
background-color: white;
|
||||
`}
|
||||
>
|
||||
{question.content}
|
||||
</p>
|
||||
<div
|
||||
css={css`
|
||||
font-size: 12px;
|
||||
font-style: italic;
|
||||
color: ${gray3};
|
||||
`}
|
||||
>
|
||||
{`Asked by ${
|
||||
question.userName
|
||||
} on ${question.created.toLocaleDateString()} ${question.created.toLocaleTimeString()}`}
|
||||
</div>
|
||||
<AnswerList data={question.answers} />
|
||||
</React.Fragment>
|
||||
)}
|
||||
</div>
|
||||
Question Page {questionId}
|
||||
</Page>
|
||||
);
|
||||
};
|
|
@ -48,6 +48,30 @@ const questions: QuestionData[] = [
|
|||
},
|
||||
];
|
||||
|
||||
export const getUnansweredQuestions = (): QuestionData[] => {
|
||||
export const getUnansweredQuestions = async (): Promise<QuestionData[]> => {
|
||||
await wait(500);
|
||||
return questions.filter((q) => q.answers.length === 0);
|
||||
};
|
||||
|
||||
const wait = (ms: number): Promise<void> => {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
};
|
||||
|
||||
export const getQuestion = async (
|
||||
questionId: number,
|
||||
): Promise<QuestionData | null> => {
|
||||
await wait(500);
|
||||
const results = questions.filter((q) => q.questionId === questionId);
|
||||
return results.length === 0 ? null : results[0];
|
||||
};
|
||||
|
||||
export const searchQuestions = async (
|
||||
criteria: string,
|
||||
): Promise<QuestionData[]> => {
|
||||
await wait(500);
|
||||
return questions.filter(
|
||||
(q) =>
|
||||
q.title.toLowerCase().indexOf(criteria.toLowerCase()) >= 0 ||
|
||||
q.content.toLowerCase().indexOf(criteria.toLowerCase()) >= 0,
|
||||
);
|
||||
};
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/** @jsxImportSource @emotion/react */
|
||||
import { css } from '@emotion/react';
|
||||
|
||||
import React from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
|
||||
import { Page } from './Page';
|
||||
import { QuestionList } from './QuestionList';
|
||||
import { searchQuestions, QuestionData } from './QuestionsData';
|
||||
|
||||
export const SearchPage = () => {
|
||||
const [searchParams] = useSearchParams();
|
||||
const [questions, setQuestions] = React.useState<QuestionData[]>([]);
|
||||
const search = searchParams.get('criteria') || '';
|
||||
React.useEffect(() => {
|
||||
const doSearch = async (criteria: string) => {
|
||||
const foundResults = await searchQuestions(criteria);
|
||||
setQuestions(foundResults);
|
||||
};
|
||||
doSearch(search);
|
||||
}, [search]);
|
||||
|
||||
return (
|
||||
<Page title="Search Results">
|
||||
{search && (
|
||||
<p
|
||||
css={css`
|
||||
font-size: 16px;
|
||||
font-style: italic;
|
||||
margin-top: 0px;
|
||||
`}
|
||||
>
|
||||
<QuestionList data={questions} />
|
||||
</p>
|
||||
)}
|
||||
</Page>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,4 @@
|
|||
import React from 'react';
|
||||
import { Page } from './Page';
|
||||
|
||||
export const SignInPage = () => <Page title="Sign In">{null}</Page>;
|
|
@ -0,0 +1,35 @@
|
|||
import styled from '@emotion/styled';
|
||||
|
||||
export const gray1 = '#383737';
|
||||
export const gray2 = '#5c5a5a';
|
||||
export const gray3 = '#857c81';
|
||||
export const gray4 = '#b9b9b9';
|
||||
export const gray5 = '#e3e2e2';
|
||||
export const gray6 = '#f7f8fa';
|
||||
export const primary1 = '#681c41';
|
||||
export const primary2 = '#824c67';
|
||||
export const accent1 = '#dbb365';
|
||||
export const accent2 = '#efd197';
|
||||
export const fontFamily = "'Segoe UI', 'Helvetica Neue',sans-serif";
|
||||
export const fontSize = '16px';
|
||||
export const PrimaryButton = styled.button`
|
||||
background-color: ${primary2};
|
||||
border-color: ${primary2};
|
||||
border-style: solid;
|
||||
border-radius: 5px;
|
||||
font-family: ${fontFamily};
|
||||
font-family: ${fontSize};
|
||||
padding: 5px 10px;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
:hover {
|
||||
background-color: ${primary1};
|
||||
}
|
||||
:focus {
|
||||
outline-color: ${primary2};
|
||||
}
|
||||
:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
`;
|
|
@ -1,13 +1,4 @@
|
|||
body {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
||||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
||||
sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
code {
|
||||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
||||
monospace;
|
||||
background-color: #f7f8fa;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue