Skip to content

Commit 9f3d455

Browse files
committed
Add devices example
1 parent 88332cd commit 9f3d455

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

examples/devices.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict'
2+
3+
const { devices } = require('..')
4+
const { chain } = require('lodash')
5+
6+
console.log(`| name | width | height | scale | mobile? | touch? | landscape? |`)
7+
console.log(
8+
`|------|-------|--------|-------------------|----------|----------|-------------|`
9+
)
10+
11+
const deviceStrings = chain(devices)
12+
.orderBy(['name'], ['asc'])
13+
.map(device => {
14+
const { name, viewport } = device
15+
const {
16+
width,
17+
height,
18+
deviceScaleFactor,
19+
isMobile,
20+
hasTouch,
21+
isLandscape
22+
} = viewport
23+
24+
return `| \`${name}\` | ${width} | ${height} | ${deviceScaleFactor} | ${isMobile} | ${hasTouch} | ${isLandscape} |`
25+
})
26+
.value()
27+
28+
deviceStrings.forEach(str => console.log(str))

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"husky": "latest",
3939
"is-travis": "latest",
4040
"lint-staged": "latest",
41+
"lodash": "latest",
4142
"mocha": "latest",
4243
"nyc": "latest",
4344
"prettier-standard": "latest",

0 commit comments

Comments
 (0)