Optimize FitCenter and FitFullScreen

This commit is contained in:
2023-09-11 23:22:27 +08:00
parent be12a7a753
commit 28ff5c5534
2 changed files with 13 additions and 6 deletions

View File

@@ -1,10 +1,13 @@
import React from 'react' import React from 'react'
import '@/assets/css/fit-center.scss' import '@/assets/css/fit-center.scss'
const FitCenter: React.FC<React.PropsWithChildren> = (props) => { const FitCenter: React.FC<
React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>
> = (props) => {
const { className, ..._props } = props
return ( return (
<> <>
<div className={'fit-center'}>{props.children}</div> <div className={`fit-center${className ? ' ' + className : ''}`} {..._props}></div>
</> </>
) )
} }

View File

@@ -1,21 +1,25 @@
import React from 'react' import React from 'react'
import '@/assets/css/fit-fullscreen.scss' import '@/assets/css/fit-fullscreen.scss'
interface FitFullscreenProps extends React.PropsWithChildren { interface FitFullscreenProps
extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> {
zIndex?: number zIndex?: number
backgroundColor?: string backgroundColor?: string
} }
const FitFullScreen = forwardRef<HTMLDivElement, FitFullscreenProps>((props, ref) => { const FitFullScreen = forwardRef<HTMLDivElement, FitFullscreenProps>((props, ref) => {
const { zIndex, backgroundColor, className, style, ..._props } = props
return ( return (
<> <>
<div <div
className={'fit-fullscreen'} className={`fit-fullscreen${className ? ' ' + className : ''}`}
style={{ style={{
zIndex: props.zIndex, zIndex,
backgroundColor: props.backgroundColor backgroundColor,
...style
}} }}
ref={ref} ref={ref}
{..._props}
> >
{props.children} {props.children}
</div> </div>