Gathering detailed insights and metrics for vue-media
Gathering detailed insights and metrics for vue-media
Gathering detailed insights and metrics for vue-media
Gathering detailed insights and metrics for vue-media
npm install vue-media
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
193 Stars
27 Commits
15 Forks
4 Watching
14 Branches
4 Contributors
Updated on 18 Sept 2024
Minified
Minified + Gzipped
JavaScript (56.9%)
Vue (43.1%)
Cumulative downloads
Total Downloads
Last day
-54.4%
52
Compared to previous day
Last week
-26.2%
329
Compared to previous week
Last month
17.6%
1,414
Compared to previous month
Last year
-25.4%
24,114
Compared to previous year
Like react-media but for Vue.js, and this library is pretty small, it's 969 bytes after minification without gzip.
1yarn add vue-media
CDN: https://unpkg.com/vue-media/dist
1<template> 2 <div id="app"> 3 <media :query="{minWidth: 500}">bigger than 500px</media> 4 <media :query="{maxWidth: 500}">smaller than 500px</media> 5 </div> 6</template> 7 8<script> 9 import Media from 'vue-media' 10 // Component is automatically registered if using CDN. 11 export default { 12 components: { 13 Media 14 } 15 } 16</script>
The value of query
can also be a media query string like (max-width: 500px)
, for more info please see json2mq doc.
The media
component will only return the first element or component passed to it. Example:
1<template> 2 <media :query="{maxWidth: 600}"> 3 <h2>hello world</h2> 4 <my-other-component></my-other-component> <!-- this will not be used! --> 5 </media> 6</template>
Use the media-enter
and media-leave
events.
1<template> 2 <div> 3 <media 4 :query="{maxWidth: 600}" 5 @media-enter="mediaEnter" 6 @media-leave="mediaLeave" 7 > 8 <h2>Hello world</h2> 9 </media> 10 <h2 v-if="greaterThan600">I'm now wider than 600!</h2> 11 </div> 12</template> 13 14<script> 15import Media from 'vue-media' 16 17export default { 18 components: { 19 Media 20 }, 21 data() { 22 return { 23 greaterThan600: window.innerWidth > 600 24 } 25 }, 26 methods: { 27 mediaEnter(mediaQueryString) { 28 this.greaterThan600 = false 29 }, 30 mediaLeave(mediaQueryString) { 31 this.greaterThan600 = true 32 } 33 } 34} 35</script>
The first argument of the listener is a mediaQueryString like (min-width: 400px)
.
Prop | Type | Default | Description |
---|---|---|---|
visibleByDefault | boolean | false | Whether to show the element by default. |
If you want to support legacy browsers (ie <= 10), please include a window.matchMedia
polyfill.
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
vue-media © egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).
egoistian.com · GitHub @egoist · Twitter @_egoistlily
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/27 approved changesets -- score normalized to 1
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
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
107 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
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