diff --git a/src/components/Card.tsx b/src/components/Card.tsx
index 449454da..26546ac6 100644
--- a/src/components/Card.tsx
+++ b/src/components/Card.tsx
@@ -12,6 +12,7 @@ import {
toFillLevel,
useFillLevel,
} from './contexts/FillLevelContext'
+import WrapWithIf from './WrapWithIf'
const CARD_SEVERITIES = [
'info',
@@ -38,6 +39,7 @@ type BaseCardProps = {
size?: 'medium' | 'large'
content?: ReactNode
headerProps?: ComponentProps<'div'>
+ outerProps?: ComponentProps<'div'>
}
}
@@ -137,24 +139,37 @@ const getBgColor = ({
}
const HeaderSC = styled.div<{
- fillLevel: CardFillLevel
- selected: boolean
- size: 'medium' | 'large'
-}>(({ theme, fillLevel, selected, size }) => ({
- ...theme.partials.text.overline,
- display: 'flex',
- alignItems: 'center',
- color: theme.colors['text-xlight'],
- borderBottom: `1px solid ${theme.colors[fillToNeutralBorderC[fillLevel]]}`,
- backgroundColor: selected
- ? theme.colors[fillToNeutralSelectedBgC[fillLevel]]
- : getBgColor({ theme, fillLevel }),
- height: size === 'large' ? 48 : 40,
- padding: `0 ${theme.spacing.medium}px`,
- overflow: 'hidden',
-}))
+ $fillLevel: CardFillLevel
+ $selected: boolean
+ $size: 'medium' | 'large'
+ $cornerSize: CornerSize
+}>(
+ ({
+ theme,
+ $fillLevel: fillLevel,
+ $selected: selected,
+ $size: size,
+ $cornerSize: cornerSize,
+ }) => ({
+ ...theme.partials.text.overline,
+ flexShrink: 0,
+ display: 'flex',
+ alignItems: 'center',
+ color: theme.colors['text-xlight'],
+ border: `1px solid ${theme.colors[fillToNeutralBorderC[fillLevel]]}`,
+ borderBottom: 'none',
+ borderRadius: `${theme.borderRadiuses[cornerSize]}px ${theme.borderRadiuses[cornerSize]}px 0 0`,
+ backgroundColor: selected
+ ? theme.colors[fillToNeutralSelectedBgC[fillLevel]]
+ : getBgColor({ theme, fillLevel }),
+ height: size === 'large' ? 48 : 40,
+ padding: `0 ${theme.spacing.medium}px`,
+ overflow: 'hidden',
+ })
+)
const CardSC = styled(Div)<{
+ $hasHeader: boolean
$fillLevel: CardFillLevel
$cornerSize: CornerSize
$severity: Severity
@@ -164,6 +179,7 @@ const CardSC = styled(Div)<{
}>(
({
theme,
+ $hasHeader,
$fillLevel: fillLevel,
$cornerSize: cornerSize,
$severity: severity,
@@ -172,8 +188,16 @@ const CardSC = styled(Div)<{
$disabled: disabled,
}) => ({
...theme.partials.reset.button,
- border: `1px solid ${theme.colors[fillToNeutralBorderC[fillLevel]]}`,
- borderRadius: theme.borderRadiuses[cornerSize],
+ border: `1px solid ${
+ theme.colors[
+ fillToNeutralBorderC[
+ $hasHeader ? toFillLevel(fillLevel + 1) : fillLevel
+ ]
+ ]
+ }`,
+ borderRadius: $hasHeader
+ ? `0 0 ${theme.borderRadiuses[cornerSize]}px ${theme.borderRadiuses[cornerSize]}px`
+ : theme.borderRadiuses[cornerSize],
backgroundColor: selected
? theme.colors[fillToNeutralSelectedBgC[fillLevel]]
: getBgColor({ theme, fillLevel }),
@@ -199,6 +223,14 @@ const CardSC = styled(Div)<{
})
)
+const OuterWrapSC = styled.div({
+ display: 'flex',
+ flexDirection: 'column',
+ overflow: 'hidden',
+ width: '100%',
+ height: '100%',
+})
+
const Card = forwardRef(
(
{
@@ -214,7 +246,13 @@ const Card = forwardRef(
}: CardProps,
ref
) => {
- const { size, content: headerContent, headerProps } = header ?? {}
+ const hasHeader = !!header
+ const {
+ size,
+ content: headerContent,
+ headerProps,
+ outerProps,
+ } = header ?? {}
const mainFillLevel = useDecideFillLevel({ fillLevel })
const headerFillLevel = useDecideFillLevel({ fillLevel: mainFillLevel + 1 })
@@ -226,33 +264,40 @@ const Card = forwardRef(
return (
- }
>
{header && (
{headerContent}
)}
- {children}
-
+
+ {children}
+
+
)
}
diff --git a/src/stories/Card.stories.tsx b/src/stories/Card.stories.tsx
index 91e83a38..32aacdf4 100644
--- a/src/stories/Card.stories.tsx
+++ b/src/stories/Card.stories.tsx
@@ -1,4 +1,3 @@
-import { Flex } from 'honorable'
import { type ComponentProps, type ReactNode } from 'react'
import { useTheme } from 'styled-components'
@@ -6,7 +5,7 @@ import { useTheme } from 'styled-components'
import { type FillLevel } from '../components/contexts/FillLevelContext'
import type { CardProps } from '../components/Card'
-import { Card, InfoOutlineIcon, Tooltip } from '../index'
+import { Card, Flex, InfoOutlineIcon, Tooltip } from '../index'
export default {
title: 'Card',
@@ -72,7 +71,6 @@ function Template({
}}
>
- {fillLevels.map((fillLevel) => (
+ {fillLevels.map((fillLevel, index) => (
fillLevel=
{fillLevel === undefined ? 'undefined' : `"${fillLevel}"`}
@@ -178,4 +181,13 @@ WithFillLevelContext.args = {
clickable: false,
disabled: false,
width: 400,
+ headerSize: 'medium',
+ headerContent: (
+
+ Header
+
+
+
+
+ ),
}