/** @jsxImportSource @emotion/react */ import { css } from '@emotion/react'; import { useState, useEffect } from 'react'; import { RcIconAngleDown, RcIconAngleUp } from '../icons'; export interface RcCardProps { initShow?: boolean; withShowHide?: boolean; width?: string; minWidth?: string; maxHeight?: string; iconSize?: string; iconPadding?: string; borderRadius?: string; bgColor?: string; headerColor?: string; headerBgColor?: string; headerHeight?: string; headerPaddingHoriz?: string; title?: string; titleBgColor?: string; titleBorderColor?: string; paddingVert?: string; paddingHoriz?: string; cssTitle?: string; } export const RcCard: React.FC = ({ initShow = true, withShowHide = true, width = '100%', minWidth, maxHeight, iconSize = '20px', iconPadding = '25px', borderRadius = '8px', bgColor = '#ffffff', headerColor = '#484848', headerBgColor = '#ffffff', headerHeight = '52px', headerPaddingHoriz = '20px', title, paddingVert = '5px', paddingHoriz = '10px', cssTitle = `font-weight: bold;`, children, }) => { const [show, setShow] = useState(true); useEffect(() => { setShow(!!initShow); }, [initShow]); const contentMaxHeight = maxHeight ? `calc(${maxHeight} - ${headerHeight})` : ''; return (
{title && (
{ if (withShowHide) { setShow(!show); } }} >
{cssTitle ? {title} : {title}}
)} {show && (
{children}
)} {withShowHide && (
setShow(!show)} > {show ? : }
)}
); };