Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
refactor(make-breakpoints): change the output of the breakpoints
Browse files Browse the repository at this point in the history
breakpoints are not an array but an associative array

BREAKING CHANGE: breakpoints are not an array but an associative array
  • Loading branch information
mg901 committed Jan 23, 2019
1 parent cc59795 commit 32ccd4d
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/make-breakpoints/make-breakpoints-process.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @flow

import * as R from 'ramda';
import { toPxBreakValue } from './to-px-break-value';
import { basePropProcess } from './base-prop-process';
Expand All @@ -8,22 +6,27 @@ import { renameProp } from './rename-prop';
import { inheritProps } from './inherit-props';
import { calcRatioProcess } from './ratio-prop-utils';
import { setPropRoot } from './root-prop-utils';
import { type Breakpoint } from '../models/breakpoints';
import { type UserConfig } from '../models/user-config';
import { makeBreaksMap } from './make-breaks-map';

const reduceIndexed = R.addIndex(R.reduce);

export const makeBreakpointsProcess = (config: UserConfig): Breakpoint[] =>
createBreakpoints(config)
.map(
R.compose(
basePropProcess,
toPxBreakValue,
renameProp('breakpoint', 'value'),
),
)
.reduce(inheritProps, [])
.map(
R.compose(
setPropRoot,
calcRatioProcess,
),
);
// makeBreakpointsProcess :: Object -> {a: [Object]}
export const makeBreakpointsProcess = R.compose(
R.map(R.omit(['name'])),
R.reduce(makeBreaksMap, {}),
R.map(
R.compose(
setPropRoot,
calcRatioProcess,
),
),
reduceIndexed(inheritProps, []),
R.map(
R.compose(
basePropProcess,
toPxBreakValue,
renameProp('breakpoint', 'value'),
),
),
createBreakpoints,
);

0 comments on commit 32ccd4d

Please sign in to comment.