Created
April 21, 2016 15:59
-
-
Save Nasawa/a0f7ea2ddfc2dcbf87ab65a3203ee77c to your computer and use it in GitHub Desktop.
Hain Color Plugin
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
'use strict'; | |
function h(c) | |
{ | |
var r = parseInt(c[0]+c[1], 16); | |
var g = parseInt(c[2]+c[3], 16); | |
var b = parseInt(c[4]+c[5], 16); | |
return `rgb(${r}, ${g}, ${b})`.replace(/NaN/g, '0'); | |
} | |
module.exports = (context) => | |
{ | |
function search(query, res) | |
{ | |
res.add( | |
{ | |
title: "Color: #"+query+" <span style='width:100px;height:100px;background-color:#"+query+"'> </span> "+h(query), | |
desc: "<span style='width:100px;height:100px;background-color:#"+query+"'> </span>" | |
}); | |
} | |
return {search}; | |
}; |
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
{ | |
"name": "hain-plugin-colors", | |
"version": "1.0.0", | |
"description": "Hain plugin to show Hex colors", | |
"main": "index.js", | |
"keywords": [ | |
"hain-0.1.0", | |
"hain", | |
"colors", | |
"hain-plugin-colors" | |
], | |
"hain": { | |
"prefix": "#", | |
"usage": "enter a hex color starting with #", | |
"icon": "#fa fa-paint-brush", | |
"redirect": "/g" | |
}, | |
"author": "Nasawa", | |
"license": "ISC" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment