Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add iconStyle prop #133

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/components/surfaces/Card/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
import React from 'react'
import PropTypes from 'prop-types'
import MuiCard, { CardContent, iconStyle } from './CardStyles'
import MuiCard, { CardContent, iconStyle as baseIconStyle } from './CardStyles'
import CardMedia from '@mui/material/CardMedia'
import { any, isNil } from 'ramda'
import { CardProps, CardColor } from './types'
Expand Down Expand Up @@ -47,14 +47,15 @@ const Card: React.FC<CardProps> = ({
mediaProps,
avatarProps,
headerContentProps,
iconStyle = {},
...props
}) => {
const hasIcon = !!Icon

const cardHeaderProps = {
title,
subheader,
avatar: Icon && <Icon style={iconStyle} />,
avatar: Icon && <Icon style={{ ...baseIconStyle, ...iconStyle }} />,
actions,
filled,
...headerProps
Expand Down Expand Up @@ -166,7 +167,12 @@ Card.propTypes = {
* @default {}
* Props applied to the CardHeader component.
*/
headerContentProps: PropTypes.object
headerContentProps: PropTypes.object,
/**
* @default {}
* Style applied to icon avatar.
*/
iconStyle: PropTypes.object
}

export default Card
4 changes: 4 additions & 0 deletions src/components/surfaces/Card/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,8 @@ export interface CardProps extends Omit<MuiCardProps, 'title'> {
* Style applied to the header content.
*/
headerContentProps?: HTMLAttributes<HTMLDivElement>
/**
* Icon style.
*/
iconStyle?: React.CSSProperties
}
Loading