Skip to content

Commit

Permalink
fix(TextLink): vertical alignment when used in list (#2574)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxcheremisin authored Sep 8, 2023
1 parent c346611 commit 21994b4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-insects-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@contentful/f36-text-link': patch
---

fix(TextLink): vertical alignment when used in list
3 changes: 1 addition & 2 deletions packages/components/text-link/src/TextLink.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const textLink = ({
css({
display: 'inline-flex',
justifyContent: 'center',
alignItems: 'center',
alignItems: 'baseline',
boxSizing: 'border-box',
border: 0,
padding: 0,
Expand All @@ -84,7 +84,6 @@ const textLink = ({
opacity: isDisabled ? 0.5 : 1,
...variantToStyles(variant),
outline: 'none',
verticalAlign: 'bottom',
'&:focus, &:focus-visible, &:hover': {
textDecoration: isDisabled ? 'none' : 'underline',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/components/text-link/src/TextLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function _TextLink<E extends React.ElementType = typeof TEXT_LINK_DEFAULT_TAG>(
};

const iconContent = icon ? (
<Flex as="span">
<Flex as="span" alignSelf="center">
{React.cloneElement(icon, {
className: cx(icon.props.className, styles.textLinkIcon()),
size: 'small',
Expand Down
51 changes: 51 additions & 0 deletions packages/components/text-link/stories/TextLink.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { Meta, Story } from '@storybook/react/types-6-0';
import * as icons from '@contentful/f36-icons';
import { Icon } from '@contentful/f36-icon';
import { Paragraph, Text } from '@contentful/f36-typography';
import { List } from '@contentful/f36-list';
import { Flex } from '@contentful/f36-core';
import tokens from '@contentful/f36-tokens';

Expand Down Expand Up @@ -81,6 +82,56 @@ export const UsedWithText = () => {
);
};

export const UsedWithList = () => {
return (
<List>
<List.Item>
<Text>
List item with a link:{' '}
<TextLink
href="https://contentful.com"
target="_blank"
rel="noopener noreferrer"
>
Contentful
</TextLink>{' '}
Website
</Text>
</List.Item>
<List.Item>
<Text>
List item with a link and start icon:{' '}
<TextLink
href="https://contentful.com"
target="_blank"
rel="noopener noreferrer"
icon={<Icon as={icons.ExternalLinkIcon} />}
alignIcon="start"
>
Contentful
</TextLink>{' '}
Website
</Text>
</List.Item>
<List.Item>
<Text>
List item with a link and end icon:{' '}
<TextLink
href="https://contentful.com"
target="_blank"
rel="noopener noreferrer"
icon={<Icon as={icons.ExternalLinkIcon} />}
alignIcon="end"
>
Contentful
</TextLink>{' '}
Website
</Text>
</List.Item>
</List>
);
};

const textLinkVariants = [
'primary',
'positive',
Expand Down

1 comment on commit 21994b4

@vercel
Copy link

@vercel vercel bot commented on 21994b4 Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.