Skip to content

Commit

Permalink
feat: add color schema detection
Browse files Browse the repository at this point in the history
closes #101
  • Loading branch information
Kikobeats committed Nov 11, 2019
1 parent 26744cd commit ca55c0d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
7 changes: 5 additions & 2 deletions packages/screenshot/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ const createSvgBackground = css => svgGradient(css, { width: '1388px', height: '

module.exports = gotoOpts => {
const preparePage = createPreparePage(gotoOpts)
return page => async (url, { type = 'png', direction = 'vertical', overlay, ...opts } = {}) => {
await preparePage(page, url, opts)
return page => async (
url,
{ overlay = {}, type = 'png', direction = 'vertical', ...opts } = {}
) => {
await preparePage(page, url, { overlay, ...opts })
const screenshot = await page.screenshot({ ...opts, type })

if (!overlay) return screenshot
Expand Down
15 changes: 10 additions & 5 deletions packages/screenshot/src/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,25 @@ module.exports = ({ goto, ...gotoOpts } = {}) => {

return async (page, url, opts = {}) => {
const {
fullPage,
device = 'macbook pro 13',
disableAnimations = true,
hide,
overlay,
click,
element,
fullPage,
hide,
modules,
scripts,
styles,
element,
scrollTo,
overlay,
styles,
...args
} = opts

if (overlay.browser) {
const value = overlay.browser.includes('dark') ? 'dark' : 'light'
await page.emulateMediaFeatures([{ name: 'prefers-color-scheme', value }])
}

page.on('dialog', async dialog => {
await dialog.dismiss()
})
Expand Down

0 comments on commit ca55c0d

Please sign in to comment.