Skip to content

Commit 8e5996b

Browse files
committed
Added responsiveScreenShots method
Method uses some default screen sizes which can be altered
1 parent 297e408 commit 8e5996b

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

src/Browser.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,39 @@ class Browser
3939
*/
4040
public static $storeScreenshotsAt;
4141

42+
/**
43+
* These are the most common screen sizes to use for responsive screenshots.
44+
* These will trigger all of tailwind's default breakpoints.
45+
*
46+
* @var array
47+
*/
48+
public static $responsiveScreenSizes = [
49+
'xs' => [
50+
'width' => 360,
51+
'height' => 640,
52+
],
53+
'sm' => [
54+
'width' => 640,
55+
'height' => 360,
56+
],
57+
'md' => [
58+
'width' => 768,
59+
'height' => 1024,
60+
],
61+
'lg' => [
62+
'width' => 1024,
63+
'height' => 768,
64+
],
65+
'xl' => [
66+
'width' => 1280,
67+
'height' => 1024,
68+
],
69+
'2xl' => [
70+
'width' => 1536,
71+
'height' => 864,
72+
],
73+
];
74+
4275
/**
4376
* The directory that will contain any console logs.
4477
*
@@ -396,6 +429,26 @@ public function screenshot($name)
396429
return $this;
397430
}
398431

432+
/**
433+
* Take a series of screenshots at different browser sizes to emulate different devices.
434+
*
435+
* @param string $name
436+
* @return $this
437+
*/
438+
public function responsiveScreenShots($name)
439+
{
440+
if (substr($name, -1) !== '/') {
441+
$name .= '-';
442+
}
443+
444+
foreach (static::$responsiveScreenSizes as $device => $size) {
445+
$this->resize($size['width'], $size['height'])
446+
->screenshot("$name$device");
447+
}
448+
449+
return $this;
450+
}
451+
399452
/**
400453
* Store the console output with the given name.
401454
*

0 commit comments

Comments
 (0)