├── .editorconfig ├── .gitignore ├── LICENSE.md ├── README.md ├── package.json └── src └── MediaQuery.svelte /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 4 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | package-lock.json 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Alexander Kozlovich 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## svelte-media-query ([npm](https://www.npmjs.com/package/svelte-media-query), [demo](https://svelte.dev/repl/26eb44932920421da01e2e21539494cd)) 2 | CSS media queries in svelte. 3 | 4 | ## Installation 5 | 6 | ```bash 7 | npm i svelte-media-query 8 | ``` 9 | 10 | ## Usage 11 | 12 | ```html 13 | 16 | 17 | 18 | {#if matches} 19 |
20 | default 21 |
22 | {/if} 23 |
24 | 25 | 26 | {#if matches} 27 |
28 | tablet 29 |
30 | {/if} 31 |
32 | 33 | 34 | {#if matches} 35 |
36 | mobile 37 |
38 | {/if} 39 |
40 | ``` 41 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svelte-media-query", 3 | "description": "Svelte CSS Media Query", 4 | "version": "1.1.2", 5 | "main": "./src/MediaQuery.svelte", 6 | "svelte": "./src/MediaQuery.svelte", 7 | "repository": "https://github.com/xelaok/svelte-media-query", 8 | "author": "Alexander Kozlovich ", 9 | "license": "MIT", 10 | "keywords": [ 11 | "svelte", 12 | "media query" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /src/MediaQuery.svelte: -------------------------------------------------------------------------------- 1 | 42 | 43 | 44 | --------------------------------------------------------------------------------