Skip to content

Commit

Permalink
fix: layout item content margin (#1104)
Browse files Browse the repository at this point in the history
* fix: add layout item content right margin
  • Loading branch information
qradle-yndx authored Jan 29, 2025
1 parent dc04d43 commit fc44210
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 3 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/models/constructor-items/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export type ContentTextSize = 's' | 'm' | 'l';
export type ContentTheme = 'default' | 'dark' | 'light';
export type FileLinkType = 'vertical' | 'horizontal';
export type ImageCardMargins = 's' | 'm';
export type LayoutItemContentMargin = 'm' | 'l';

// modifiers
export interface Themable {
Expand Down
2 changes: 2 additions & 0 deletions src/models/constructor-items/sub-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
ImageCardMargins,
ImageObjectProps,
ImageProps,
LayoutItemContentMargin,
LinkProps,
MediaProps,
MediaView,
Expand Down Expand Up @@ -182,6 +183,7 @@ export interface PriceCardProps extends CardBaseProps, Pick<ContentBlockProps, '

export interface LayoutItemProps extends ClassNameProps, CardLayoutProps, AnalyticsEventsBase {
content: Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size'>;
contentMargin?: LayoutItemContentMargin;
media?: ThemeSupporting<MediaProps>;
metaInfo?: string[];
border?: boolean;
Expand Down
24 changes: 22 additions & 2 deletions src/sub-blocks/LayoutItem/LayoutItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

$block: '.#{$ns}layout-item';

$contentMarginM: 40px;
$contentMarginL: 80px;

#{$block} {
display: flex;
flex-direction: column;
Expand All @@ -26,14 +29,31 @@ $block: '.#{$ns}layout-item';
display: flex;

flex: auto;
margin: $indentXS $indentXS 0 0;
margin-top: $indentXS;
margin-left: 0;
margin-bottom: 0;

&_no-media {
margin: 0;
margin-top: 0;
}

&_margin {
&_m {
margin-right: $contentMarginM;
}
&_l {
margin-right: $contentMarginL;
}
}
}

&__wrapper {
flex: auto;
}

@media (max-width: map-get($gridBreakpoints, 'sm') - 1) {
&__content {
margin-right: 0;
}
}
}
3 changes: 2 additions & 1 deletion src/sub-blocks/LayoutItem/LayoutItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const b = block('layout-item');

const LayoutItem = ({
content: {links, ...content},
contentMargin = 'm',
metaInfo,
media,
border,
Expand Down Expand Up @@ -77,7 +78,7 @@ const LayoutItem = ({
<div className={b(null, className)}>
{renderMedia()}
{metaInfo && <MetaInfo items={metaInfo} className={b('meta-info')} />}
<div className={b('content', {'no-media': !media})}>
<div className={b('content', {'no-media': !media, margin: contentMargin})}>
<IconWrapper icon={themedIcon} className={b('wrapper')}>
<Content {...contentProps} titleId={titleId} />
</IconWrapper>
Expand Down
2 changes: 2 additions & 0 deletions src/sub-blocks/LayoutItem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

`content: Partial<Content>` - `Content` props (size and justify props like `colSizes`, `centered`, `size` are omitted) (see [Content](?path=/story/components-content--default))

`contentMargin?: 'm' | 'l'` — Content right margin ('m' by default)

`metaInfo?: string[]` - segmented info string above the content (with YFM support)

`border?: boolean` — Image border
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,5 @@ ControlPosition.argTypes = {
className: {table: {disable: true}},
controlPosition: {table: {disable: true}},
analyticsEvents: {table: {disable: true}},
contentMargin: {table: {disable: true}},
};
5 changes: 5 additions & 0 deletions src/sub-blocks/LayoutItem/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const LayoutItem = {
...CardLayoutProps,
media: MediaProps,
content: omit(ContentBase, ['colSize', 'size', 'centered']),
contentMargin: {
type: 'string',
enum: ['m', 'l'],
default: 'm',
},
metaInfo: metaInfo,
border: {
type: 'boolean',
Expand Down

0 comments on commit fc44210

Please sign in to comment.