Skip to content

Commit 6a53cd2

Browse files
committed
stricter types for breakpoint api
1 parent 12ce49c commit 6a53cd2

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/lib/breakpoints.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ export type { BreakpointKeys };
1010
const epsilon = 0.003125;
1111

1212
export const breakpoints = {
13-
"up": (key: BreakpointKeys) => `@media (min-width:${values[key]}${unit})`,
14-
"down": (key: BreakpointKeys) => `@media (max-width:${values[key] - epsilon}${unit})`,
13+
"up": (key: BreakpointKeys) => `@media (min-width:${values[key]}${unit})` as const,
14+
"down": (key: BreakpointKeys) => `@media (max-width:${values[key] - epsilon}${unit})` as const,
1515
"between": (start: BreakpointKeys, end: BreakpointKeys) =>
16-
[
17-
`@media (min-width:${values[start]}${unit})`,
18-
`(max-width:${values[end] - epsilon}${unit})`
19-
].join(" and "),
16+
`@media (min-width:${values[start]}${unit}) and (max-width:${
17+
values[end] - epsilon
18+
}${unit})` as const,
2019
"only": (key: BreakpointKeys) =>
2120
keys.indexOf(key) + 1 < keys.length
2221
? breakpoints.between(key, keys[keys.indexOf(key) + 1])

0 commit comments

Comments
 (0)