Skip to content

Commit

Permalink
feat: add card layout background border
Browse files Browse the repository at this point in the history
  • Loading branch information
qradle-yndx committed Jan 11, 2024
1 parent 0457a44 commit 345c72e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/blocks/CardLayout/CardLayout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ $block: '.#{$ns}card-layout-block';
object-fit: cover;
object-position: left;
}

@include card-border();
}

@include animate-slides(#{$block}__item);
Expand Down
6 changes: 5 additions & 1 deletion src/blocks/CardLayout/CardLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const CardLayout: React.FC<CardLayoutBlockProps> = ({
className,
titleClassName,
background,
backgroundBorder = 'none',
}) => {
return (
<AnimateBlock className={b(null, className)} animate={animated}>
Expand All @@ -43,7 +44,10 @@ const CardLayout: React.FC<CardLayoutBlockProps> = ({
'with-background': !isEmpty(background),
})}
>
<BackgroundImage className={b('image')} {...background} />
<BackgroundImage
className={b('image', {border: backgroundBorder})}
{...background}
/>
<Row>
{React.Children.map(children, (child, index) => (
<Col key={index} sizes={colSizes} className={b('item')}>
Expand Down
4 changes: 4 additions & 0 deletions src/blocks/CardLayout/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export const CardLayoutProps = {
...BlockHeaderProps,
colSizes: containerSizesObject,
background: BackgroundImageProps,
backgroundBorder: {
type: 'string',
enum: ['line', 'shadow', 'none'],
},
children: ChildrenCardsProps,
},
};
Expand Down
2 changes: 2 additions & 0 deletions src/models/constructor-items/blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Animatable,
BackgroundImageProps,
ButtonProps,
CardBorder,
ContentSize,
ContentTextSize,
ContentTheme,
Expand Down Expand Up @@ -306,6 +307,7 @@ export interface CardLayoutBlockProps extends Childable, Animatable, LoadableChi
description?: string;
colSizes?: GridColumnSizesType;
background?: BackgroundImageProps;
backgroundBorder?: CardBorder;
}

export type FilterTag = {
Expand Down
21 changes: 12 additions & 9 deletions styles/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -252,15 +252,7 @@
border-radius: $borderRadius;
}

@mixin card($hover: false) {
min-height: 248px;
height: 100%;
overflow-x: hidden;
border-radius: $borderRadius;
background-color: var(--g-color-base-float);

transition: box-shadow 0.3s $ease-out-cubic;

@mixin card-border($hover: false) {
&_border_line {
border: 1px solid var(--g-color-line-generic);
}
Expand All @@ -283,6 +275,17 @@
}
}

@mixin card($hover: false) {
min-height: 248px;
height: 100%;
overflow-x: hidden;
border-radius: $borderRadius;
background-color: var(--g-color-base-float);

transition: box-shadow 0.3s $ease-out-cubic;
@include card-border($hover);
}

@mixin card-image {
margin: $imagePadding;
border-radius: calc(#{$borderRadius} - #{$imagePadding});
Expand Down

0 comments on commit 345c72e

Please sign in to comment.