Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@jill64/svelte-dark-theme
Advanced tools
☯ Dark Theme Manager for SvelteKit
<script>
import { ThemeManager, setting, theme } from '@jill64/svelte-dark-theme'
const setToDark = () => {
$setting = 'dark'
}
const setToLight = () => {
$setting = 'light'
}
const setToDeviceSync = () => {
$setting = 'sync'
}
</script>
<!-- Place it in root -->
<ThemeManager />
<!-- Theme Store ('dark' | 'light') -->
<div>Theme: {$theme}</div>
<!-- Theme Store ('dark' | 'light' | 'sync') -->
<div>Setting: {$setting}</div>
<style>
:global(body.light) {
/* light mode styling */
}
:global(body.dark) {
/* dark mode styling */
}
</style>
This function provides the smart theme switching found on some sites.
Each call to the function switches the setting
according to the following rules
before setting | device theme | after setting | after theme |
---|---|---|---|
light | light | dark | dark |
light | dark | sync | dark |
dark | light | sync | light |
dark | dark | light | light |
sync | light | dark | dark |
sync | dark | light | light |
<script>
import { flip } from '@jill64/svelte-dark-theme'
</script>
<button on:click={$filp}> flip theme </button>
When using SSR, you can reduce flushing on load by binding classes to html with hooks.
// hooks.server.js
import { onRender } from '@jill64/svelte-dark-theme'
export const handle = onRender({
// Optional Configs
// {
// cookieKey: string (default: 'svelte-dark-theme')
// }
})
Use sequence
when combining with other processing.
// hooks.server.js
import { onRender } from '@jill64/svelte-dark-theme'
import { sequence } from '@sveltejs/kit/hooks'
export const handle = sequence(onRender(), async ({ event, resolve }) => {
// ...
return resolve(event)
})
FAQs
☯ Dark Theme Manager for SvelteKit
The npm package @jill64/svelte-dark-theme receives a total of 11,858 weekly downloads. As such, @jill64/svelte-dark-theme popularity was classified as popular.
We found that @jill64/svelte-dark-theme demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.