1
0
mirror of https://github.com/uetchy/namae.git synced 2025-07-02 14:20:03 +09:00
namae/web/src/App.tsx

83 lines
1.6 KiB
TypeScript
Raw Normal View History

import React, { useState } from 'react'
import styled, { createGlobalStyle } from 'styled-components'
2019-08-03 13:36:29 +09:00
import { Helmet } from 'react-helmet'
import { useTranslation } from 'react-i18next'
2019-07-31 03:43:13 +09:00
2019-08-03 16:44:48 +09:00
import Welcome from './components/Welcome'
import Form from './components/Form'
import Cards from './components/cards'
2019-08-03 16:44:48 +09:00
import Footer from './components/Footer'
2019-07-27 19:18:54 +09:00
2019-08-03 00:35:47 +09:00
import { mobile } from './util/css'
import { isStandalone } from './util/pwa'
2019-07-30 23:27:28 +09:00
export default function App() {
const [query, setQuery] = useState('')
const { t } = useTranslation()
function onQuery(query: string) {
setQuery(query)
2019-08-03 16:44:48 +09:00
}
2019-07-27 19:18:54 +09:00
return (
<>
<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>
<Form onQuery={onQuery} />
2019-08-02 04:23:21 +09:00
</Header>
<Content>
{query !== '' ? (
<Cards query={query} />
2019-08-07 17:42:07 +09:00
) : (
!isStandalone() && <Welcome />
)}
</Content>
2019-08-07 17:42:07 +09:00
<Footer />
</>
2019-07-27 19:18:54 +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;
}
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;
${mobile} {
background: #f5f5f5;
}
}
`
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-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
}
`