From 9f47fb5fcaacc3b7b98ce2ae86661ce530cf8085 Mon Sep 17 00:00:00 2001 From: Sarah Rambacher Date: Mon, 21 Sep 2020 16:12:53 -0400 Subject: [PATCH] change external link to pf component --- src/components/external-link/ExternalLink.tsx | 15 +- .../__tests__/ExternalLink.test.tsx | 21 +++ .../__snapshots__/ExternalLink.test.tsx.snap | 136 ++++++++++++++---- src/stories/ExternalLink.stories.tsx | 13 ++ 4 files changed, 155 insertions(+), 30 deletions(-) diff --git a/src/components/external-link/ExternalLink.tsx b/src/components/external-link/ExternalLink.tsx index 8491667307..ba8d7eebee 100644 --- a/src/components/external-link/ExternalLink.tsx +++ b/src/components/external-link/ExternalLink.tsx @@ -1,5 +1,6 @@ import React from "react"; import { ExternalLinkAltIcon } from "@patternfly/react-icons"; +import { Button } from "@patternfly/react-core"; export const ExternalLink = ({ title, @@ -7,9 +8,15 @@ export const ExternalLink = ({ ...rest }: React.HTMLProps) => { return ( - - {title ? title : href}{" "} - {href?.startsWith("http") && } - + ); }; diff --git a/src/components/external-link/__tests__/ExternalLink.test.tsx b/src/components/external-link/__tests__/ExternalLink.test.tsx index 8922e633be..45e95cdd7a 100644 --- a/src/components/external-link/__tests__/ExternalLink.test.tsx +++ b/src/components/external-link/__tests__/ExternalLink.test.tsx @@ -14,4 +14,25 @@ describe("", () => { ); expect(comp.asFragment()).toMatchSnapshot(); }); + + it("render with internal url", () => { + const comp = render( + + ); + expect(comp.asFragment()).toMatchSnapshot(); + }); + + it("render as application", () => { + const comp = render( + + ); + expect(comp.asFragment()).toMatchSnapshot(); + }); + + it("render as disabled", () => { + const comp = render( + + ); + expect(comp.asFragment()).toMatchSnapshot(); + }); }); diff --git a/src/components/external-link/__tests__/__snapshots__/ExternalLink.test.tsx.snap b/src/components/external-link/__tests__/__snapshots__/ExternalLink.test.tsx.snap index c6739e1f78..9a31b35c24 100644 --- a/src/components/external-link/__tests__/__snapshots__/ExternalLink.test.tsx.snap +++ b/src/components/external-link/__tests__/__snapshots__/ExternalLink.test.tsx.snap @@ -1,24 +1,98 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[` render as application 1`] = ` + + + Application link + + +`; + +exports[` render as disabled 1`] = ` + + + Disabled link + + + + + +`; + +exports[` render with internal url 1`] = ` + + + Application page + + +`; + exports[` render with link 1`] = ` - http://hello.nl/ - + + `; @@ -26,22 +100,32 @@ exports[` render with link 1`] = ` exports[` render with link and title 1`] = ` - Link to Hello - + + `; diff --git a/src/stories/ExternalLink.stories.tsx b/src/stories/ExternalLink.stories.tsx index e3a5c1e40d..5f0712a8f5 100644 --- a/src/stories/ExternalLink.stories.tsx +++ b/src/stories/ExternalLink.stories.tsx @@ -21,3 +21,16 @@ export const WithoutTitle = Template.bind({}); WithoutTitle.args = { href: "http://some-other-link.nl/super", }; + +export const ApplicationLink = Template.bind({}); +ApplicationLink.args = { + title: "Application link", + href: "/application/main", +}; + +export const DisabledLink = Template.bind({}); +DisabledLink.args = { + title: "Disabled link", + href: "http://some-other-link.nl/super", + isDisabled: "true", +};