Skip to content

Commit 9828569

Browse files
authored
Merge pull request #56 from gravity-ui/fix-arrow-link-position-CLOUDFRONT-13236
fix: link arrow position
2 parents b3e826b + 2fe8038 commit 9828569

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

src/components/Link/Link.scss

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,18 @@ $block: '.#{$ns}link-block';
2222
}
2323

2424
&_has-arrow {
25+
display: inherit;
26+
white-space: nowrap;
27+
2528
&:hover,
2629
&:active {
2730
--pc-text-header-color: inherit;
2831
color: var(--yc-color-text-link);
2932
}
33+
34+
#{$root}__content {
35+
white-space: normal;
36+
}
3037
}
3138

3239
&:hover {
@@ -44,8 +51,7 @@ $block: '.#{$ns}link-block';
4451

4552
&__arrow {
4653
position: relative;
47-
margin-left: 2px;
48-
54+
top: 2px;
4955
transition: transform 0.3s $ease-out-cubic;
5056
transform: rotate(-90deg);
5157
}
@@ -57,6 +63,10 @@ $block: '.#{$ns}link-block';
5763

5864
&_m {
5965
@include text-size(body-2);
66+
67+
#{$root}__arrow {
68+
top: 1px;
69+
}
6070
}
6171

6272
&_s {

src/components/Link/Link.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useContext} from 'react';
1+
import React, {Fragment, useContext} from 'react';
22
import {Icon} from '@gravity-ui/uikit';
33

44
import {block, getLinkProps, setUrlTld} from '../../utils';
@@ -13,6 +13,7 @@ import {useMetrika} from '../../hooks/useMetrika';
1313
import './Link.scss';
1414

1515
const b = block('link-block');
16+
const WORD_JOINER_SYM = '\u200b';
1617

1718
export type LinkFullProps = LinkProps & ClassNameProps;
1819

@@ -23,9 +24,9 @@ function getArrowSize(size: TextSize) {
2324
case 'm':
2425
return 18;
2526
case 's':
26-
return 12;
27+
return 14;
2728
default:
28-
return 12;
29+
return 14;
2930
}
3031
}
3132

@@ -79,13 +80,16 @@ const LinkBlock = (props: WithChildren<LinkFullProps>) => {
7980
onClick={onClick}
8081
{...linkProps}
8182
>
82-
{children || text}
83+
<span className={b('content')}>{children || text}</span>
8384
{arrow && (
84-
<Icon
85-
className={b('arrow')}
86-
data={Chevron}
87-
size={getArrowSize(textSize)}
88-
/>
85+
<Fragment>
86+
{WORD_JOINER_SYM}
87+
<Icon
88+
className={b('arrow')}
89+
data={Chevron}
90+
size={getArrowSize(textSize)}
91+
/>
92+
</Fragment>
8993
)}
9094
</a>
9195
);

src/components/Link/__stories__/Link.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const WithChildrenTemplate: Story<LinkFullProps> = (args) => (
7575
export const Default = DefaultTemplate.bind({});
7676
export const ThemesSizes = ThemesSizesTemplate.bind({});
7777
export const NormalWithChildren = WithChildrenTemplate.bind({});
78-
export const NormalArrow = DefaultTemplate.bind({});
78+
export const NormalArrow = SizesTemplate.bind({});
7979
export const NormalForDarkTheme = DarkTemplate.bind({});
8080
export const UnderlineWithChildren = WithChildrenTemplate.bind({});
8181
export const BackWithChildren = WithChildrenTemplate.bind({});

0 commit comments

Comments
 (0)