Gathering detailed insights and metrics for @spezifisch/svelte-media
Gathering detailed insights and metrics for @spezifisch/svelte-media
Gathering detailed insights and metrics for @spezifisch/svelte-media
Gathering detailed insights and metrics for @spezifisch/svelte-media
Svelte.js util to easily observe media queries as a reactive store
npm install @spezifisch/svelte-media
Typescript
Module System
Min. Node Version
Node Version
NPM Version
60.4
Supply Chain
78.9
Quality
75
Maintenance
50
Vulnerability
100
License
TypeScript (62.18%)
JavaScript (37.82%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
60 Stars
35 Commits
4 Forks
4 Watchers
10 Branches
2 Contributors
Updated on Apr 17, 2025
Latest Version
0.1.5
Package Id
@spezifisch/svelte-media@0.1.5
Unpacked Size
6.63 kB
Size
3.22 kB
File Count
6
NPM Version
8.5.5
Node Version
16.15.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
22
Easy way to observe for media queries as a store for your Svelte apps
svelte-media
helps you define the media queries you want to observe. By using stores to keep track of the matching state of the given media queries it notifies your app in the most efficient way when a change happens.
It works SSR environments where window.matchMedia
is not available, so it can be used in Sapper apps safely.
Just run npm i --save-dev svelte-media
or yarn add svelte-media
.
The package's default export is a function that takes an object with named mediaquery strings and returns a svelte store that you can export to consume any way you want.
1import watchMedia from "svelte-media"; 2 3const mediaqueries = { 4 small: "(max-width: 849px)", 5 large: "(min-width: 850px)", 6 short: "(max-height: 399px)", 7 landscape: "(orientation: landscape) and (max-height: 499px)", 8 tiny: "(orientation: portrait) and (max-height: 599px)", 9 dark: "(prefers-color-scheme: dark)", 10 noanimations: "(prefers-reduced-motion: reduce)" 11}; 12 13export const media = watchMedia(mediaqueries);
Given an object with named media queries, the returned object from that store will have boolean properties named
after the media queries that indicate if they are a match or not, and a property named classNames
that
contains a name of the matching media queries prefixed by media-
to use as convenient css classes in any element.
For the example above the object might look like this:
1{ 2 small: false 3 large: true 4 short: true 5 landscape: true 6 tiny: false 7 dark: true 8 noanimations : false, 9 classNames: 'media-large media-short media-landscape media-dark' 10}
As with any other store, you can subscribe to it in templates by prefixing it with $
.
1<script> 2 import { media } from '../stores'; 3</script> 4 5<div class="body l-body {$media.classNames}"> 6 {if $media.large} 7 <DesktopNav/> 8 {:else} 9 <MobileNav/> 10 {/if} 11</div>
You can create more than one store if, for instance, you want to keep media queries about screen size separated from, say those about pixel density, as the latter very rarely will fire an update.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
Found 1/15 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
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
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
30 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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