Created
January 28, 2020 07:25
-
-
Save Richienb/c1dcd2ffb174e003d1c0e7e8ea402dcb to your computer and use it in GitHub Desktop.
Kve colour
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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