badgen.net/components/builder-hints.tsx

84 wiersze
2.3 KiB
TypeScript
Czysty Zwykły widok Historia

2023-03-18 08:57:24 +00:00
/* eslint-disable @next/next/no-html-link-for-pages */
2019-10-04 12:45:52 +00:00
import * as CSS from 'csstype'
2023-01-04 01:31:10 +00:00
import Link from 'next/link'
2019-10-04 12:45:52 +00:00
2019-08-30 03:22:22 +00:00
export default function BuilderHints ({ focus, badgeURL }) {
2018-10-19 05:06:41 +00:00
const visible = !focus && !badgeURL
2019-10-04 12:45:52 +00:00
const style: CSS.Properties = {
2018-10-19 05:06:41 +00:00
opacity: visible ? 1 : 0,
pointerEvents: visible ? 'auto' : 'none'
}
return (
<div className='hints' style={style}>
<Hint left={0} width={50} height={3}>
2024-03-03 16:18:07 +00:00
<a href='/help#generators'>GENERATOR (static or live badge)</a>
2018-10-19 05:06:41 +00:00
</Hint>
<Hint left={66} width={70} height={2}>TEXT</Hint>
<Hint left={153} width={60} height={2}>TEXT</Hint>
2018-10-26 07:10:23 +00:00
<Hint left={230} width={50} height={2}>
2023-03-18 08:57:24 +00:00
<a href='/help#colors'>COLOR (optional)</a>
2018-10-26 07:10:23 +00:00
</Hint>
<Hint left={290} width={110} height={1}>
2023-03-18 08:57:24 +00:00
<a className='sd' href='/help#options'>OPTIONS (icon, label, etc.)</a>
2018-10-26 07:10:23 +00:00
</Hint>
2023-01-04 01:31:10 +00:00
<style jsx>{`
2018-10-19 05:06:41 +00:00
.hints {
position: relative;
overflow: visible;
width: 100%;
left: -147px;
/* height: 200px; */
2018-10-19 05:06:41 +00:00
transition: all 200ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
2023-01-04 01:31:10 +00:00
.hint a {
2018-10-26 07:10:23 +00:00
color: #333;
}
2023-03-18 08:57:24 +00:00
a:hover {
border-bottom: 1px dashed #333 !important;
2019-06-02 05:31:09 +00:00
text-decoration: none;
2018-10-26 07:10:23 +00:00
}
2019-08-24 08:24:46 +00:00
`}
</style>
2018-10-19 05:06:41 +00:00
</div>
)
}
2018-10-26 07:10:23 +00:00
const Hint = ({ left, width, height, children, align = 'left' }) => {
2019-10-04 12:45:52 +00:00
const wrapperPos: CSS.Properties = {
2018-10-19 05:06:41 +00:00
left: `calc(50% + ${left}px)`,
height: `${height * 54}px`,
2018-10-26 07:10:23 +00:00
width: `${width}px`,
2022-05-24 10:47:23 +00:00
textAlign: align as CSS.Property.TextAlign
2018-10-19 05:06:41 +00:00
}
return (
<div className='hint' style={wrapperPos}>
<div className='line' />
<div className='content'>{children}</div>
2022-12-31 08:23:34 +00:00
<style>{`
2018-10-19 05:06:41 +00:00
.hint {
border-top: 2px solid #666;
position: absolute;
}
.line {
border-left: 2px solid #666;
height: calc(100% - 26px);
left: calc(50% - 1px);
position: relative;
}
.content {
min-width: 100%;
text-align: center;
position: absolute;
bottom: 0;
left: 0;
white-space: nowrap;
font: 16px/24px monospace;
2018-10-26 07:10:23 +00:00
height: 24px;
2018-10-19 05:06:41 +00:00
color: #333;
}
2019-08-24 08:24:46 +00:00
`}
</style>
2018-10-19 05:06:41 +00:00
</div>
)
}