Skip to content

Commit bc6245c

Browse files
authored
feat: quote types for Quote block (#663)
* feat: quoteType for Quote block
1 parent 7d57714 commit bc6245c

File tree

7 files changed

+52
-16
lines changed

7 files changed

+52
-16
lines changed

src/models/constructor-items/common.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ export enum MediaVideoControlsType {
5555
Custom = 'custom',
5656
}
5757

58+
export enum QuoteType {
59+
Chevron = 'chevron', // « »
60+
EnglishDouble = 'english-double', // “ ”
61+
}
62+
5863
// types
5964
export type TextTheme = 'light' | 'dark';
6065
export type TextSize = 'xs' | 's' | 'm' | 'l';

src/models/constructor-items/sub-blocks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ClassNameProps} from '../../models';
1+
import {ClassNameProps, QuoteType} from '../../models';
22
import {ThemeSupporting} from '../../utils';
33
import {HubspotEventData, HubspotEventHandlers} from '../../utils/hubspot';
44
import {AnalyticsEventsBase, PixelEvent} from '../common';
@@ -96,6 +96,7 @@ export interface QuoteProps extends Themable, CardBaseProps {
9696
author?: AuthorItem;
9797
buttonText?: string;
9898
theme?: TextTheme;
99+
quoteType?: QuoteType;
99100
}
100101

101102
export interface BackgroundCardProps

src/schema/validators/common.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
CustomControlsButtonPositioning,
44
CustomControlsType,
55
MediaVideoControlsType,
6+
QuoteType,
67
Theme,
78
} from '../../models';
89

@@ -25,6 +26,7 @@ export const fileLinkTypes = ['vertical', 'horizontal'];
2526
export const dividerEnum = {enum: [0, 'xxs', 'xs', 's', 'm', 'l', 'xl', 'xxl', 'xxxl']};
2627
export const sizeNumber = {type: 'number', maximum: 12, minimum: 1};
2728
export const contentThemes = ['default', 'dark', 'light'];
29+
export const quoteTypes = Object.values(QuoteType);
2830
export const customControlsType = [
2931
CustomControlsType.WithMuteButton,
3032
CustomControlsType.WithPlayPauseButton,

src/sub-blocks/Quote/Quote.scss

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,23 @@
33

44
$block: '.#{$ns}quote';
55

6+
@mixin comma-type($name, $opening, $closing, $left-offset) {
7+
&_#{$name} {
8+
&::before {
9+
position: absolute;
10+
top: -1px;
11+
left: $left-offset;
12+
content: $opening;
13+
}
14+
15+
#{$block}__text {
16+
&::after {
17+
content: $closing;
18+
}
19+
}
20+
}
21+
}
22+
623
#{$block} {
724
$arrowWidth: 16px;
825
$gap: 5px;
@@ -41,17 +58,9 @@ $block: '.#{$ns}quote';
4158
position: relative;
4259
@include text-size(body-3);
4360

44-
&::before {
45-
position: absolute;
46-
top: -1px;
47-
left: -10px;
48-
content: '«';
49-
}
50-
}
51-
52-
&__text {
53-
&::after {
54-
content: '».';
61+
&_quote-type {
62+
@include comma-type('chevron', '«', '»', -10px);
63+
@include comma-type('english-double', '', '', -8px);
5564
}
5665
}
5766

src/sub-blocks/Quote/Quote.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {Author, HTML, Image} from '../../components';
66
import {getMediaImage} from '../../components/Media/Image/utils';
77
import {useTheme} from '../../context/theme';
88
import {useAnalytics} from '../../hooks';
9-
import {AuthorType, DefaultEventNames, QuoteProps} from '../../models';
9+
import {AuthorType, DefaultEventNames, QuoteProps, QuoteType} from '../../models';
1010
import {block, getThemedValue} from '../../utils';
1111

1212
import './Quote.scss';
@@ -24,6 +24,7 @@ const Quote = (props: QuoteProps) => {
2424
author,
2525
url,
2626
buttonText,
27+
quoteType = QuoteType.Chevron,
2728
} = props;
2829
const theme = useTheme();
2930
const imageThemed = getThemedValue(image, theme);
@@ -65,7 +66,7 @@ const Quote = (props: QuoteProps) => {
6566
<div key={text} className={b('content-wrapper')}>
6667
<div>
6768
<Image className={b('logo')} {...logoProps} />
68-
<div className={b('content')}>
69+
<div className={b('content', {'quote-type': quoteType})}>
6970
<span className={b('text')}>
7071
<HTML>{text}</HTML>
7172
</span>

src/sub-blocks/Quote/__stories__/Quote.stories.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22

33
import {Meta, StoryFn} from '@storybook/react';
44

5-
import {QuoteProps} from '../../../models';
5+
import {QuoteProps, QuoteType} from '../../../models';
66
import Quote from '../Quote';
77

88
import data from './data.json';
@@ -22,11 +22,19 @@ const DefaultTemplate: StoryFn<QuoteProps> = (args) => (
2222
<Quote {...args} />
2323
</div>
2424
);
25+
const QuoteTypesTemplate: StoryFn<QuoteProps> = (args) => (
26+
<div style={{maxWidth: '1248px', display: 'flex', flexDirection: 'column', gap: '24px'}}>
27+
<Quote {...args} quoteType={QuoteType.Chevron} />
28+
<Quote {...args} quoteType={QuoteType.EnglishDouble} />
29+
</div>
30+
);
2531
export const Default = DefaultTemplate.bind({});
32+
export const QuoteTypes = QuoteTypesTemplate.bind({});
2633
export const BorderLine = DefaultTemplate.bind({});
2734
export const DarkTheme = DefaultTemplate.bind({});
2835

2936
Default.args = data.default.content as QuoteProps;
37+
QuoteTypes.args = data.default.content as QuoteProps;
3038
BorderLine.args = {
3139
...data.default.content,
3240
...data.borderLine.content,

src/sub-blocks/Quote/schema.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import {ImageProps} from '../../components/Image/schema';
2-
import {BaseProps, ThemeProps, authorItem, withTheme} from '../../schema/validators/common';
2+
import {
3+
BaseProps,
4+
ThemeProps,
5+
authorItem,
6+
quoteTypes,
7+
withTheme,
8+
} from '../../schema/validators/common';
39

410
export const Quote = {
511
quote: {
@@ -24,6 +30,10 @@ export const Quote = {
2430
},
2531
theme: ThemeProps,
2632
author: authorItem,
33+
quoteType: {
34+
type: 'string',
35+
enum: quoteTypes,
36+
},
2737
},
2838
},
2939
};

0 commit comments

Comments
 (0)