Skip to content

Commit a14ad2b

Browse files
author
John Persson
committed
feat(utils): Added a list of breakpoints in the order they where defined
The returned object from `breakpoints` now include a list of breakpoints in the order they where defined
1 parent 9d53059 commit a14ad2b

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,14 @@ export const getMediaShorthands = (breakpoints, rule) => (
9191

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

9596
return ({
9697
...mediasUp,
9798
up: (widthKey: string) => getMixin(breakpoints, widthKey, 'up')(),
9899
down: (widthKey: string) => getMixin(breakpoints, widthKey, 'down')(),
99100
only: (widthKey: string, boundKey: string) => getMixin(breakpoints, widthKey, 'only')(boundKey),
101+
list,
100102
});
101103
};
102104

src/index.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,10 @@ describe('breakpoint', () => {
125125
expect(bp.xl`baground: red;`[1]).toMatch('@media only screen and (min-width: 1200px)');
126126
});
127127
});
128+
describe('list', () => {
129+
it('stores an array of breakpoints in the order they where defined', () => {
130+
expect(bp.list).toEqual(['xs', 's', 'm', 'l', 'xl']);
131+
})
132+
});
128133
});
129134
});

0 commit comments

Comments
 (0)