Skip to content

Instantly share code, notes, and snippets.

@Richienb
Created January 28, 2020 07:25
Show Gist options
  • Save Richienb/c1dcd2ffb174e003d1c0e7e8ea402dcb to your computer and use it in GitHub Desktop.
Save Richienb/c1dcd2ffb174e003d1c0e7e8ea402dcb to your computer and use it in GitHub Desktop.
Kve colour
const kve = require("kve")
const fontColourContrast = require("font-color-contrast")
const parseColour = require("parse-color")
kve.colour = (object) => {
const { hex } = parseColour(object)
const fontColour = fontColourContrast(hex)
const html = `
<style>
.item {
background-color: ${hex};
height: 10rem;
display: flex;
align-items: flex-end;
font-size: 2em;
padding: 1.5rem;
color: ${fontColour};
}
</style>
<main class="item">
${object}
</main>
`
return kve({color: object}, { html, title: "Colour Viewer" })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment