From 953c3c0dad0059c21662343527af3b7aa5faba0c Mon Sep 17 00:00:00 2001 From: evavirseda Date: Wed, 21 Aug 2024 16:50:08 +0200 Subject: [PATCH] feat(apps-ui-kit): add `VisualAssetCard` component (#1918) * feat: add visualAssetCard component * feat: improvements * feat: improvemetns * feat: rename fucntion --------- --- apps/ui-kit/src/lib/components/atoms/index.ts | 1 + .../visual-asset-card/VisualAssetCard.tsx | 75 +++++++++++++++++++ .../atoms/visual-asset-card/index.ts | 5 ++ .../visual-asset-card.enums.ts | 7 ++ .../stories/atoms/VisualAssetCard.stories.tsx | 56 ++++++++++++++ 5 files changed, 144 insertions(+) create mode 100644 apps/ui-kit/src/lib/components/atoms/visual-asset-card/VisualAssetCard.tsx create mode 100644 apps/ui-kit/src/lib/components/atoms/visual-asset-card/index.ts create mode 100644 apps/ui-kit/src/lib/components/atoms/visual-asset-card/visual-asset-card.enums.ts create mode 100644 apps/ui-kit/src/storybook/stories/atoms/VisualAssetCard.stories.tsx diff --git a/apps/ui-kit/src/lib/components/atoms/index.ts b/apps/ui-kit/src/lib/components/atoms/index.ts index d1885a262f7..7966854f54a 100644 --- a/apps/ui-kit/src/lib/components/atoms/index.ts +++ b/apps/ui-kit/src/lib/components/atoms/index.ts @@ -16,3 +16,4 @@ export * from './panel'; export * from './tooltip'; export * from './info-box'; export * from './snackbar'; +export * from './visual-asset-card'; diff --git a/apps/ui-kit/src/lib/components/atoms/visual-asset-card/VisualAssetCard.tsx b/apps/ui-kit/src/lib/components/atoms/visual-asset-card/VisualAssetCard.tsx new file mode 100644 index 00000000000..bf36f18243e --- /dev/null +++ b/apps/ui-kit/src/lib/components/atoms/visual-asset-card/VisualAssetCard.tsx @@ -0,0 +1,75 @@ +// Copyright (c) 2024 IOTA Stiftung +// SPDX-License-Identifier: Apache-2.0 + +import React from 'react'; +import { VisualAssetType } from './visual-asset-card.enums'; +import { ButtonUnstyled } from '../button'; +import { MoreHoriz } from '@iota/ui-icons'; + +export interface VisualAssetCardProps { + /** + * The type of the asset to be displayed. + */ + assetType?: VisualAssetType; + /** + * The source of the image to be displayed. + */ + assetSrc: string; + /** + * Alt text for the image. + */ + altText: string; + /** + * The onClick event for the icon. + */ + onIconClick?: (e: React.MouseEvent) => void; + /** + * The onClick event for the card. + */ + onClick?: (e: React.MouseEvent) => void; + /** + * The icon to be displayed. + */ + icon: React.ReactNode; + /** + * The title text to be displayed on hover. + */ + assetTitle?: string; +} + +export function VisualAssetCard({ + assetType = VisualAssetType.Image, + assetSrc, + altText, + onIconClick, + onClick, + icon = , + assetTitle, +}: VisualAssetCardProps): React.JSX.Element { + const handleIconClick = (event: React.MouseEvent) => { + onIconClick?.(event); + event?.stopPropagation(); + }; + return ( +
+ {assetType === VisualAssetType.Video ? ( +