Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Content): revert renderСontentControls adding #840

Merged
merged 2 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/sub-blocks/BackgroundCard/BackgroundCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ $block: '.#{$ns}background-card';
object-position: left;
}
}

&__footer {
margin-top: 0px;
}

&__links,
&__buttons {
margin-top: $indentXS;
}
}

a#{$block} {
Expand Down
32 changes: 13 additions & 19 deletions src/sub-blocks/BackgroundCard/BackgroundCard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React, {useMemo} from 'react';
import React from 'react';

import {useUniqId} from '@gravity-ui/uikit';

import {BackgroundImage, CardBase} from '../../components/';
import {BackgroundImage, Buttons, CardBase, Links} from '../../components/';
import {useTheme} from '../../context/theme';
import {BackgroundCardProps} from '../../models';
import {block, getThemedValue} from '../../utils';
import renderContentControls from '../../utils/renderContentControls/renderContentControls';
import Content from '../Content/Content';
import renderCardFooterControlsContainer from '../renderCardFooterControlsContainer/renderCardFooterControlsContainer';

import './BackgroundCard.scss';

Expand Down Expand Up @@ -39,20 +37,6 @@ const BackgroundCard = (props: BackgroundCardProps) => {
const borderType = hasBackgroundColor ? 'none' : border;
const areControlsInFooter = !paddingBottom && controlPosition === 'footer';

const footerControls = useMemo(
() =>
renderContentControls(
{
links: areControlsInFooter ? links : undefined,
buttons: areControlsInFooter ? buttons : undefined,
size: 's',
titleId,
},
renderCardFooterControlsContainer,
),
[areControlsInFooter, links, buttons, titleId],
);

return (
<CardBase
className={b({padding: paddingBottom, theme: cardTheme})}
Expand All @@ -79,7 +63,17 @@ const BackgroundCard = (props: BackgroundCardProps) => {
colSizes={{all: 12, md: 12}}
/>
</CardBase.Content>
{footerControls}
{areControlsInFooter && (links || buttons) && (
<CardBase.Footer>
<Links className={b('links')} size="s" links={links} titleId={titleId} />
<Buttons
className={b('buttons')}
size="s"
buttons={buttons}
titleId={titleId}
/>
</CardBase.Footer>
)}
</CardBase>
);
};
Expand Down
9 changes: 9 additions & 0 deletions src/sub-blocks/BasicCard/BasicCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,13 @@ $block: '.#{$ns}basic-card';
@include add-specificity(&) {
min-height: auto;
}

&__footer {
margin-top: 0px;
}

&__links,
&__buttons {
margin-top: $indentXS;
}
}
31 changes: 13 additions & 18 deletions src/sub-blocks/BasicCard/BasicCard.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React, {useMemo} from 'react';
import React from 'react';

import {useUniqId} from '@gravity-ui/uikit';

import {CardBase, IconWrapper} from '../../components';
import {Buttons, CardBase, IconWrapper, Links} from '../../components';
import {BasicCardProps} from '../../models';
import {IconPosition} from '../../models/constructor-items/sub-blocks';
import {block} from '../../utils';
import renderContentControls from '../../utils/renderContentControls/renderContentControls';
import Content from '../Content/Content';
import renderCardFooterControlsContainer from '../renderCardFooterControlsContainer/renderCardFooterControlsContainer';

import './BasicCard.scss';

Expand All @@ -30,19 +28,6 @@ const BasicCard = (props: BasicCardProps) => {
const titleId = useUniqId();
const descriptionId = useUniqId();
const areControlsInFooter = controlPosition === 'footer';
const footerControls = useMemo(
() =>
renderContentControls(
{
links: areControlsInFooter ? links : undefined,
buttons: areControlsInFooter ? buttons : undefined,
size: 's',
titleId,
},
renderCardFooterControlsContainer,
),
[areControlsInFooter, links, buttons, titleId],
);

return (
<CardBase
Expand All @@ -66,7 +51,17 @@ const BasicCard = (props: BasicCardProps) => {
/>
</IconWrapper>
</CardBase.Content>
{footerControls}
{areControlsInFooter && (buttons || links) && (
<CardBase.Footer className={b('footer')}>
<Links className={b('links')} size="s" links={links} titleId={titleId} />
<Buttons
className={b('buttons')}
size="s"
buttons={buttons}
titleId={titleId}
/>
</CardBase.Footer>
)}
</CardBase>
);
};
Expand Down
8 changes: 6 additions & 2 deletions src/sub-blocks/Content/Content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ $darkSecondary: var(--g-color-text-dark-secondary);
}
}

