Skip to content

Commit

Permalink
fix: expand react compiler to dialog, menu, theme provider
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Nov 1, 2024
1 parent 289a005 commit 0ec4752
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
6 changes: 4 additions & 2 deletions src/core/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,15 @@ export const Dialog = forwardRef(function Dialog(
onFocus,
padding: paddingProp = 3,
portal: portalProp,
position: positionProp = dialog.position || 'fixed',
position: _positionProp,
scheme,
width: widthProp = 0,
zOffset: zOffsetProp = dialog.zOffset || layer.dialog.zOffset,
zOffset: _zOffsetProp,
animate: _animate = false,
...restProps
} = props
const positionProp = _positionProp ?? (dialog.position || 'fixed')
const zOffsetProp = _zOffsetProp ?? (dialog.zOffset || layer.dialog.zOffset)
const prefersReducedMotion = usePrefersReducedMotion()
const animate = prefersReducedMotion ? false : _animate
const portal = usePortal()
Expand Down
4 changes: 3 additions & 1 deletion src/core/components/menu/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ export const Menu = forwardRef(function Menu(
originElement,
padding = 1,
registerElement,
shouldFocus = (props.focusFirst && 'first') || (props.focusLast && 'last') || null,
shouldFocus: _shouldFocus,
space = 1,
...restProps
} = props
const shouldFocus =
_shouldFocus ?? ((props.focusFirst && 'first') || (props.focusLast && 'last') || null)

const ref = useRef<HTMLDivElement | null>(null)

Expand Down
3 changes: 2 additions & 1 deletion src/core/components/menu/menuGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ export function MenuGroup(
onClickOutside,
onEscape,
onItemClick,
onItemMouseEnter = menu.onMouseEnter,
onItemMouseEnter: _onItemMouseEnter,
registerElement,
} = menu
const onItemMouseEnter = _onItemMouseEnter ?? menu.onMouseEnter
const [rootElement, setRootElement] = useState<HTMLButtonElement | HTMLDivElement | null>(null)
const [open, setOpen] = useState(false)
const [shouldFocus, setShouldFocus] = useState<'first' | 'last' | null>(null)
Expand Down
6 changes: 4 additions & 2 deletions src/core/components/menu/menuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,11 @@ export const MenuItem = forwardRef(function MenuItem(
activeElement,
mount,
onItemClick,
onItemMouseEnter = menu.onMouseEnter,
onItemMouseLeave = menu.onMouseLeave,
onItemMouseEnter: _onItemMouseEnter,
onItemMouseLeave: _onItemMouseLeave,
} = menu
const onItemMouseEnter = _onItemMouseEnter ?? menu.onMouseEnter
const onItemMouseLeave = _onItemMouseLeave ?? menu.onMouseLeave
const [rootElement, setRootElement] = useState<HTMLDivElement | null>(null)
const active = Boolean(activeElement) && activeElement === rootElement
const ref = useRef<HTMLDivElement | null>(null)
Expand Down
10 changes: 4 additions & 6 deletions src/core/theme/themeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ export interface ThemeProviderProps {
*/
export function ThemeProvider(props: ThemeProviderProps): React.ReactElement {
const parentTheme = useContext(ThemeContext)
const {
children,
scheme = parentTheme?.scheme || 'light',
theme: rootTheme = parentTheme?.theme || null,
tone = parentTheme?.tone || 'default',
} = props
const {children} = props
const scheme = props.scheme ?? (parentTheme?.scheme || 'light')
const rootTheme = props.theme ?? (parentTheme?.theme || null)
const tone = props.tone ?? (parentTheme?.tone || 'default')

const themeContext: ThemeContextValue | null = useMemo(() => {
if (!rootTheme) return null
Expand Down

0 comments on commit 0ec4752

Please sign in to comment.