
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
🎨 Add color theme systme to your page with ColorMode!
npm install color-mode
OR Add to <script>
Download
<div class="wrap" colormode="bg:bgPrimary">
<div class="panel" colormode="bg:bgSecondary">
<h2 class="title" colormode="fg:labelPrimary">ColorMode</h2>
<a id="dark" class="button" colormode="secondaryBtn">Dark</a>
<a id="default" class="button" colormode="primaryBtn">Default</a>
</div>
</div>
<script>
// Bind button event
window.onload = function () {
document.getElementById('dark').addEventListener('click', function () {
colorMode.set('dark')
})
document.getElementById('default').addEventListener('click', function () {
colorMode.set('default')
})
}
var option = {
initialTheme: 'dark', // Init with dark
fallbackTheme: 'default',
animation: 200, // Transform effect duration(ms)
tags: {
fg: 'color',
bg: 'background-color',
primaryBtn: {
backgroundColor: '@tint',
color: '@onTint'
},
secondaryBtn: {
backgroundColor: '@bgTertiary',
color: '@tint'
}
},
themes: {
default: { // required!
tint: '#007aff',
onTint: '#ffffff',
bgPrimary: '#e5e9f2',
bgSecondary: '#ffffff',
bgTertiary: '#eef3fc',
labelPrimary: '#1d212b',
labelSecondary: '#45566f'
},
dark: {
tint: '#6db3ff',
onTint: '#ffffff',
bgPrimary: '#262b3a',
bgSecondary: '#484d5d',
bgTertiary: '#353a4b',
labelPrimary: '#ffffff',
labelSecondary: '#cfd3e0'
},
// You can add more custom themes
}
}
// Create ColorMode instance
var colorMode = new ColorMode(option)
</script>
Import ColorMode
// NPM
import colorMode from 'color-mode'
<!-- HTML Script -->
<script src="color-mode.min.js">
Create ColorMode instance
var colorMode = new ColorMode(option)
ColorMode Class
ColorMode instance must be create once.
| Parameter | Type | Required |
|---|---|---|
| option | object | O |
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
| initialTheme | string | X | default | Initial theme name |
| fallbackTheme | string | X | default | Fallback theme name |
| animation | number | X | 0 | Theme transform effect duration |
| tags | object | O | none | Theme tags |
| themes | object | O | none | Themes |
| Key | Value | Type | Required |
|---|---|---|---|
custom tag name | CSS Property or Style object | string | object | O |
'color', 'background-color', 'box-shadow', ...{ color: 'dodgerblue', backgroundColor: '#e0e0e0', ... }
(background-color > backgroundColor)@ (ex: @NAME find 'NAME' color from theme)/**
* tags: {
* TAG_NAME: 'CSS Property',
* TAG_NAME: {
* boxShadow: '0 0 0 5px @primary' // Using theme's 'primary' named color
* }
* }
*/
const option = {
// ...
tags: {
myTag: ...,
fg: 'color', // string (CSS Property)
bg: 'background-color',
detail: { // object (Style object)
backgroundColor: '#2f2f2f',
color: '@primary' // Find 'primary' color from 'option.themes.*'
}
}
}
| Key | Value | Type | Required |
|---|---|---|---|
| default | CSS Style (color code, etc..) | string | O |
custom theme name | CSS Style (color code, etc..) | string | X |
default theme requiredcustom theme name if you want to add theme
/**
* themes: {
* THEME_NAME: {
* STYLE_NAME: 'VALUE'
* }
* }
*/
const option = {
// ...
themes: {
default: { // required!
tint: '#007aff',
tint10: '#d8e7f9',
onTint: '#ffffff',
bgPrimary: '#e5e9f2',
bgSecondary: '#ffffff',
bgTertiary: '#eef3fc',
panelBorder: '1px solid #007aff'
},
dark: {
tint: '#6db3ff',
tint10: '#e4ecf9',
onTint: '#ffffff',
bgPrimary: '#262b3a',
bgSecondary: '#484d5d',
bgTertiary: '#353a4b',
panelBorder: '1px solid #6db3ff'
},
myTheme: { ... }
}
}
| Type | Description |
|---|---|
| string | Current theme name |
if (colorMode.currentTheme === 'default') {
// If current theme is default..
}
Return all of theme names list
const colorMode = new ColorMode({
//...
themes: {
default: { /*...*/ },
dark: { /*...*/ },
rainbow: { /*...*/ }
}
})
colorMode.getThemeList() // ['default', 'dark', 'rainbow']
Change theme to target theme
| Parameter | Type | Required |
|---|---|---|
| themeName | string | O |
// Set to 'dark' theme
colorMode.set('dark')
MIT Licensed
FAQs
Add color theme systme to your page with color-mode!
We found that color-mode 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
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.