2020-02-05 15:59:53 +09:00
|
|
|
import React from 'react';
|
2019-09-17 14:30:26 +09:00
|
|
|
import styled, {createGlobalStyle} from 'styled-components';
|
|
|
|
import {Helmet} from 'react-helmet';
|
|
|
|
import {useTranslation} from 'react-i18next';
|
2019-07-31 03:43:13 +09:00
|
|
|
|
2019-09-17 14:30:26 +09:00
|
|
|
import Welcome from './components/Welcome';
|
|
|
|
import Form from './components/Form';
|
|
|
|
import Cards from './components/cards';
|
|
|
|
import Footer from './components/Footer';
|
2019-07-27 19:18:54 +09:00
|
|
|
|
2019-09-17 14:30:26 +09:00
|
|
|
import {mobile} from './util/css';
|
|
|
|
import {isStandalone} from './util/pwa';
|
2020-02-05 15:59:53 +09:00
|
|
|
import {Switch, Route, useParams} from 'react-router-dom';
|
2019-08-03 00:35:47 +09:00
|
|
|
|
2019-07-30 23:27:28 +09:00
|
|
|
export default function App() {
|
2020-02-05 15:59:53 +09:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<GlobalStyle />
|
|
|
|
<Switch>
|
|
|
|
<Route path="/s/:query">
|
|
|
|
<Search />
|
|
|
|
</Route>
|
|
|
|
<Route path="/">
|
|
|
|
<Home />
|
|
|
|
</Route>
|
|
|
|
</Switch>
|
|
|
|
<Footer />
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2019-08-03 00:45:13 +09:00
|
|
|
|
2020-02-05 15:59:53 +09:00
|
|
|
function Search() {
|
|
|
|
const {query: currentQuery} = useParams<{query: string}>();
|
2019-08-03 16:44:48 +09:00
|
|
|
|
2019-07-27 19:18:54 +09:00
|
|
|
return (
|
2019-08-01 02:01:20 +09:00
|
|
|
<>
|
2019-08-03 13:36:29 +09:00
|
|
|
<Helmet>
|
2020-02-05 15:59:53 +09:00
|
|
|
<title>Search for "{currentQuery}" — namae</title>
|
2019-08-03 13:36:29 +09:00
|
|
|
</Helmet>
|
2019-08-02 04:23:21 +09:00
|
|
|
<Header>
|
2020-02-05 15:59:53 +09:00
|
|
|
<Form initialValue={currentQuery} />
|
2019-08-02 04:23:21 +09:00
|
|
|
</Header>
|
2019-08-01 02:01:20 +09:00
|
|
|
<Content>
|
2020-02-05 15:59:53 +09:00
|
|
|
<Cards query={currentQuery} />
|
2019-08-01 02:01:20 +09:00
|
|
|
</Content>
|
2020-02-05 15:59:53 +09:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function Home() {
|
|
|
|
const {t} = useTranslation();
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Helmet>
|
|
|
|
<title>namae — {t('title')}</title>
|
|
|
|
</Helmet>
|
|
|
|
<Header>
|
|
|
|
<Form />
|
|
|
|
</Header>
|
|
|
|
<Content>{!isStandalone() && <Welcome />}</Content>
|
2019-08-01 02:01:20 +09:00
|
|
|
</>
|
2019-09-17 14:30:26 +09:00
|
|
|
);
|
2019-07-27 19:18:54 +09:00
|
|
|
}
|
|
|
|
|
2019-08-01 02:01:20 +09:00
|
|
|
const GlobalStyle = createGlobalStyle`
|
2019-08-01 13:21:23 +09:00
|
|
|
* {
|
|
|
|
box-sizing: border-box;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
html {
|
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
|
2019-08-01 02:01:20 +09:00
|
|
|
body {
|
2019-08-01 13:21:23 +09:00
|
|
|
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;
|
2019-08-02 04:23:21 +09:00
|
|
|
background: #ffffff;
|
2019-09-17 14:30:26 +09:00
|
|
|
|
2019-08-02 04:23:21 +09:00
|
|
|
${mobile} {
|
|
|
|
background: #f5f5f5;
|
|
|
|
}
|
2019-08-01 02:01:20 +09:00
|
|
|
}
|
2019-09-17 14:30:26 +09:00
|
|
|
`;
|
2019-08-01 02:01:20 +09:00
|
|
|
|
2019-08-02 04:23:21 +09:00
|
|
|
const Content = styled.div`
|
2019-08-02 16:27:05 +09:00
|
|
|
padding-top: 100px;
|
2019-08-02 04:23:21 +09:00
|
|
|
|
|
|
|
${mobile} {
|
|
|
|
padding-top: 60px;
|
|
|
|
}
|
2019-09-17 14:30:26 +09:00
|
|
|
`;
|
2019-08-01 01:48:55 +09:00
|
|
|
|
2019-07-31 03:43:13 +09:00
|
|
|
const Header = styled.header`
|
2019-08-01 02:30:35 +09:00
|
|
|
padding: 0 40px;
|
2019-08-01 01:48:55 +09:00
|
|
|
background-image: linear-gradient(180deg, #a2d4ff 0%, #ac57ff 99%);
|
|
|
|
|
|
|
|
${mobile} {
|
2019-08-01 02:30:35 +09:00
|
|
|
padding: 0 20px;
|
2019-08-01 01:48:55 +09:00
|
|
|
}
|
2019-09-17 14:30:26 +09:00
|
|
|
`;
|