import icons from 'badgen-icons'
export default function HomeIntro ({ isFlat }) {
return (
{explainCode(isFlat)}
Builtin color names
{colorExamples()}
Builtin icons
{iconExamples()}
Options
-
color
Override default badge color.
e.g.
-
icon
Use builtin icon (or url for external icon) in front of subject text.
e.g.
-
list
Set list=|
will replace ,
with |
in status text.
e.g.
-
label
Override default subject text (URL-Encoding needed for spaces or special characters).
e.g.
-
labelColor
Override default label color.
e.g.
Advanced usage
-
/runkit
create arbitrary live badge with RunKit's online IDE.
-
/https
turn an api endpoint into a svg live badge.
)}
const colorExamples = () => {
const colors = ['blue', 'cyan', 'green', 'yellow', 'orange', 'red', 'pink', 'purple', 'grey', 'black']
return colors.map(c => (
))
}
const iconExamples = () => {
return Object.keys(icons).map(icon => {
const url = `/badge/icon/${icon}?icon=${icon}&label`
return (
)
})
}
const explainCode = (isFlat) => {
const text = `
https://badgen.net/badge/:subject/:status/:color?icon=github
──┬── ───┬─── ──┬─── ──┬── ────┬──────
│ │ │ │ └─ Options (label, list, icon, color)
│ │ │ │
│ TEXT TEXT RGB / COLOR_NAME ( optional )
│
"badge" - default (static) badge generator`
if (isFlat) {
return text
.replace('badgen.net', 'flat.badgen.net')
.replace(/\n/g, '\n ')
.trim()
} else {
return text.trim()
}
}