Skip to content

Commit

Permalink
remove setting padding to 0 on card header
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianchircats committed Jan 9, 2025
1 parent eac0356 commit 2fa2a77
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/components/surfaces/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react'
import PropTypes from 'prop-types'
import MuiCard, { CardContent, iconStyle as baseIconStyle } from './CardStyles'
import CardMedia from '@mui/material/CardMedia'
import { any, isNil, omit } from 'ramda'
import { any, isNil } from 'ramda'
import { CardProps, CardColor } from './types'
import CardHeader from './CardHeader'
import CardActions from './CardActions'
Expand Down Expand Up @@ -60,15 +60,14 @@ const Card: React.FC<CardProps> = ({
filled,
...headerProps
}
const hasHeader = any(x => !isNil(x), Object.values(omit(['avatar'], cardHeaderProps)))
const hasHeader = any(x => !isNil(x), Object.values(cardHeaderProps))

const { size, ...standardMediaProps } = mediaProps || {}

return (
<MuiCard color={color} hasIcon={hasIcon} variant={variant} {...props}>
{hasHeader && (
<CardHeader
hasHeader={hasHeader}
hasIcon={hasIcon}
iconColor={hasIcon ? (iconColor as CardColor) : undefined}
avatarProps={avatarProps}
Expand Down
4 changes: 0 additions & 4 deletions src/components/surfaces/Card/CardHeader/CardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ CardHeader.propTypes = {
* Card title
*/
title: PropTypes.node,
/**
* Indicates if the parent Card component contains an header element or not
*/
hasHeader: PropTypes.bool,
/**
* Indicates if the parent Card component contains an icon element or not
*/
Expand Down
7 changes: 2 additions & 5 deletions src/components/surfaces/Card/CardHeader/CardHeaderStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { CardColor } from '../types'
type StyledProps = {
theme: Theme
filled: boolean
hasHeader: boolean
hasIcon: boolean
iconColor: CardColor
avatarProps: any
Expand All @@ -16,20 +15,18 @@ type StyledProps = {

const CardHeader = styled(MuiCardHeader, {
shouldForwardProp: prop =>
!includes(prop, ['variant', 'hasHeader', 'hasIcon', 'iconColor', 'filled', 'avatarProps', 'headerContentProps'])
!includes(prop, ['variant', 'hasIcon', 'iconColor', 'filled', 'avatarProps', 'headerContentProps'])
})(
({
theme,
filled,
hasHeader,
hasIcon,
iconColor = 'secondary' as CardColor & keyof Palette,
avatarProps,
headerContentProps
}: Partial<StyledProps>) => ({
['&.MuiCardHeader-root']: {
...(filled && { backgroundColor: theme?.palette.grey[200], minHeight: '48px' }),
...(!hasHeader && hasIcon ? { padding: 0 } : {})
...(filled && { backgroundColor: theme?.palette.grey[200], minHeight: '48px' })
},
['& .MuiCardHeader-avatar']: {
...(hasIcon && {
Expand Down
4 changes: 0 additions & 4 deletions src/components/surfaces/Card/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ export interface CardHeaderProps extends Omit<MuiCardHeaderProps, 'action'> {
* If 'true', the card header will be filled with a grayish color
*/
filled?: boolean
/**
* Indicates if the parent Card component contains an header element or not
*/
hasHeader?: boolean
/**
* Indicates if the parent Card component contains an icon element or not
*/
Expand Down

0 comments on commit 2fa2a77

Please sign in to comment.