Skip to content

Commit

Permalink
fixup! feat: add analyticsEvents to BackgroundCard
Browse files Browse the repository at this point in the history
  • Loading branch information
niktverd committed Sep 13, 2023
1 parent 2270323 commit f98ad39
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/models/constructor-items/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@ export interface PriceDetailsProps {
items?: PriceDetailsSettingsProps[] | PriceDetailsListProps[];
}

export interface PriceItemProps extends PriceDetailsProps, PriceDescriptionProps {}
export interface PriceItemProps
extends PriceDetailsProps,
PriceDescriptionProps,
AnalyticsEventsBase {}

export interface PriceFoldableDetailsProps {
title: string;
Expand Down
3 changes: 2 additions & 1 deletion src/models/constructor-items/sub-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ export interface BackgroundCardProps

export interface BasicCardProps
extends CardBaseProps,
AnalyticsEventsBase,
Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size' | 'theme'> {
url: string;
icon?: ImageProps;
Expand All @@ -127,7 +128,7 @@ export interface BannerCardProps {
button: Pick<ButtonProps, 'text' | 'url' | 'target'>;
}

export interface MediaCardProps extends MediaProps, CardBaseProps {}
export interface MediaCardProps extends MediaProps, AnalyticsEventsBase, CardBaseProps {}

export interface LayoutItemProps extends ClassNameProps {
content: Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size'>;
Expand Down
14 changes: 14 additions & 0 deletions src/sub-blocks/BackgroundCard/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'lodash';

import {ImageObjectProps} from '../../components/Image/schema';
import {BaseProps, CardBase, withTheme} from '../../schema/validators/common';
import {AnalyticsEventSchema} from '../../schema/validators/event';
import {ContentBase} from '../Content/schema';

const BackgroundCardContentProps = _.omit(ContentBase, ['size']);
Expand All @@ -25,6 +26,19 @@ export const BackgroundCard = {
type: 'string',
enum: ['s', 'm', 'l', 'xl'],
},
analyticsEvents: {
oneOf: [
{
...AnalyticsEventSchema,
optionName: 'single',
},
{
type: 'array',
items: AnalyticsEventSchema,
optionName: 'list',
},
],
},
},
},
};
9 changes: 7 additions & 2 deletions src/sub-blocks/MediaCard/MediaCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ import './MediaCard.scss';

const b = block('MediaCard');

const MediaCard = ({border, ...mediaProps}: MediaCardProps) => (
<CardBase className={b()} bodyClassName={b('body')} border={border}>
const MediaCard = ({border, analyticsEvents, ...mediaProps}: MediaCardProps) => (
<CardBase
className={b()}
bodyClassName={b('body')}
border={border}
analyticsEvents={analyticsEvents}
>
<CardBase.Content>
<Media {...mediaProps} />
</CardBase.Content>
Expand Down
14 changes: 14 additions & 0 deletions src/sub-blocks/MediaCard/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {AnimatableProps, BaseProps, CardBase, MediaProps} from '../../schema/validators/common';
import {AnalyticsEventSchema} from '../../schema/validators/event';

export const MediaCardBlock = {
'media-card': {
Expand All @@ -9,6 +10,19 @@ export const MediaCardBlock = {
...CardBase,
...MediaProps,
...AnimatableProps,
analyticsEvents: {
oneOf: [
{
...AnalyticsEventSchema,
optionName: 'single',
},
{
type: 'array',
items: AnalyticsEventSchema,
optionName: 'list',
},
],
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {CardBase} from '../../../components';
import {BREAKPOINTS} from '../../../constants';
import {Col, Grid, GridColumnSize, Row} from '../../../grid';
import {
AnalyticsEventsBase,
CardBorder,
PriceDescriptionProps,
PriceDetailsListProps,
Expand All @@ -24,7 +25,7 @@ const CombinedPricesGroupSize = {
[GridColumnSize.Lg]: 3,
};

interface CombinedPriceDetailedProps {
interface CombinedPriceDetailedProps extends AnalyticsEventsBase {
items: PriceItemProps[];
numberGroupItems: number;
useMixedView?: boolean;
Expand All @@ -43,6 +44,7 @@ const CombinedPriceDetailed = (props: CombinedPriceDetailedProps) => {
useMixedView,
getDescriptionComponent,
getDetailsComponent,
analyticsEvents,
} = props;

const [groupItemsSize, setGroupItemsSize] = useState<number>(numberGroupItems);
Expand Down Expand Up @@ -103,7 +105,7 @@ const CombinedPriceDetailed = (props: CombinedPriceDetailedProps) => {
const chunkedItems = _.chunk(items, groupItemsSize);

return (
<CardBase className={b()} border={border}>
<CardBase className={b()} border={border} analyticsEvents={analyticsEvents}>
<CardBase.Content>
<Grid>
{chunkedItems.map((chunk: PriceItemProps[], id) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ const SeparatePriceDetailed = (props: SeparatePriceDetailedProps) => {

return (
<Fragment>
{items.map((item: PriceItemProps, id: number) => (
<CardBase key={id} className={b()} border={border}>
{items.map(({analyticsEvents, ...item}: PriceItemProps, id: number) => (
<CardBase
key={id}
className={b()}
border={border}
analyticsEvents={analyticsEvents}
>
<CardBase.Content>
{getDescriptionComponent(item)}
{getDetailsComponent(item.items)}
Expand Down
14 changes: 14 additions & 0 deletions src/sub-blocks/PriceDetailed/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {AnimatableProps, BaseProps, textSize} from '../../schema/validators/common';
import {AnalyticsEventSchema} from '../../schema/validators/event';
import {filteredArray} from '../../schema/validators/utils';

const PriceDetailedDetailsType = ['marked-list', 'settings'];
Expand Down Expand Up @@ -162,6 +163,19 @@ const PriceItem = {
properties: {
...PriceDetailsProps,
...PriceDescriptionProps,
analyticsEvents: {
oneOf: [
{
...AnalyticsEventSchema,
optionName: 'single',
},
{
type: 'array',
items: AnalyticsEventSchema,
optionName: 'list',
},
],
},
},
};

Expand Down

0 comments on commit f98ad39

Please sign in to comment.