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