diff --git a/src/utils.js b/src/utils.js index a5954787e..1e5fa761d 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,10 +1,10 @@ import { css } from 'styled-components' import defaultBreakpoints from './theme/defaultBreakpoints' -const getBreakpoints = props => +export const getBreakpoints = props => (props && props.theme && props.theme.breakpoints) || defaultBreakpoints -const getBreakpointsEntries = props => { +export const getBreakpointsEntries = props => { const breakpoints = getBreakpoints(props) const entries = Object.keys(breakpoints).reduce( (entries, key) => [...entries, [key, breakpoints[key]]], @@ -13,13 +13,13 @@ const getBreakpointsEntries = props => { return entries.sort((a, b) => a[1] > b[1]) } -const getNextBreakpoint = (name, props) => { +export const getNextBreakpoint = (name, props) => { const entries = getBreakpointsEntries(props) const index = entries.findIndex(([key]) => key === name) return index < entries.length - 1 ? entries[index + 1][0] : null } -const getPreviousBreakpoint = (name, props) => { +export const getPreviousBreakpoint = (name, props) => { const entries = getBreakpointsEntries(props) const index = entries.findIndex(([key]) => key === name) return index >= 1 ? entries[index - 1][0] : null @@ -29,7 +29,7 @@ const getPreviousBreakpoint = (name, props) => { * Minimum breakpoint width. * Null for the smallest breakpoint. */ -const getBreakpointMin = (name, props) => { +export const getBreakpointMin = (name, props) => { const breakpoints = getBreakpoints(props) const breakPoint = breakpoints[name] return breakPoint !== 0 ? breakPoint : null @@ -43,7 +43,7 @@ const getBreakpointMin = (name, props) => { * Uses 0.02px rather than 0.01px to work around a current rounding bug in Safari. * See https://bugs.webkit.org/show_bug.cgi?id=178261 */ -const getBreakpointMax = (name, props) => { +export const getBreakpointMax = (name, props) => { const next = getNextBreakpoint(name, props) return next ? getBreakpointMin(next, props) - 0.02 : null }