Skip to content

Commit c49f0a5

Browse files
committed
refactor: index file. Add /css package for Theme typing
1 parent 2451c3a commit c49f0a5

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

packages/css/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ export type ColorMode = {
511511
}
512512

513513
export interface Theme {
514-
breakpoints?: ObjectOrArray<number | string | symbol>
514+
breakpoints?: Array<string>
515515
mediaQueries?: { [size: string]: string }
516516
space?: ObjectOrArray<CSS.MarginProperty<number | string>>
517517
fontSizes?: ObjectOrArray<CSS.FontSizeProperty<number>>

packages/match-media/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
},
1919
"devDependencies": {
2020
"react": "^16.9.0",
21-
"theme-ui": "^0.3.1"
21+
"@theme-ui/core": "^0.3.1",
22+
"@theme-ui/css": "^0.3.1"
2223
},
2324
"peerDependencies": {
2425
"react": "^16.9.0",

packages/match-media/src/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
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'
34

45
// Shared with @theme-ui/css
56
const defaultBreakpoints = [40, 52, 64].map(n => n + 'em')
67

7-
export const useBreakpointIndex = ({ defaultIndex = 0 }) => {
8+
type defaultOptions = {
9+
defaultIndex?: number
10+
}
11+
12+
export const useBreakpointIndex = (options: defaultOptions = {}) => {
813
const context = useThemeUI()
14+
const { defaultIndex = 0 } = options
915
const breakpoints =
1016
(context.theme && context.theme.breakpoints) || defaultBreakpoints
1117

@@ -46,7 +52,9 @@ export const useBreakpointIndex = ({ defaultIndex = 0 }) => {
4652
return value
4753
}
4854

49-
export const useResponsiveValue = (values, options) => {
55+
type Values = ((theme: Theme | null) => string[]) | string[]
56+
57+
export const useResponsiveValue = (values: Values, options: defaultOptions) => {
5058
const { theme } = useThemeUI()
5159
const array = typeof values === 'function' ? values(theme) : values
5260
const index = useBreakpointIndex(options)

0 commit comments

Comments
 (0)