diff --git a/src/@next/Link/Link.stories.tsx b/src/@next/Link/Link.stories.tsx index c4f8cdfa2..d08350b29 100644 --- a/src/@next/Link/Link.stories.tsx +++ b/src/@next/Link/Link.stories.tsx @@ -21,3 +21,19 @@ export const Default = DefaultTemplate.bind({}); Default.args = { url: '#', }; + +const WithinParagraphTemplate: Story = args => { + return ( + <> + Lorem ipsum dolor sit amet, consectetur adipiscing elit. + + {' '} + Default Link + {' '} + Sed volutpat eget mi in consequat. Aliquam cursus nunc pulvinar rutrum + pharetra. + + ); +}; + +export const WithinParagraph = WithinParagraphTemplate.bind({}); diff --git a/src/@next/Link/Link.tsx b/src/@next/Link/Link.tsx index 49b8e4b0b..00d0510e5 100644 --- a/src/@next/Link/Link.tsx +++ b/src/@next/Link/Link.tsx @@ -27,6 +27,7 @@ export const Link = ({ data-underline={!removeUnderline} data-monochrome={monochrome} {...(external && { target: '_blank' })} + external={external} {...props} > diff --git a/src/@next/Link/LinkStyle.ts b/src/@next/Link/LinkStyle.ts index 4f2d1f96f..d1136eb35 100644 --- a/src/@next/Link/LinkStyle.ts +++ b/src/@next/Link/LinkStyle.ts @@ -3,9 +3,16 @@ import { Blue, Neutral } from '../utilities/colors'; import { space2 } from '../utilities/spacing'; import { LinkProps } from './Link'; +const centerAlign = ` + vertical-align: middle; + + svg { + vertical-align: middle; + } +`; + export const StyledLink = styled.a` - display: flex; - align-items: center; + ${({ external }) => external && centerAlign} color: ${Blue.S99}; &[data-underline='false'] { diff --git a/test/e2e/link/link.spec.ts b/test/e2e/link/link.spec.ts index 211f50ad0..95206f2f0 100644 --- a/test/e2e/link/link.spec.ts +++ b/test/e2e/link/link.spec.ts @@ -58,3 +58,11 @@ test('Link - monochrome with external link', async ({ page }) => { 'link-monochrome-with-external-pressed.png' ); }); + +test('Link - within paragraph', async ({ page }) => { + const linkPage = new LinkPage(page); + await linkPage.gotoWithinParagraphPage(); + await expect(linkPage.container).toHaveScreenshot( + 'link-within-paragraph.png' + ); +}); diff --git a/test/e2e/link/link.spec.ts-snapshots/link-external-chromium-linux.png b/test/e2e/link/link.spec.ts-snapshots/link-external-chromium-linux.png index 04a945520..d2fd7c347 100755 Binary files a/test/e2e/link/link.spec.ts-snapshots/link-external-chromium-linux.png and b/test/e2e/link/link.spec.ts-snapshots/link-external-chromium-linux.png differ diff --git a/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-chromium-linux.png b/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-chromium-linux.png index e19770ac0..615de3997 100755 Binary files a/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-chromium-linux.png and b/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-chromium-linux.png differ diff --git a/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-hover-chromium-linux.png b/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-hover-chromium-linux.png index 6da6d3055..8cf90c4ac 100755 Binary files a/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-hover-chromium-linux.png and b/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-hover-chromium-linux.png differ diff --git a/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-pressed-chromium-linux.png b/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-pressed-chromium-linux.png index 6da6d3055..8cf90c4ac 100755 Binary files a/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-pressed-chromium-linux.png and b/test/e2e/link/link.spec.ts-snapshots/link-monochrome-with-external-pressed-chromium-linux.png differ diff --git a/test/e2e/link/link.spec.ts-snapshots/link-within-paragraph-chromium-linux.png b/test/e2e/link/link.spec.ts-snapshots/link-within-paragraph-chromium-linux.png new file mode 100644 index 000000000..4b87c0b64 Binary files /dev/null and b/test/e2e/link/link.spec.ts-snapshots/link-within-paragraph-chromium-linux.png differ diff --git a/test/e2e/link/linkPage.ts b/test/e2e/link/linkPage.ts index 1fa42e1b8..58e336ee5 100644 --- a/test/e2e/link/linkPage.ts +++ b/test/e2e/link/linkPage.ts @@ -1,5 +1,5 @@ import { Locator, Page } from '@playwright/test'; -import { StoryBookPage } from '../storybookPage'; +import { Args, StoryBookPage } from '../storybookPage'; export class LinkPage extends StoryBookPage { readonly link: Locator; @@ -10,4 +10,9 @@ export class LinkPage extends StoryBookPage { .frameLocator('internal:attr=[title="storybook-preview-iframe"i]') .getByText('Default Link'); } + + async gotoWithinParagraphPage(args?: Args) { + this.setPath('?path=/story/next-link--within-paragraph'); + await this.goto(args); + } }