Giter VIP home page Giter VIP logo

svelte-mq-store's Introduction

svelte-mq-store

npm-version npm-license npm-download-month npm-min-size ci.yml website

๐Ÿ“ฑ Create any media-query store in Svelte

Demo

Installation

npm i svelte-mq-store

Usage

Use the listen to subscribe to the contents of any media query.

<script>
  import { listen } from 'svelte-mq-store'

  const isDark = listen('(prefers-color-scheme: dark)')
</script>

{#if $isDark}
  Device is dark mode
{:else}
  Device is light mode
{/if}

Fallback in Server

Media queries are available only in the browser.
The fallback value used by the server during SSR can be specified as the second argument. (default is undefined).

import { listen } from 'svelte-mq-store'

const isDark = listen(
  '(prefers-color-scheme: dark)',
  false // fallback value
)

License

MIT

svelte-mq-store's People

Contributors

jill64 avatar renovate[bot] avatar wraith-ci[bot] avatar

Watchers

 avatar

svelte-mq-store's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/ci.yml
  • jill64/playwright-config v2.2.2@374b1a370d028014cc9f0a1209921007ceb69018
npm
package.json
  • @jill64/eslint-config-svelte 1.0.14
  • @jill64/npm-demo-layout 1.0.47
  • @jill64/playwright-config 2.2.2
  • @jill64/prettier-config 1.0.0
  • @jill64/sentry-sveltekit-cloudflare 1.7.2
  • @jill64/universal-sanitizer 1.0.2
  • @playwright/test 1.41.0
  • @sveltejs/adapter-cloudflare 4.1.0
  • @sveltejs/kit 2.4.0
  • svelte 4.2.9
  • typescript 5.3.3
  • vite 5.0.11
  • @sveltejs/vite-plugin-svelte 3.0.1
  • @sveltejs/kit ^2.0.0
  • svelte ^4.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.