Skip to content

Commit

Permalink
feat: use selectable card component
Browse files Browse the repository at this point in the history
  • Loading branch information
Arucard89 committed Jun 28, 2024
1 parent 0635fba commit 3aa5055
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 51 deletions.

This file was deleted.

30 changes: 8 additions & 22 deletions src/components/Themes/ui/BorderRadiusTab/BorderCard/BorderCard.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,15 @@
import {CircleCheckFill} from '@gravity-ui/icons';
import {Card, Text} from '@gravity-ui/uikit';
import React, {useCallback} from 'react';
import {useTranslation} from 'react-i18next';
import {SelectableCard} from 'src/components/SelectableCard/SelectableCard';
import {RADIUS_PRESETS} from 'src/components/Themes/lib/constants';
import {RadiusPresetName} from 'src/components/Themes/lib/types';

import {block} from '../../../../../utils';

import './BorderCard.scss';

const b = block('border-card');

export type BorderCardProps = {
preset: RadiusPresetName;
selected: boolean;
onClick: (preset: RadiusPresetName) => void;
};

const FakeButton = ({preset, text}: {preset: RadiusPresetName; text: string}) => (
<div className={b('fake-button')} style={{borderRadius: RADIUS_PRESETS[preset]?.m + 'px'}}>
<Text color="inverted-primary">{text}</Text>
</div>
);

export const BorderCard = ({selected, preset, onClick}: BorderCardProps) => {
const {t} = useTranslation('themes');

Expand All @@ -33,13 +20,12 @@ export const BorderCard = ({selected, preset, onClick}: BorderCardProps) => {
const displayName = t(preset);

return (
<Card className={b()} type="selection" selected={selected} onClick={handleClick}>
{preset === RadiusPresetName.Custom ? (
<Text variant="body-2">{displayName}</Text>
) : (
<FakeButton preset={preset} text={displayName} />
)}
{selected && <CircleCheckFill className={b('icon')} />}
</Card>
<SelectableCard
text={displayName}
onClick={handleClick}
selected={selected}
pureText={preset === RadiusPresetName.Custom}
contentStyle={{borderRadius: RADIUS_PRESETS[preset]?.m + 'px'}}
/>
);
};

0 comments on commit 3aa5055

Please sign in to comment.