badgen.net/components/badge-examples.tsx

113 wiersze
2.6 KiB
TypeScript
Czysty Zwykły widok Historia

/* eslint-disable @next/next/no-img-element */
2018-10-15 09:33:58 +00:00
export default ({ data }) => {
2019-06-02 02:40:29 +00:00
return data.map(({ id, title, examples }) => (
<dl id={id} key={title}>
2018-10-18 08:38:13 +00:00
<dt>
2019-08-24 08:24:46 +00:00
{id
? <a className='title' href={`#${id}`}>{title}</a>
2019-08-24 08:24:46 +00:00
: <span className='title'>{title}</span>}
{id && <a className='doc' href={`/${id}`}>?</a>}
2018-10-18 08:38:13 +00:00
</dt>
2019-05-25 12:19:11 +00:00
{
Object.entries(examples).map(([path, desc]) => (
<ExampleItem key={path} desc={desc} url={path} />
))
}
2022-12-31 08:23:34 +00:00
<style>{`
2018-09-20 09:52:16 +00:00
dl {
padding: 0 1em;
margin: 0 auto;
2018-10-15 09:33:58 +00:00
max-width: 920px;
2018-09-20 09:52:16 +00:00
}
dt {
margin-bottom: 1em;
padding-top: 1em;
border-bottom: 1px solid #DDD;
line-height: 2em;
}
2018-10-18 08:38:13 +00:00
a {
color: #333;
position: relative;
text-decoration: none;
font-family: Merriweather, serif;
}
a.title:hover:before {
content: '#';
font-family: Arial;
color: #ccc;
display: inline-block;
position: relative;
left: -0.8em;
2019-06-02 02:40:29 +00:00
top: -0.1em;
width: 0px;
2018-10-18 08:38:13 +00:00
}
a.doc {
background: #CCC;
text-align: center;
color: #FFF; font: 12px/17px verdana, sans-serif;
display: inline-block;
height: 16px;
width: 16px;
border-radius: 50%;
margin-left: 0.5em;
2019-06-02 02:40:29 +00:00
top: -1px;
2018-10-18 08:38:13 +00:00
}
a.doc:hover {
background-color: #AAA
}
2019-08-24 08:24:46 +00:00
`}
</style>
2018-09-20 09:52:16 +00:00
</dl>
))
}
2018-10-17 07:15:58 +00:00
const ExampleItem = ({ desc, url }) => (
<dd>
<b>{desc}</b>
2022-12-31 08:23:34 +00:00
<i><img alt={desc} src={url} /></i>
2018-10-17 07:15:58 +00:00
<span><a href={url}>{url}</a></span>
2022-12-31 08:23:34 +00:00
<style>{`
2018-10-17 07:15:58 +00:00
dd {
font: 14px/20px sans-serif;
vertical-align: top;
height: 28px;
white-space: nowrap;
margin: 0;
}
b {
display: inline-block;
2019-07-06 10:40:01 +00:00
width: 17em;
2018-10-17 07:15:58 +00:00
font-family: Roboto,-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif;
text-align: right;
2019-06-21 14:56:45 +00:00
font-weight: 400;
color: #777;
2018-10-17 07:15:58 +00:00
}
i {
display: inline-block;
2019-07-06 10:40:01 +00:00
min-width: 200px;
2018-10-17 07:15:58 +00:00
}
img {
vertical-align: top;
height: 20px;
margin: 0 10px;
}
span {
2019-06-21 15:27:57 +00:00
font-family: Roboto Mono, SF Mono, Consolas, monospace;
2018-10-17 07:15:58 +00:00
}
2018-10-22 08:44:14 +00:00
a {
color: #06D;
}
a:hover {
text-decoration: underline;
}
2018-10-17 07:15:58 +00:00
@media (max-width: 600px) {
span {
display: none;
}
}
2019-08-24 08:24:46 +00:00
`}
</style>
2018-10-17 07:15:58 +00:00
</dd>
)