Skip to content

Commit

Permalink
feat: added urlTitle attributes to the schemas (#665)
Browse files Browse the repository at this point in the history
* feat: added urlTitle attributes to the schemas and its usages to the stories
  • Loading branch information
Kyzyl-ool authored Oct 27, 2023
1 parent fe0a8c6 commit ab70085
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import './Button.scss';
export interface ButtonProps extends Omit<ButtonParams, 'url'>, QAProps {
className?: string;
url?: string;
urlTitle?: string;
onClick?: React.MouseEventHandler<HTMLButtonElement | HTMLAnchorElement>;
}

Expand All @@ -34,6 +35,7 @@ const Button = (props: ButtonProps) => {
size = 'l',
theme = 'normal',
url,
urlTitle,
img,
onClick: onClickOrigin,
text,
Expand Down Expand Up @@ -94,6 +96,7 @@ const Button = (props: ButtonProps) => {
view={toCommonView(buttonTheme as OldButtonTheme)}
size={toCommonSize(size as OldButtonSize)}
href={url ? setUrlTld(url, tld) : undefined}
title={urlTitle}
width={width}
{...buttonProps}
>
Expand Down
3 changes: 2 additions & 1 deletion src/components/Button/__stories__/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
}
],
"metrikaGoals": ["one", "two", "three"],
"img": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/icons/icon.svg"
"img": "https://storage.yandexcloud.net/cloud-www-assets/constructor/storybook/icons/icon.svg",
"urlTitle": "Some button title"
}
}
}
2 changes: 2 additions & 0 deletions src/models/constructor-items/sub-blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface QuoteProps extends Themable, CardBaseProps {
logo: ImageProps;
color?: string;
url?: string;
urlTitle?: string;
author?: AuthorItem;
buttonText?: string;
theme?: TextTheme;
Expand All @@ -115,6 +116,7 @@ export interface BasicCardProps
AnalyticsEventsBase,
Omit<ContentBlockProps, 'colSizes' | 'centered' | 'size' | 'theme'> {
url: string;
urlTitle?: string;
icon?: ImageProps;
target?: string;
iconPosition?: IconPosition;
Expand Down
12 changes: 12 additions & 0 deletions src/schema/validators/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ export const LinkProps = {
url: {
type: 'string',
},
urlTitle: {
type: 'string',
},
arrow: {
type: 'boolean',
},
Expand Down Expand Up @@ -339,6 +342,9 @@ export const ButtonProps = {
url: {
type: 'string',
},
urlTitle: {
type: 'string',
},
primary: {
type: 'boolean',
},
Expand Down Expand Up @@ -504,6 +510,9 @@ export const AnchorProps = {
url: {
type: 'string',
},
urlTitle: {
type: 'string',
},
},
};

Expand Down Expand Up @@ -538,6 +547,9 @@ export const TitleProps = {
url: {
type: 'string',
},
urlTitle: {
type: 'string',
},
resetMargin: {
type: 'boolean',
},
Expand Down
3 changes: 3 additions & 0 deletions src/sub-blocks/BackgroundCard/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export const BackgroundCard = {
url: {
type: 'string',
},
urlTitle: {
type: 'string',
},
background: withTheme(ImageObjectProps),
backgroundColor: {
type: 'string',
Expand Down
3 changes: 2 additions & 1 deletion src/sub-blocks/BasicCard/__stories__/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"default": {
"content": {
"title": "Lorem ipsum",
"text": "**Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
"text": "**Ut enim ad minim veniam** [quis nostrud](https://example.com) exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
"urlTitle": "Opens in a new tab"
}
}
}
3 changes: 3 additions & 0 deletions src/sub-blocks/BasicCard/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const BasicCard = {
url: {
type: 'string',
},
urlTitle: {
type: 'string',
},
icon: ImageProps,
target: {
type: 'string',
Expand Down
2 changes: 2 additions & 0 deletions src/sub-blocks/Quote/Quote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const Quote = (props: QuoteProps) => {
logo,
author,
url,
urlTitle,
buttonText,
quoteType = QuoteType.Chevron,
} = props;
Expand All @@ -49,6 +50,7 @@ const Quote = (props: QuoteProps) => {
href={url}
className={b('link-button', {theme: textTheme})}
onClick={handleButtonClick}
title={urlTitle}
>
{buttonText}
</Button>
Expand Down
2 changes: 2 additions & 0 deletions src/sub-blocks/Quote/__stories__/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
}
},
"url": "https://example.com",
"urlTitle": "Opens in a new tab",
"buttonText": "Button text",
"author": {
"firstName": "Lorem",
"secondName": "ipsum",
Expand Down
3 changes: 3 additions & 0 deletions src/sub-blocks/Quote/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export const Quote = {
url: {
type: 'string',
},
urlTitle: {
type: 'string',
},
buttonText: {
type: 'string',
},
Expand Down

0 comments on commit ab70085

Please sign in to comment.