Gathering detailed insights and metrics for @iantomarcello/prisma-colour
Gathering detailed insights and metrics for @iantomarcello/prisma-colour
Gathering detailed insights and metrics for @iantomarcello/prisma-colour
Gathering detailed insights and metrics for @iantomarcello/prisma-colour
npm install @iantomarcello/prisma-colour
Typescript
Module System
Node Version
NPM Version
71.6
Supply Chain
98.8
Quality
75.3
Maintenance
100
Vulnerability
100
License
HTML (53.16%)
JavaScript (46.84%)
Total Downloads
1,027
Last Day
1
Last Week
6
Last Month
8
Last Year
103
22 Commits
2 Watching
1 Branches
1 Contributors
Latest Version
1.0.3
Package Id
@iantomarcello/prisma-colour@1.0.3
Unpacked Size
35.83 kB
Size
8.14 kB
File Count
7
NPM Version
6.14.9
Node Version
14.15.3
Cumulative downloads
Total Downloads
Last day
0%
1
Compared to previous day
Last week
0%
6
Compared to previous week
Last month
166.7%
8
Compared to previous month
Last year
-44%
103
Compared to previous year
2
Prisma, which means prism in Malay, is a simple chainable colour converter in JS that outputs CSS colour values like the lovely hex colours and rgb.
Here's how it works:
1import PrismaColour from '@iantomarcello/prisma-colour'; 2const red = '#ff0000'; 3const pink = new PrismaColour(red).lighten(40).getHex(); // #fecccc 4const transparentRed = new PrismaColour(red).fadeOut(75).getHex(); // #ff000040. 5const darkOrange = new PrismaColour(red).spin(40).darken(15).getHex(); // #b27600. 6const fullCircle = new PrismaColour(red).spin(180).spin(180).getHex(); // #ff0000
Well this looks familliar...
Yup, its kinda similar to how colour function of css preprocessors like LESS works. The
code is based on that.
Why chainable tho...?
I find the nesting methods of like the preprocessors to be bulky.
Say, I wanna lighten something, then saturate it, then fade it a little, for the the preprocessors, it would look like this:
1// If it looked like CSS preprocessors. 2const bulky = SomeOtherLibraryMaybe.fade(saturate(lighten('#ff0000', 15) 15) 15); // #ff4b4bd9
Making it chainable would make it more readible.
1// 🔗🔗🔗 2const chaining = new PrismaColour('#ff0000') 3 .lighten(15) // #fe4c4c 4 .saturate(15) //#ff4b4b 5 .fade(15).getHex(); //#ff4b4bd9
Like a prism, to get output colour, you must provide an input colour.
1import PrismaColour from '@iantomarcello/prisma-colour'; 2const inputColour = '#ff0000'; 3let changeIt = new PrismaColour(inputColour); 4// inputColour is ready to be converted.
Operations are chainable methods which converts the colour. Chainable meaning it always returns it self. To output the colours, see Output Methods below.
Sets colour's opacity to said amount regardless of input's opacity.
Increases colour's opacity by said amount.
Decreases colour's opacity by said amount.
Rotate the hue angle of a colour by amount in degrees.
Increases colour's lightness in the HSL colour space by said amount.
Decreases colour's lightness in the HSL colour space by said amount.
Increases colour's saturation in the HSL colour space by said amount.
Decreases colour's saturation in the HSL colour space by said amount.
Output methods are end of the chain methods that returns the colour is CSS values of preferred format.
RGB and HSL methods have newer space separated notation variant, which be be outputted by setting the spacing
param to space
. By default it outputs the good old comma
.
Returns colour in Hex representation.
If the colour had alpha, it will output the transparency as well.
Returns colour in RGB, regardless of transparency.
Returns colour in RGBA, inclusive of transparency.
Returns colour in HSL, regardless of transparency.
Returns colour in HSLA, inclusive of transparency.
Returns a copy of this PrismaColour instance including operated colour.
You can clone at anytime during operation.
You can use it somewhere like in Tailwind CSS to generate the colour dynamically.
1// tailwind.config.js 2const PrismaColour = require('./build/cjs/prisma-colour.js'); 3const BLUE = '#1b61e4'; 4 5// Generating a complementary 'primary' and 'secondary' colour scheme. 6module.exports = { 7 theme: { 8 extend: { 9 colors: { 10 primary: { 11 '100': new PrismaColour(BLUE).lighten(20).getHex(), 12 '200': new PrismaColour(BLUE).lighten(15).getHex(), 13 '300': new PrismaColour(BLUE).lighten(10).getHex(), 14 '400': new PrismaColour(BLUE).lighten(5).getHex(), 15 '500': new PrismaColour(BLUE).lighten(0).getHex(), 16 '600': new PrismaColour(BLUE).darken(5).getHex(), 17 '700': new PrismaColour(BLUE).darken(10).getHex(), 18 '800': new PrismaColour(BLUE).darken(15).getHex(), 19 '900': new PrismaColour(BLUE).darken(20).getHex(), 20 }, 21 secondary: { 22 '100': new PrismaColour(BLUE).spin(180).lighten(20).getHex(), 23 '200': new PrismaColour(BLUE).spin(180).lighten(15).getHex(), 24 '300': new PrismaColour(BLUE).spin(180).lighten(10).getHex(), 25 '400': new PrismaColour(BLUE).spin(180).lighten(5).getHex(), 26 '500': new PrismaColour(BLUE).spin(180).lighten(0).getHex(), 27 '600': new PrismaColour(BLUE).spin(180).darken(5).getHex(), 28 '700': new PrismaColour(BLUE).spin(180).darken(10).getHex(), 29 '800': new PrismaColour(BLUE).spin(180).darken(15).getHex(), 30 '900': new PrismaColour(BLUE).spin(180).darken(20).getHex(), 31 } 32 } 33 }, 34 }, 35}
Or in a Lit Element to create a better interactive styling.
1import { LitElement, html, css, unsafeCSS } from 'lit-element'; 2import PrismaColour from './build/esm/prisma-colour.js'; 3 4const RED = 'rgb(195, 50, 50)'; // red 5 6class HoverMeButton extends LitElement { 7 static get styles() { 8 return [ 9 css` 10 :host() { 11 display: block; 12 } 13 14 button { 15 padding: 14px 23px; 16 border: 0; 17 border-radius: 3px; 18 background: ${unsafeCSS(RED)}; 19 color: black; 20 transition: background 0.2s ease-out; 21 cursor: pointer; 22 } 23 24 /* Hover to for softer red */ 25 button:hover { 26 background: ${unsafeCSS( 27 new PrismaColour(RED).lighten(17).getRGB() 28 )}; 29 } 30 `, 31 ]; 32 } 33 34 render() { 35 return html` 36 <button type="button">Hover Me</button> 37 `; 38 } 39} 40customElements.define('hover-me-button', HoverMeButton); 41
This is a colour converter and has nothing to do with the database toolkit, Prisma.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
2 existing vulnerabilities detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More