Skip to content

Commit

Permalink
Add devices example
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Nov 9, 2017
1 parent 88332cd commit 419a112
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions examples/devices.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'

const { devices } = require('..')
const { chain } = require('lodash')

console.log(`| name | width | height | scale | mobile? | touch? | landscape? |`)
console.log(
`|------|-------|--------|-------------------|----------|----------|-------------|`
)

const deviceStrings = chain(devices)
.orderBy(['viewport.width', 'viewport.height'], ['desc', 'desc'])
.map(device => {
const { name, viewport } = device
const {
width,
height,
deviceScaleFactor,
isMobile,
hasTouch,
isLandscape
} = viewport

return `| \`${name}\` | ${width} | ${height} | ${deviceScaleFactor} | ${isMobile} | ${hasTouch} | ${isLandscape} |`
})
.value()

deviceStrings.forEach(str => console.log(str))
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"husky": "latest",
"is-travis": "latest",
"lint-staged": "latest",
"lodash": "latest",
"mocha": "latest",
"nyc": "latest",
"prettier-standard": "latest",
Expand Down

0 comments on commit 419a112

Please sign in to comment.