@vaadin/media-query-mixin
TypeScript icon, indicating that this package has built-in type declarations

0.1.4 • Public • Published

@vaadin/media-query-mixin

This package provides MediaQueryMixin and @mediaProperty decorator.

@customElement('mq-basic-element')
class MyElement extends MediaQueryMixin(LitElement) {
  @mediaProperty({ media: '(max-width: 420px)' })
  fullscreen: boolean | null | undefined;
}

Using a @mediaProperty decorator

When using @mediaProperty, the following restrictions apply:

  • property is forced to be of type: Boolean regardless of the user config
  • property value is set to true when query matches, and false otherwise
  • attribute: false is forced so setting attribute is ignored
  • property is read-only so manual modifications are ignored
  • default property value set by the user is also ignored

As a result, window.matchMedia is a single source of truth.

Dependencies (3)

Dev Dependencies (2)

Package Sidebar

Install

npm i @vaadin/media-query-mixin

Weekly Downloads

1

Version

0.1.4

License

Apache-2.0

Unpacked Size

11.5 kB

Total Files

6

Last publish

Collaborators

  • web-padawan
  • diegocardoso
  • alvarezguille
  • platosha
  • jouni
  • manolo
  • yuriyyev
  • vaadin-owner
  • tomivirkki
  • artur-
  • sunzhewyq
  • sosa-vaadin