
Research
/Security News
Popular Tinycolor npm Package Compromised in Supply Chain Attack Affecting 40+ Packages
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
theme-color-switch
Advanced tools
This a script to switch color specific styles less file and which you can use to change theme dynamically in browser
This a script to switch color specific styles less file and which you can use to change theme dynamically in browser.
Also you can use these less syntax functions for color conversion.
$ npm install theme-color-switch
Try out the demo
const less = require('theme-color-switch');
const colorSource = require('!raw-loader!./public/color.less'); // theme file content which generate by theme-color-generator
less.render(
colorSource,
{
modifyVars: {
'@theme-color': '#0035ff' // the variables in theme file which you want to change
},
},
function(e, output) {
if (e) {
console.error(`Failed to update theme`);
}
if (output && output.css) {
addCSS(output.css);
}
}
);
color.less
file with theme-color-generator ( as color.js
in example ) first, then toggle color with this package as Theme.js
in exampleNow you can change colors by modify less avriables as the example
如只想使用主题切换的,上面的内容就已完成。
Color
对象的可以使用toCSS()
属性来获取输出值。也可以作为下一个函数的颜色参数。Dimension
对象的可以作为number
类型传给下一个函数。import { shade, tint, fade } from 'theme-color-switch';
let shadeColor = shade('#007fff', '50%').toCSS();
let fadeAndTintColor = fade(tint('#007fff', '30%'), '10%').toCSS();
Returns: Color
Example: rgb(90, 129, 32)
Output: #5a8120
Returns: Color
Example: rgba(90, 129, 32, 0.5)
Output: rgba(90, 129, 32, 0.5)
Returns: Color
Example: argb(rgba(90, 23, 148, 0.5))
Output: #805a1794
Returns: Color
Example: hsl(90, 100%, 50%)
Output: #80ff00
Returns: Color
Example: hsla(90, 100%, 50%, 0.5)
Output: rgba(128, 255, 0, 0.5)
Returns: Color
Example: hsv(90, 100%, 50%)
Output: #408000
Returns: Color
Example: hsva(90, 100%, 50%, 0.5)
Output: rgba(64, 128, 0, 0.5)
Returns: Dimension
Example: hue(hsl(90, 100%, 50%))
Output: 90
Returns: Dimension
Example: saturation(hsl(90, 100%, 50%))
Output: 100%
Returns: Dimension
Example: lightness(hsl(90, 100%, 50%))
Output: 50%
Returns: Dimension
Example: hsvhue(hsv(90, 100%, 50%))
Output: 90
Returns: Dimension
Example: hsvsaturation(hsv(90, 100%, 50%))
Output: 100%
Returns: Dimension
Example: hsvhue(hsv(90, 100%, 50%))
Output: 90
Returns: Dimension
Example: red(rgb(10, 20, 30))
Output: 10
Returns: Dimension
Example: green(rgb(10, 20, 30))
Output: 20
Returns: Dimension
Example: blue(rgb(10, 20, 30))
Output: 30
Returns: Dimension
Example: alpha(rgba(10, 20, 30, 0.5))
Output: 0.5
Returns: Dimension
Example: luma(rgb(100, 200, 30))
Output: 44%
Returns: Dimension
Example: luminance(rgb(100, 200, 30))
Output: 65%
Returns: Color
Example: saturate(#80e619, 20%)
Output: #80ff00
Returns: Color
Example: desaturate(#80e619, 20%)
Output: #80cd32
Returns: Color
Example: lighten(#80e619, 20%)
Output: #b3f075
Returns: Color
Example: darken(#80e619, 20%)
Output: #4d8a0f
Returns: Color
Example: fadein(rgba(128, 242, 13, 0.5), 10%)
Output: rgba(128, 242, 13, 0.6)
Returns: Color
Example: fadeout(rgba(128, 242, 13, 0.5), 10%)
Output: rgba(128, 242, 13, 0.4)
Returns: Color
Example: fade(#80f20d, 10%)
Output: rgba(128, 242, 13, 0.1)
Returns: Color
Example: spin(#f2330d, 30)
Output: #f2a60d
Returns: Color
Example: mix(#ff0000, #0000ff, 50%)
Output: #800080
Returns: Color
Example: tint(#007fff, 50%)
Output: #80bfff
Returns: Color
Example: shade(#007fff, 50%)
Output: #004080
Returns: Color
Example: greyscale(#80f20d)
Output: #808080
Returns: Color
Example:
p {
a: contrast(#bbbbbb);
b: contrast(#222222, #101010);
c: contrast(#222222, #101010, #dddddd);
d: contrast(hsl(90, 100%, 50%), #000000, #ffffff, 30%);
e: contrast(hsl(90, 100%, 50%), #000000, #ffffff, 80%);
}
Output:
p {
a: #000000 // black
b: #ffffff // white
c: #dddddd
d: #000000 // black
e: #ffffff // white
}
Returns: Color
Example | Output |
---|---|
color('#5a8120') | #5a8120 |
color('rgb(90, 129, 32)') | #5a8120 |
color('rgba(90, 129, 32, 0.5)') | rgba(90, 129, 32, 0.5) |
1.3.1
FAQs
This a script to switch color specific styles less file and which you can use to change theme dynamically in browser
The npm package theme-color-switch receives a total of 0 weekly downloads. As such, theme-color-switch popularity was classified as not popular.
We found that theme-color-switch demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Malicious update to @ctrl/tinycolor on npm is part of a supply-chain attack hitting 40+ packages across maintainers
Security News
pnpm's new minimumReleaseAge setting delays package updates to prevent supply chain attacks, with other tools like Taze and NCU following suit.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.