2019-09-24 14:01:58 +09:00
|
|
|
import React, {useState} 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-09-24 14:01:58 +09:00
|
|
|
import {sendQueryStatistics} from './util/analytics';
|
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';
|
2019-08-03 00:35:47 +09:00
|
|
|
|
2019-07-30 23:27:28 +09:00
|
|
|
export default function App() {
|
2019-09-17 14:30:26 +09:00
|
|
|
const [query, setQuery] = useState('');
|
|
|
|
const {t} = useTranslation();
|
2019-08-03 00:45:13 +09:00
|
|
|
|
2019-09-02 19:41:44 +09:00
|
|
|
function onQuery(query: string) {
|
2019-09-17 14:30:26 +09:00
|
|
|
setQuery(query);
|
2019-09-24 13:55:07 +09:00
|
|
|
sendQueryStatistics(query.length);
|
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
|
|
|
<>
|
|
|
|
<GlobalStyle />
|
2019-08-03 13:36:29 +09:00
|
|
|
<Helmet>
|
2019-08-14 13:04:34 +09:00
|
|
|
<title>namae — {t('title')}</title>
|
2019-08-03 13:36:29 +09:00
|
|
|
</Helmet>
|
2019-08-02 04:23:21 +09:00
|
|
|
<Header>
|
2019-09-02 19:41:44 +09:00
|
|
|
<Form onQuery={onQuery} />
|
2019-08-02 04:23:21 +09:00
|
|
|
</Header>
|
2019-08-01 02:01:20 +09:00
|
|
|
<Content>
|
2019-09-02 19:41:44 +09:00
|
|
|
{query !== '' ? (
|
|
|
|
<Cards query={query} />
|
2019-08-07 17:42:07 +09:00
|
|
|
) : (
|
|
|
|
!isStandalone() && <Welcome />
|
|
|
|
)}
|
2019-08-01 02:01:20 +09:00
|
|
|
</Content>
|
2019-08-07 17:42:07 +09:00
|
|
|
<Footer />
|
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
|
|
|
`;
|