Skip to content

Commit

Permalink
feat(utils): Added a list of breakpoints in the order they where defined
Browse files Browse the repository at this point in the history
The returned object from `breakpoints` now include a list of breakpoints in the order they where
defined
  • Loading branch information
John Persson committed Nov 14, 2017
1 parent 9d53059 commit a14ad2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,14 @@ export const getMediaShorthands = (breakpoints, rule) => (

export const getMedia = (breakpoints: Breakpoints) => {
const mediasUp = getMediaShorthands(breakpoints, 'up');
const list = Object.keys(breakpoints);

return ({
...mediasUp,
up: (widthKey: string) => getMixin(breakpoints, widthKey, 'up')(),
down: (widthKey: string) => getMixin(breakpoints, widthKey, 'down')(),
only: (widthKey: string, boundKey: string) => getMixin(breakpoints, widthKey, 'only')(boundKey),
list,
});
};

Expand Down
5 changes: 5 additions & 0 deletions src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,5 +125,10 @@ describe('breakpoint', () => {
expect(bp.xl`baground: red;`[1]).toMatch('@media only screen and (min-width: 1200px)');
});
});
describe('list', () => {
it('stores an array of breakpoints in the order they where defined', () => {
expect(bp.list).toEqual(['xs', 's', 'm', 'l', 'xl']);
})
});
});
});

0 comments on commit a14ad2b

Please sign in to comment.