#{$block}__list {
#{$block}__list,
#{$block}__links,
#{$block}__buttons {
margin-top: $indentXS;
}
}
Expand All @@ -110,7 +112,9 @@ $darkSecondary: var(--g-color-text-dark-secondary);
@include text-size(body-3);
}

#{$block}__list {
#{$block}__list,
#{$block}__links,
#{$block}__buttons {
margin-top: $indentSM;
}
}
Expand Down
38 changes: 22 additions & 16 deletions src/sub-blocks/Content/Content.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React, {useMemo} from 'react';
import React from 'react';

import {useUniqId} from '@gravity-ui/uikit';

import {ContentList, Title, YFMWrapper} from '../../components';
import {Buttons, ContentList, Links, Title, YFMWrapper} from '../../components';
import {Col} from '../../grid';
import {ClassNameProps, ContentBlockProps, ContentSize, TitleItemProps} from '../../models';
import {QAProps} from '../../models/common';
import {block} from '../../utils';
import {getQaAttrubutes} from '../../utils/blocks';
import renderContentControls from '../../utils/renderContentControls/renderContentControls';

import './Content.scss';

Expand Down Expand Up @@ -54,18 +53,6 @@ const Content = (props: ContentProps) => {
const defaultTitleId = useUniqId();
const titleId = titleIdFromProps || defaultTitleId;

const controls = useMemo(
() =>
renderContentControls({
size,
links,
buttons,
titleId,
qa: qaAttributes,
}),
[size, links, buttons, titleId, qaAttributes],
);

return (
<Col
className={b({size, centered, theme}, className)}
Expand Down Expand Up @@ -107,7 +94,26 @@ const Content = (props: ContentProps) => {
/>
</div>
)}
{controls}
{links && (
<Links
className={b('links', {size})}
size={size}
links={links}
titleId={titleId}
qa={qaAttributes.links}
linkQa={qaAttributes.link}
/>
)}
{buttons && (
<Buttons
className={b('buttons', {size})}
size={size}
buttons={buttons}
titleId={titleId}
qa={qaAttributes.buttons}
buttonQa={qaAttributes.button}
/>
)}
</Col>
);
};
Expand Down
5 changes: 5 additions & 0 deletions src/sub-blocks/LayoutItem/LayoutItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ $block: '.#{$ns}layout-item';
margin: 0;
}
}

&__links,
&__buttons {
margin-top: $indentXS;
}
}
20 changes: 7 additions & 13 deletions src/sub-blocks/LayoutItem/LayoutItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import React, {useMemo} from 'react';

import {useUniqId} from '@gravity-ui/uikit';

import {FullscreenMedia, IconWrapper, Media, MetaInfo} from '../../components';
import {Buttons, FullscreenMedia, IconWrapper, Links, Media, MetaInfo} from '../../components';
import {ContentBlockProps, LayoutItemProps} from '../../models';
import {block} from '../../utils';
import renderContentControls from '../../utils/renderContentControls/renderContentControls';
import Content from '../Content/Content';

import {getLayoutItemLinks, hasFullscreen, showFullscreenIcon} from './utils';
Expand Down Expand Up @@ -35,16 +34,6 @@ const LayoutItem = ({
colSizes: {all: 12, md: 12},
};
const titleId = useUniqId();
const footerControls = useMemo(
() =>
renderContentControls({
links: areControlsInFooter ? links : undefined,
buttons: areControlsInFooter ? buttons : undefined,
size: 's',
titleId,
}),
[areControlsInFooter, links, buttons, titleId],
);
const renderMedia = () => {
if (!media) {
return null;
Expand Down Expand Up @@ -77,7 +66,12 @@ const LayoutItem = ({
<Content {...contentProps} titleId={titleId} />
</IconWrapper>
</div>
{footerControls}
{areControlsInFooter && links && (
<Links className={b('links')} size="s" links={links} titleId={titleId} />
)}
{areControlsInFooter && buttons && (
<Buttons className={b('buttons')} size="s" buttons={buttons} titleId={titleId} />
)}
</div>
);
};
Expand Down

This file was deleted.

This file was deleted.

17 changes: 0 additions & 17 deletions src/utils/renderContentControls/ContentControls.scss

This file was deleted.

48 changes: 0 additions & 48 deletions src/utils/renderContentControls/renderContentControls.tsx

This file was deleted.

Loading