From 46c74b5ee9b21410a42dd31fad2a81016ca64d5d Mon Sep 17 00:00:00 2001 From: "m.usman" Date: Fri, 18 Oct 2024 22:29:57 +0200 Subject: [PATCH 1/2] feat: added image object for image handling in horizontal card component --- .../content/Cards/CardHorizontal.stories.tsx | 9 ++++- .../content/Cards/CardHorizontal.tsx | 40 +++++++++---------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/components/content/Cards/CardHorizontal.stories.tsx b/src/components/content/Cards/CardHorizontal.stories.tsx index 7c7d070b..bc87d551 100644 --- a/src/components/content/Cards/CardHorizontal.stories.tsx +++ b/src/components/content/Cards/CardHorizontal.stories.tsx @@ -41,8 +41,13 @@ CardHorizontal.args = { description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', borderRadius: 20, - imagePath: '', - imageAlt: 'App Card ', + image: { + src: 'https://raw.githubusercontent.com/eclipse-tractusx/portal-assets/main/public/assets/images/logos/cx-short.svg', + alt: 'alt text', + style: { + color: 'red', + }, + }, status: StatusVariants.release, statusText: 'In Release', buttonText: 'Details', diff --git a/src/components/content/Cards/CardHorizontal.tsx b/src/components/content/Cards/CardHorizontal.tsx index e0a72fa8..cb43f1c2 100644 --- a/src/components/content/Cards/CardHorizontal.tsx +++ b/src/components/content/Cards/CardHorizontal.tsx @@ -20,23 +20,29 @@ import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown' import { Box, useTheme } from '@mui/material' -import { useRef } from 'react' -import { LogoGrayData } from '../../basic/Image' +import { useRef, type CSSProperties } from 'react' +import { Image, LogoGrayData } from '../../basic/Image' import { Typography } from '../../basic/Typography' import { type CardChipProps } from './CardChip' +interface ICardImage { + src: string + alt?: string + style?: CSSProperties +} + interface CardHorizontalProps extends CardChipProps { label: string title: string subTitle?: string borderRadius: number - imagePath: string - imageAlt?: string description?: string backgroundColor?: string buttonText?: string onBtnClick?: React.MouseEventHandler expandOnHover?: boolean + image: ICardImage + imageLoader?: (src: string) => Promise } export const CardHorizontal = ({ @@ -44,9 +50,6 @@ export const CardHorizontal = ({ title, subTitle, borderRadius = 0, - imagePath, - // @ts-expect-error keep for backward compatibility - imageAlt, description, // @ts-expect-error keep for backward compatibility status, @@ -55,6 +58,8 @@ export const CardHorizontal = ({ buttonText, onBtnClick, backgroundColor, + image, + imageLoader, // @ts-expect-error keep for backward compatibility expandOnHover = false, }: CardHorizontalProps) => { @@ -76,19 +81,14 @@ export const CardHorizontal = ({ }, }} > - + {image && ( + {image?.alt} + )} Date: Mon, 21 Oct 2024 10:40:50 +0200 Subject: [PATCH 2/2] chore: changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bf5851e..3c1f7ddd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -113,6 +113,7 @@ - simplify and automate release versioning ([3824c8c](https://github.com/eclipse-tractusx/portal-shared-components/commit/3824c8ccec94cbc5856c7094d92d7db21058f304)) - **table:** support pagination in table component ([fc362a0](https://github.com/eclipse-tractusx/portal-shared-components/commit/fc362a08d2c881273f1cc3f9dd07cf26ad099547)) +- Horizontalcard component support image object(https://github.com/eclipse-tractusx/portal-shared-components/pull/355) ## 3.1.2