Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
@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 2,081 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
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.