-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
30 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { BreakpointKeys } from '@toptal/picasso-provider/index' | ||
import { PicassoBreakpoints } from '@toptal/picasso-provider/index' | ||
|
||
/** | ||
* Produces an array of checkpoints – screen size values, needed for covering | ||
* all existing breakpoints in tests (checkpoints are different from breakpoints | ||
* by certain offset). | ||
* | ||
* @returns {number[]} Array of checkpoints | ||
*/ | ||
export const getCheckpoints = () => { | ||
const offset = 1 | ||
const breakpoints = PicassoBreakpoints.breakpoints.values | ||
const breakpointKeys = Object.keys(breakpoints) | ||
|
||
return [ | ||
...breakpointKeys | ||
// Skip the first breakpoint as it equals to 0 | ||
.slice(1) | ||
// Genereate checkpoints by subtsracting offset from each breakpoint | ||
.map( | ||
breakpointKey => breakpoints[breakpointKey as BreakpointKeys] - offset | ||
), | ||
// Add the last checkpoint that covers screens wider that the last breakpoint | ||
breakpoints[breakpointKeys.slice(-1) as unknown as BreakpointKeys] + offset, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters