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

153 lines
3.6 KiB
JavaScript
Raw Normal View History

2019-07-27 19:18:54 +09:00
import React from 'react'
import styled, { createGlobalStyle } from 'styled-components'
2019-07-31 03:43:13 +09:00
2019-07-30 23:27:28 +09:00
import { useDeferredState } from './hooks/state'
2019-07-31 04:42:54 +09:00
import { mobile } from './util/css'
2019-08-02 04:23:21 +09:00
import { isStandalone } from './util/pwa'
2019-08-01 13:21:23 +09:00
import Welcome from './components/Welcome'
2019-07-31 13:57:48 +09:00
import Footer from './components/Footer'
2019-08-01 13:21:23 +09:00
import { Cards, CardContainer } from './components/Cards'
2019-07-31 12:22:31 +09:00
import GithubCard from './components/cards/GithubCard'
import DomainCard from './components/cards/DomainCard'
import HomebrewCard from './components/cards/HomebrewCard'
import TwitterCard from './components/cards/TwitterCard'
import SlackCard from './components/cards/SlackCard'
import NpmCard from './components/cards/NpmCard'
import JsOrgCard from './components/cards/JsOrgCard'
import PypiCard from './components/cards/PypiCard'
import S3Card from './components/cards/S3Card'
import CratesioCard from './components/cards/CratesioCard'
2019-08-02 16:27:05 +09:00
import RubyGemsCard from './components/cards/RubyGemsCard'
2019-08-01 01:10:09 +09:00
import { EventReporter } from './components/Analytics'
2019-07-27 19:18:54 +09:00
2019-07-30 23:27:28 +09:00
export default function App() {
const [query, setQuery] = useDeferredState(1000)
2019-07-27 19:18:54 +09:00
function onChange(e) {
setQuery(e.target.value)
}
2019-08-01 02:22:20 +09:00
const queryGiven = query && query.length > 0
2019-07-27 19:18:54 +09:00
return (
<>
<GlobalStyle />
2019-08-02 04:23:21 +09:00
<Header>
<InputContainer>
<Logo>namæ</Logo>
<Input onChange={onChange} />
</InputContainer>
</Header>
<Content>
2019-08-01 13:21:23 +09:00
{queryGiven ? (
<Cards>
<CardContainer>
<DomainCard name={query} />
<GithubCard name={query} />
<NpmCard name={query} />
2019-08-01 14:40:43 +09:00
<JsOrgCard name={query} />
<PypiCard name={query} />
<CratesioCard name={query} />
2019-08-02 16:27:05 +09:00
<RubyGemsCard name={query} />
2019-08-01 14:40:43 +09:00
<HomebrewCard name={query} />
<TwitterCard name={query} />
<SlackCard name={query} />
<S3Card name={query} />
</CardContainer>
<EventReporter query={query} />
</Cards>
2019-08-02 04:23:21 +09:00
) : !isStandalone() ? (
2019-08-01 13:21:23 +09:00
<Welcome />
2019-08-02 04:23:21 +09:00
) : null}
{!isStandalone() ? <Footer /> : null}
</Content>
</>
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
}
`
const InputContainer = styled.div`
transform: translateY(40px);
padding: 20px;
background: #ffffff;
2019-08-01 13:21:23 +09:00
box-shadow: 0 10px 20px 0 #c7dcf7;
border-radius: 20px;
2019-08-01 01:48:55 +09:00
${mobile} {
transform: translateY(20px);
}
2019-07-31 00:26:49 +09:00
`
2019-07-31 03:43:13 +09:00
const Logo = styled.div`
2019-07-31 10:36:54 +09:00
margin-bottom: 5px;
2019-08-01 01:48:55 +09:00
text-align: center;
2019-07-31 03:43:13 +09:00
font-family: sans-serif;
font-weight: bold;
2019-08-01 01:48:55 +09:00
font-size: 20px;
color: #4a90e2;
${mobile} {
font-size: 15px;
}
2019-07-31 03:43:13 +09:00
`
2019-07-31 12:22:31 +09:00
const Input = styled.input.attrs({
type: 'text',
2019-08-01 13:21:23 +09:00
placeholder: 'search',
2019-07-31 12:22:31 +09:00
autocomplete: 'off',
autocorrect: 'off',
autocapitalize: 'off',
spellcheck: 'false',
})`
2019-07-30 23:27:28 +09:00
width: 100%;
2019-08-01 13:21:23 +09:00
border: none;
2019-07-30 23:27:28 +09:00
outline: none;
2019-07-31 03:52:17 +09:00
text-align: center;
2019-07-30 23:27:28 +09:00
font-family: monospace;
2019-08-01 13:21:23 +09:00
font-size: 5rem;
2019-07-31 03:43:13 +09:00
2019-07-31 12:22:31 +09:00
${mobile} {
2019-08-01 14:00:22 +09:00
font-size: 2rem;
2019-07-31 12:22:31 +09:00
}
2019-07-31 03:43:13 +09:00
`