File tree Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -511,7 +511,7 @@ export type ColorMode = {
511
511
}
512
512
513
513
export interface Theme {
514
- breakpoints ?: ObjectOrArray < number | string | symbol >
514
+ breakpoints ?: Array < string >
515
515
mediaQueries ?: { [ size : string ] : string }
516
516
space ?: ObjectOrArray < CSS . MarginProperty < number | string > >
517
517
fontSizes ?: ObjectOrArray < CSS . FontSizeProperty < number > >
Original file line number Diff line number Diff line change 2
2
"name" : " @theme-ui/match-media" ,
3
3
"version" : " 0.3.1" ,
4
4
"description" : " React hooks for theme-ui breakpoints" ,
5
+ "source" : " src/index.ts" ,
5
6
"main" : " dist/index.js" ,
6
7
"module" : " dist/index.esm.js" ,
8
+ "types" : " dist/index.d.ts" ,
7
9
"author" :
" Brent Jackson <[email protected] >" ,
8
10
"license" : " MIT" ,
9
11
"repository" : " system-ui/theme-ui" ,
10
12
"scripts" : {
11
- "prepare" : " microbundle --no-compress" ,
12
- "watch" : " microbundle watch --no-compress"
13
+ "prepare" : " microbundle --no-compress --tsconfig tsconfig.json " ,
14
+ "watch" : " microbundle watch --no-compress --tsconfig tsconfig.json "
13
15
},
14
16
"publishConfig" : {
15
17
"access" : " public"
16
18
},
17
19
"devDependencies" : {
18
20
"react" : " ^16.9.0" ,
19
- "theme-ui" : " ^0.3.1"
21
+ "@theme-ui/core" : " ^0.3.1" ,
22
+ "@theme-ui/css" : " ^0.3.1"
20
23
},
21
24
"peerDependencies" : {
22
25
"react" : " ^16.9.0" ,
Original file line number Diff line number Diff line change 1
1
import { useState , useEffect , useCallback } from 'react'
2
- import { useThemeUI } from 'theme-ui'
2
+ import { useThemeUI } from '@theme-ui/core'
3
+ import { Theme } from '@theme-ui/css'
3
4
4
5
// Shared with @theme -ui/css
5
6
const defaultBreakpoints = [ 40 , 52 , 64 ] . map ( n => n + 'em' )
6
7
7
- export const useBreakpointIndex = ( options = { } ) => {
8
+ type defaultOptions = {
9
+ defaultIndex ?: number
10
+ }
11
+
12
+ export const useBreakpointIndex = ( options : defaultOptions = { } ) => {
8
13
const context = useThemeUI ( )
9
14
const { defaultIndex = 0 } = options
10
15
const breakpoints =
@@ -47,7 +52,9 @@ export const useBreakpointIndex = (options = {}) => {
47
52
return value
48
53
}
49
54
50
- export const useResponsiveValue = ( values , options ) => {
55
+ type Values = ( ( theme : Theme | null ) => string [ ] ) | string [ ]
56
+
57
+ export const useResponsiveValue = ( values : Values , options : defaultOptions = { } ) => {
51
58
const { theme } = useThemeUI ( )
52
59
const array = typeof values === 'function' ? values ( theme ) : values
53
60
const index = useBreakpointIndex ( options )
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "resolveJsonModule" : true ,
4
+ "esModuleInterop" : true ,
5
+ "moduleResolution" : " node" ,
6
+ "strict" : true
7
+ }
8
+ }
You can’t perform that action at this time.
0 commit comments