Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
nuxt-viewport
Advanced tools
Define custom viewports for your Nuxt️ project
nuxt-viewport
dependency to your project# Using npm
npm install --save-dev nuxt-viewport
# Using yarn
yarn add --dev nuxt-viewport
nuxt-viewport
to the modules
section of nuxt.config.js
{
modules: [
[
'nuxt-viewport', {
/* Viewport options */
}
],
]
}
using top level options
{
modules: [
'nuxt-viewport',
],
viewport: {
/* Viewport options */
},
}
@nuxtjs/composition-api
import { defineComponent, useContext, watch } from '@nuxtjs/composition-api'
export default defineComponent({
setup() {
// Context.
const context = useContext()
// Viewport module.
const viewport = context.$viewport
// Watch breakpoint for updates.
watch(() => viewport.breakpoint, (newBreakpoint, oldBreakpoint) => {
console.log('Breakpoint updated:', oldBreakpoint, '->', newBreakpoint)
})
},
})
If using typescript or running typescript language server to check the code (for example through Vetur), add types to types
array in your tsconfig.json
:
{
"compilerOptions": {
"types": [
"@nuxt/types",
"nuxt-viewport",
]
}
}
breakpoints
An object where the key is the name of the viewport, and the value is the viewport size.
cookieName
viewport
The key for the document cookie.
defaultBreakpoints
console
, desktop
, embedded
, mobile
, smarttv
, tablet
, wearable
An object where the key is the name of the detected device, and the value is the breakpoint key.
fallbackBreakpoint
viewport
The breakpoint key to be used, if the device was not detected.
{
// ...
viewport: {
breakpoints: {
desktop: 1024,
desktopMedium: 1280,
desktopWide: 1600,
mobile: 320,
mobileMedium: 375,
mobileWide: 425,
tablet: 768,
},
cookieName: 'viewport',
defaultBreakpoints: {
desktop: 'desktop',
mobile: 'mobile',
tablet: 'tablet',
},
fallbackBreakpoint: 'desktop',
},
// ...
}
{
// ...
viewport: {
breakpoints: {
xs: 320,
sm: 640,
md: 768,
lg: 1024,
xl: 1280,
'2xl': 1536,
},
defaultBreakpoints: {
desktop: 'lg',
mobile: 'xs',
tablet: 'md',
},
fallbackBreakpoint: 'lg'
},
// ...
}
$viewport.breakpoint
Current breakpoint.
$viewport.isGreaterThan
// Example: $viewport.breakpoint is "mobile".
$viewport.isGreaterThan('mobile') // Result: false.
$viewport.isGreaterThan('desktop') // Result: false.
$viewport.isGreaterOrEquals
// Example: $viewport.breakpoint is "mobile".
$viewport.isGreaterOrEquals('mobile') // Result: true.
$viewport.isGreaterOrEquals('desktop') // Result: false.
$viewport.isLessThan
// Example: $viewport.breakpoint is "desktop".
$viewport.isLessThan('desktopWide') // Result: true.
$viewport.isLessThan('mobile') // Result: false.
$viewport.match
// Example: $viewport.breakpoint is "tablet".
$viewport.match('tablet') // Result: true.
$viewport.match('desktop') // Result: false.
$viewport.matches
// Example: $viewport.breakpoint is "mobileWide".
$viewport.matches('tablet', 'mobileWide') // Result: true.
$viewport.matches('mobile', 'tablet') // Result: false.
You can contribute to this module online with CodeSandBox:
Or locally:
yarn install
or npm install
yarn dev
or npm run dev
Copyright (c) mvrlin mvrlin@pm.me
FAQs
Define custom viewports for your Nuxt project
The npm package nuxt-viewport receives a total of 23,793 weekly downloads. As such, nuxt-viewport popularity was classified as popular.
We found that nuxt-viewport demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.