badgen.net/components/builder-hints.js

81 wiersze
2.1 KiB
JavaScript
Czysty Zwykły widok Historia

2018-10-19 05:06:41 +00:00
export default ({ focus, badgeURL }) => {
const visible = !focus && !badgeURL
const style = {
opacity: visible ? 1 : 0,
pointerEvents: visible ? 'auto' : 'none'
}
return (
<div className='hints' style={style}>
<Hint left={0} width={50} height={3}>
2018-10-26 07:19:09 +00:00
<div style={{ textAlign: 'left', marginBottom: '2em' }}>
2018-12-17 02:51:00 +00:00
SERVICE_NAME (
<a href='/gallery/static'>static badge</a> / <a href='/gallery/live'>live badge</a>)
2018-10-26 07:10:23 +00:00
</div>
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}>
2018-12-17 02:51:00 +00:00
&nbsp;RGB / <a href='/docs/help#colors'>COLOR_NAME</a> (optional)
2018-10-26 07:10:23 +00:00
</Hint>
<Hint left={290} width={110} height={1}>
2018-12-17 02:51:00 +00:00
<a href='/docs/help#options'>OPTIONS (icon, label, etc.)</a>
2018-10-26 07:10:23 +00:00
</Hint>
2018-10-19 05:06:41 +00:00
<style jsx>{`
.hints {
height: 0;
position: relative;
overflow: visible;
width: 100%;
left: -147px;
transition: all 200ms cubic-bezier(0.215, 0.61, 0.355, 1);
}
2018-10-26 07:10:23 +00:00
a {
color: #333;
}
a:hover {
border-bottom: 1px dashed #333;
2018-10-26 07:10:23 +00:00
}
2018-10-19 05:06:41 +00:00
`}</style>
</div>
)
}
2018-10-26 07:10:23 +00:00
const Hint = ({ left, width, height, children, align = 'left' }) => {
2018-10-19 05:06:41 +00:00
const wrapperPos = {
left: `calc(50% + ${left}px)`,
height: `${height * 54}px`,
2018-10-26 07:10:23 +00:00
width: `${width}px`,
textAlign: align
2018-10-19 05:06:41 +00:00
}
return (
<div className='hint' style={wrapperPos}>
<div className='line' />
<div className='content'>{children}</div>
<style jsx>{`
.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;
}
`}</style>
</div>
)
}