Skip to content

Commit

Permalink
fix: allow custom breakpoint names in ResponsiveObject
Browse files Browse the repository at this point in the history
  • Loading branch information
TimKolberger committed Feb 7, 2021
1 parent b5aa923 commit 4943a15
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/big-cherries-wash.md
@@ -0,0 +1,6 @@
---
"@chakra-ui/styled-system": patch
---

Fixed an issue where TypeScript did not allow custom breakpoint names in
ResponsiveObject
2 changes: 1 addition & 1 deletion packages/styled-system/src/utils/types.ts
Expand Up @@ -3,7 +3,7 @@ import { ThemeTypings } from "../theming.types"
export type ResponsiveArray<T> = Array<T | null>

export type ResponsiveObject<T> = Partial<
Record<ThemeTypings["breakpoints"], T>
Record<ThemeTypings["breakpoints"] | string, T>
>

export type ResponsiveValue<T> = T | ResponsiveArray<T> | ResponsiveObject<T>
Expand Down
11 changes: 11 additions & 0 deletions packages/styled-system/tests/css-type.test.ts
Expand Up @@ -109,3 +109,14 @@ test("should support deep nesting", () => {

expect(styles).toBeTruthy()
})

test("should allow arbitrary breakpoint names by default", () => {
const styles: SystemStyleObject = {
mt: {
base: "130px",
tablet: "152px",
},
}

expect(styles).toBeTruthy()
})

0 comments on commit 4943a15

Please sign in to comment.