Skip to content

Commit

Permalink
fix: backward compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
KochiyaOcean committed Mar 10, 2024
1 parent b4216b8 commit d6e16a5
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 55 deletions.
66 changes: 42 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
"path-extra": "^4.3.0",
"poi-asset-contributor-data": "^1.1.3",
"poi-asset-themes": "^4.6.0",
"poi-lib-battle": "^2.15.0",
"poi-lib-battle": "^2.18.0",
"polished": "^4.2.2",
"prop-types": "^15.8.1",
"react": "^18.2.0",
Expand Down Expand Up @@ -188,7 +188,7 @@
"asar": "^3.2.0",
"babel-jest": "^28.1.3",
"cross-env": "^7.0.3",
"electron": "^28.1.1",
"electron": "^29.1.0",
"electron-builder": "^23.3.3",
"eslint": "^8.22.0",
"eslint-config-prettier": "^8.5.0",
Expand Down
51 changes: 22 additions & 29 deletions views/components/etc/overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,55 @@
import React, { useContext, ReactNode } from 'react'
import React, { useContext, Children, ReactNode } from 'react'
import {
Alert as BAlert,
Dialog as BDialog,
Overlay as BOverlay,
AlertProps as BAlertProps,
DialogProps as BDialogProps,
OverlayProps as BOverlayProps,
Popover as BPopover,
Tooltip as BTooltip,
PopoverProps as BPopoverProps,
TooltipProps as BTooltipProps,
type AlertProps,
type DialogProps,
type OverlayProps,
type PopoverProps,
type TooltipProps,
} from '@blueprintjs/core'
import { WindowEnv } from './window-env'

interface AlertProps extends BAlertProps {
children: ReactNode
}
const getSecondChildren = (children: ReactNode) =>
Children.count(children) > 1
? (Children.toArray(children)[1] as PopoverProps['content'])
: undefined

export const Alert: React.FC<AlertProps> = ({ children, ...props }) => (
<BAlert portalContainer={useContext(WindowEnv).mountPoint} {...props}>
{children}
</BAlert>
)

interface DialogProps extends BDialogProps {
children: ReactNode
}

export const Dialog: React.FC<DialogProps> = ({ children, ...props }) => (
<BDialog portalContainer={useContext(WindowEnv).mountPoint} {...props}>
{children}
</BDialog>
)

interface TooltipProps extends BTooltipProps {
children: ReactNode
}

export const Tooltip: React.FC<TooltipProps> = ({ children, ...props }) => (
<BTooltip portalContainer={useContext(WindowEnv).mountPoint} {...props}>
export const Tooltip: React.FC<TooltipProps> = ({ children, content, ...props }) => (
<BTooltip
portalContainer={useContext(WindowEnv).mountPoint}
{...props}
content={content || getSecondChildren(children)}
>
{children}
</BTooltip>
)

interface PopoverProps extends BPopoverProps {
children: ReactNode
}

export const Popover: React.FC<PopoverProps> = ({ children, ...props }) => (
<BPopover portalContainer={useContext(WindowEnv).mountPoint} {...props}>
export const Popover: React.FC<PopoverProps> = ({ children, content, ...props }) => (
<BPopover
portalContainer={useContext(WindowEnv).mountPoint}
{...props}
content={content || getSecondChildren(children)}
>
{children}
</BPopover>
)

interface OverlayProps extends BOverlayProps {
children: ReactNode
}

export const Overlay: React.FC<OverlayProps> = ({ children, ...props }) => (
<BOverlay portalContainer={useContext(WindowEnv).mountPoint} {...props}>
{children}
Expand Down

0 comments on commit d6e16a5

Please sign in to comment.