Skip to content

Commit

Permalink
chore: cr
Browse files Browse the repository at this point in the history
  • Loading branch information
Brentlok committed Dec 20, 2024
1 parent b57ee88 commit 63e7410
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/components/ScopedTheme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const ScopedTheme: React.FunctionComponent<React.PropsWithChildren<ThemeP
const mappedChildren = [
<Apply key={name} name={name} />,
children,
<Apply key='dispose' name={previousScopedTheme as never} />
<Apply key='dispose' name={previousScopedTheme as keyof UnistylesThemes | undefined} />
]

return (
Expand Down
6 changes: 3 additions & 3 deletions src/server/useServerUnistyles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { UnistylesWeb } from '../web'

declare global {
interface Window {
UNISTYLES_STATE: any
__UNISTYLES_STATE__: ReturnType<typeof UnistylesWeb.registry.css.getState>
}
}

Expand All @@ -26,7 +26,7 @@ export const useServerUnistyles = () => {
<>
<style id='rnw-style'>{rnwStyle}</style>
<style id='unistyles-web'>{css}</style>
<script id='unistyles-script'>{`window.UNISTYLES_STATE = ${JSON.stringify(state)}`}</script>
<script id='unistyles-script'>{`window.__UNISTYLES_STATE__ = ${JSON.stringify(state)}`}</script>
</>
)
}
Expand All @@ -35,6 +35,6 @@ export const useServerUnistyles = () => {
})

if (typeof window !== 'undefined') {
UnistylesWeb.registry.css.hydrate(window.UNISTYLES_STATE)
UnistylesWeb.registry.css.hydrate(window.__UNISTYLES_STATE__)
}
}
2 changes: 1 addition & 1 deletion src/web/convert/object/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Filters } from '../types'
import { getObjectStyle } from './objectStyle'
import { normalizeColor, normalizeNumericValue } from '../utils'
import { isUnistylesMq } from '../../../mq'
import { UnistylesWeb } from '../..'
import { UnistylesWeb } from '../../index'

const getDropShadowStyle = (dropShadow: DropShadowValue) => {
const { offsetX = 0, offsetY = 0, standardDeviation = 0, color = '#000' } = dropShadow
Expand Down
4 changes: 2 additions & 2 deletions src/web/create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { StyleSheetWithSuperPowers, StyleSheet } from '../types/stylesheet'
import { UnistylesWeb } from '.'
import { UnistylesWeb } from './index'
import { assignSecrets, error, removeInlineStyles } from './utils'

const useVariants = ['useVariants', () => {}]
Expand All @@ -10,7 +10,7 @@ export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>, id?: s
}

const computedStylesheet = typeof stylesheet === 'function'
? stylesheet(UnistylesWeb.runtime.theme, UnistylesWeb.runtime.miniRuntime)
? stylesheet(UnistylesWeb.runtime.theme, UnistylesWeb.runtime.miniRuntime)
: stylesheet

const addSecrets = (value: any, key: string, args?: Array<any>) => assignSecrets(value, {
Expand Down
4 changes: 2 additions & 2 deletions src/web/utils/unistyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../
import { isUnistylesMq, parseMq } from '../../mq'
import { keyInObject, reduceObject } from './common'
import type { UnistylesBreakpoints } from '../../global'
import { UnistylesWeb } from '..'
import { UnistylesWeb } from '../index'

export const schemeToTheme = (scheme: ColorScheme) => {
switch (scheme) {
Expand Down Expand Up @@ -66,7 +66,7 @@ export const getMediaQuery = (query: string, allBreakpoints: Array<string>) => {
const breakpointValue = UnistylesWeb.runtime.breakpoints[query as keyof UnistylesBreakpoints] ?? 0
const nextBreakpoint = allBreakpoints
.filter((b): b is keyof UnistylesBreakpoints => b in UnistylesWeb.runtime.breakpoints)
.map(b => UnistylesWeb.runtime.breakpoints[b] ?? 1)
.map(b => UnistylesWeb.runtime.breakpoints[b] as number)
.sort((a, b) => a - b)
.find(b => b > breakpointValue)
const queries = [
Expand Down
6 changes: 5 additions & 1 deletion src/web/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ type StylesWithVariants = {
styles: Record<string, any>
}>
}
const hasVariants = <T extends object>(value: [string, T]): value is [string, T & StylesWithVariants] => isDefined(value[1]) && 'variants' in value[1]
const hasVariants = <T extends object>(value: [string, T]): value is [string, T & StylesWithVariants] => {
const [, styleValue] = value

return isDefined(styleValue) && 'variants' in styleValue
}

export const getVariants = (styles: ReactNativeStyleSheet<StyleSheet>, selectedVariants: Record<string, any>) => {
return Object.entries(styles)
Expand Down

0 comments on commit 63e7410

Please sign in to comment.