From 12b0d29774ca01a6fb01f65c79d7ed1409175c30 Mon Sep 17 00:00:00 2001 From: qradle Date: Mon, 12 Feb 2024 15:56:38 +0300 Subject: [PATCH] fix: image card storybook --- src/sub-blocks/ImageCard/ImageCard.scss | 28 +++++++++++++------ src/sub-blocks/ImageCard/ImageCard.tsx | 7 +++-- .../__stories__/ImageCard.stories.tsx | 25 ++++++++++++++++- .../ImageCard/__stories__/data.json | 14 ++++++++++ 4 files changed, 63 insertions(+), 11 deletions(-) diff --git a/src/sub-blocks/ImageCard/ImageCard.scss b/src/sub-blocks/ImageCard/ImageCard.scss index 1f007de82..7c57e78f4 100644 --- a/src/sub-blocks/ImageCard/ImageCard.scss +++ b/src/sub-blocks/ImageCard/ImageCard.scss @@ -9,13 +9,13 @@ $paddingS: 4px; @include card(); min-height: 1px; border-radius: $indentSM; + $image: #{&}__image; + $content: #{&}__content; - &__content { - padding: $indentSM $indentM $indentM $indentM; + #{$content} { + padding: $indentM; } - $image: #{&}__image; - #{$image} { &_inner { width: 100%; @@ -38,12 +38,24 @@ $paddingS: 4px; } &_with-content { - #{$image}_direction_direct { - padding-bottom: 0; + &#{$block}_direction_direct { + #{$image} { + padding-bottom: 0; + } + + #{$content} { + padding-top: $indentSM; + } } - #{$image}_direction_reverse { - padding-top: 0; + &#{$block}_direction_reverse { + #{$image} { + padding-top: 0; + } + + #{$content} { + padding-bottom: $indentSM; + } } } } diff --git a/src/sub-blocks/ImageCard/ImageCard.tsx b/src/sub-blocks/ImageCard/ImageCard.tsx index 31957098e..8c84db2eb 100644 --- a/src/sub-blocks/ImageCard/ImageCard.tsx +++ b/src/sub-blocks/ImageCard/ImageCard.tsx @@ -36,14 +36,17 @@ const ImageCard = (props: ImageCardProps) => { const renderImage = () => { const imageProps = getMediaImage(image); return ( -
+
); }; return ( -
+
{direction === ImageCardDirection.Direct && ( {renderImage()} diff --git a/src/sub-blocks/ImageCard/__stories__/ImageCard.stories.tsx b/src/sub-blocks/ImageCard/__stories__/ImageCard.stories.tsx index 7e1cfd524..fdf7c9ed8 100644 --- a/src/sub-blocks/ImageCard/__stories__/ImageCard.stories.tsx +++ b/src/sub-blocks/ImageCard/__stories__/ImageCard.stories.tsx @@ -54,11 +54,34 @@ const ContentTemplate: StoryFn = (args) => (
); +const MultipleContentTemplate: StoryFn = (args) => ( +
+ )} /> + )} /> + )} /> +
+); + +const BorderTemplate: StoryFn = (args) => ( +
+
+ )} /> +
+
+ )} /> +
+
+ )} /> +
+
+); + export const Default = DefaultTemplate.bind({}); export const Margins = MultipleTemplate.bind({}); export const DirectionReverse = MultipleTemplate.bind({}); -export const Content = ContentTemplate.bind({}); +export const Content = MultipleContentTemplate.bind({}); export const BackgroundColor = MultipleTemplate.bind({}); +export const Border = BorderTemplate.bind({}); DirectionReverse.args = {direction: 'reverse'} as Partial; BackgroundColor.args = {...data.backgroundColor.content}; diff --git a/src/sub-blocks/ImageCard/__stories__/data.json b/src/sub-blocks/ImageCard/__stories__/data.json index df703714f..4edf40c34 100644 --- a/src/sub-blocks/ImageCard/__stories__/data.json +++ b/src/sub-blocks/ImageCard/__stories__/data.json @@ -28,6 +28,20 @@ "direction": "reverse" } }, + "border": { + "shadow": { + "border": "shadow (default)", + "title": "border: 'shadow'" + }, + "line": { + "border": "line", + "title": "border: 'line'" + }, + "none": { + "border": "none", + "title": "border: 'none'" + } + }, "backgroundColor": { "content": { "backgroundColor": "#ccf0d2"