badgen.net/components/badgen-title.tsx

115 wiersze
2.9 KiB
TypeScript
Czysty Zwykły widok Historia

2019-06-02 06:11:51 +00:00
import Link from 'next/link'
2022-12-31 08:23:34 +00:00
import Image from 'next/image'
2019-06-02 06:11:51 +00:00
2023-01-04 01:31:10 +00:00
// import { Merriweather } from '@next/font/google'
2022-12-31 08:23:34 +00:00
2023-01-04 01:31:10 +00:00
// const merriweather = Merriweather({ subsets: ['latin'], weight: ["300", "700"] })
2022-12-31 08:23:34 +00:00
export default function BadgenTitle ({ host }) {
2019-06-02 06:11:51 +00:00
return (
<div className='title-block'>
2023-01-04 01:31:10 +00:00
<div className='title'>
2019-06-02 06:11:51 +00:00
<h1>
<Image className='badgen-icon' alt='badgen logo' src='/statics/badgen-logo.svg' width='42' height='42' />
2023-01-04 01:31:10 +00:00
<span className='badgen-name'>Badgen</span>
2019-06-02 06:11:51 +00:00
<StyleSwitch host={host} />
</h1>
2022-12-31 08:23:34 +00:00
<div>Fast badge generating service</div>
2019-06-02 06:11:51 +00:00
</div>
2022-12-31 10:37:29 +00:00
<style jsx>{`
2019-06-02 06:11:51 +00:00
.title-block {
width: 100%;
height: 260px;
2019-06-02 06:11:51 +00:00
position: relative;
}
.title {
position: absolute;
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
transition: all 200ms ease-out;
}
.title.hidden {
opacity: 0;
transform: translateY(-20px);
}
.title.show {
transition-delay: 100ms;
}
.title h1 {
color: #333;
height: 52px;
2023-01-04 01:31:10 +00:00
width: 240px;
2019-06-02 06:11:51 +00:00
position: relative;
}
2023-01-04 01:31:10 +00:00
.title .badgen-name {
font: 50px/46px Merriweather, Georgia, serif;
font-weight: 700;
display: inline;
margin-left: 5px;
position: relative;
top: -2px;
2022-12-31 08:23:34 +00:00
}
.title div {
font: 20px/32px Merriweather, Georgia, serif;
2019-06-02 06:11:51 +00:00
font-weight: 300;
letter-spacing: 0.3px;
color: #333;
2022-12-31 08:23:34 +00:00
margin-top: 10px;
2019-06-02 06:11:51 +00:00
}
2019-08-24 08:24:46 +00:00
`}
</style>
2019-06-02 06:11:51 +00:00
</div>
)
}
const StyleSwitch = ({ host }) => {
if (!host) return null
return (
2022-12-31 10:37:29 +00:00
<div className='style-switch'>
2019-08-24 08:24:46 +00:00
{host.includes('https://flat.') ? [
2022-12-31 08:23:34 +00:00
<Link key='2' href='https://flat.badgen.net'>FLAT</Link>,
<Link key='1' href='https://badgen.net'>CLASSIC</Link>
2019-06-02 06:11:51 +00:00
] : [
2022-12-31 08:23:34 +00:00
<Link key='1' href='https://badgen.net'>CLASSIC</Link>,
<Link key='2' href='https://flat.badgen.net'>FLAT</Link>
2019-08-24 08:24:46 +00:00
]}
2022-12-31 08:23:34 +00:00
<style>{`
2019-06-02 06:11:51 +00:00
.style-switch {
position: absolute;
box-sizing: border-box;
top: -2px;
left: 235px;
height: 26px;
font: 16px/26px sans-serif;
overflow: hidden;
}
2022-12-31 10:37:29 +00:00
.style-switch a {
2019-06-02 06:11:51 +00:00
color: #999;
display: block;
line-height: 26px;
padding: 1px 3px;
}
2022-12-31 10:37:29 +00:00
.style-switch a:first-child {
2019-06-02 06:11:51 +00:00
margin-top: 0;
transition: all 200ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
.style-switch:hover a:first-child {
margin-top: -26px;
}
2022-12-31 10:37:29 +00:00
.style-switch a:focus {
2019-06-02 06:11:51 +00:00
outline: none;
color: #08C;
}
2019-08-24 08:24:46 +00:00
`}
</style>
2022-12-31 10:37:29 +00:00
</div>
2019-06-02 06:11:51 +00:00
)
}