KO
|
EN
gitlite โ search
Search
#python
#react
#python3
#android
#automation
#hacktoberfest
#artificial-intelligence
#javascript
#minecraft
#cpp
#raspberry-pi
#golang
svelte-match-media
โ 38
Open GitHub โ
a matchMedia plugin for svelte 3
Download README (.md)
Explore Similar Repositories
svelte-hash-router
:
No description available.
svelte-starter-template
:
A small starter template to get up and running with Svelte v3 ๐
svelte-scrollspy
:
Scroll Spy component for Svelte
svelte-multistep-form
:
Svelte MultiStep Form like, this component is still in beta stage
vscode-svelte-snippets
:
๐งฉ Svelte 3 Snippets for VS Code
// repository documentation
Was this content helpful?
โ 0
(0 ratings)
Select Rating:
โ
โ
โ
โ
โ
Submit Feedback
Recent Feedback
×
Download README
Do you want to download the
README.md
file for
svelte-match-media
?
Download (.md)
# svelte-match-media a matchMedia plugin for svelte 3 ## install ```console npm install --save-dev svelte-match-media ``` ```console yarn add --dev svelte-match-media ``` ## use First, in your `main.js`, set up your media queries ```js import { setup } from 'svelte-match-media' setup({ desktop: 'screen and (min-width: 769px)', mobile: 'screen and (max-width: 768px)' }) // or if those are the exact media queries you want, just call setup() ``` Then use your media queries in your svelte components ```js <script> import { media } from 'svelte-match-media' </script> <main class:foo={$media.mobile}> {#if $media.desktop} <nav /> {/if} </main> ``` ## api #### queries (argument) All `queries` specified below should be an object of the form `{ mediaName: mediaQuery }` #### `setup(queries)` This sets up a Svelte store on the `media` export with `queries` mapped to their `window.matchMedia` result #### `media` The store initialized by `setup` above #### `createMedia(queries)` If you'd like to compartmentalize your media queries, or for whatever reason create multiple stores, this will create a standalone `media` object