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

feat: add analyticsEvents to BackgroundCard #556

Merged
merged 3 commits into from
Sep 13, 2023
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
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
6 changes: 4 additions & 2 deletions src/models/constructor-items/sub-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export interface QuoteProps extends Themable, CardBaseProps {

export interface BackgroundCardProps
extends CardBaseProps,
AnalyticsEventsBase,
Omit<ContentBlockProps, 'colSizes' | 'centered'> {
url?: string;
background?: ThemeSupporting<ImageObjectProps>;
Expand All @@ -109,6 +110,7 @@ export interface BackgroundCardProps

export interface BasicCardProps
extends CardBaseProps,
AnalyticsEventsBase,
Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size' | 'theme'> {
url: string;
icon?: ImageProps;
Expand All @@ -126,9 +128,9 @@ 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 {
export interface LayoutItemProps extends ClassNameProps, AnalyticsEventsBase {
content: Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size'>;
media: MediaProps;
metaInfo?: string[];
Expand Down
2 changes: 2 additions & 0 deletions src/sub-blocks/BackgroundCard/BackgroundCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const BackgroundCard = (props: BackgroundCardProps) => {
theme: cardTheme = 'default',
links,
buttons,
analyticsEvents,
} = props;

const theme = useTheme();
Expand All @@ -34,6 +35,7 @@ const BackgroundCard = (props: BackgroundCardProps) => {
className={b({padding: paddingBottom, theme: cardTheme})}
url={url}
border={borderType}
analyticsEvents={analyticsEvents}
>
<CardBase.Content>
<BackgroundImage
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',
},
],
},
},
},
};
4 changes: 3 additions & 1 deletion src/sub-blocks/LayoutItem/LayoutItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const LayoutItem = ({
border,
fullscreen,
className,
analyticsEvents,
}: LayoutItemProps) => (
<div className={b(null, className)}>
{fullscreen && hasFullscreen(media) ? (
Expand All @@ -31,11 +32,12 @@ const LayoutItem = ({
{...media}
{...fullscreenMediaProps}
className={b('media', {border}, mediaClassName)}
analyticsEvents={analyticsEvents}
/>
)}
</FullscreenMedia>
) : (
<Media {...media} className={b('media', {border})} />
<Media {...media} className={b('media', {border})} analyticsEvents={analyticsEvents} />
)}
{metaInfo && <MetaInfo items={metaInfo} className={b('meta-info')} />}
<div className={b('content')}>
Expand Down
14 changes: 14 additions & 0 deletions src/sub-blocks/LayoutItem/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {omit} from 'lodash';

import metaInfo from '../../components/MetaInfo/schema';
import {BaseProps, MediaProps} from '../../schema/validators/common';
import {AnalyticsEventSchema} from '../../schema/validators/event';
import {ContentBase} from '../../sub-blocks/Content/schema';

export const LayoutItem = {
Expand All @@ -19,5 +20,18 @@ export const LayoutItem = {
fullscreen: {
type: 'boolean',
},
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
Loading