From cdf618ec3699d744cf424b61ea229616a2c217e3 Mon Sep 17 00:00:00 2001 From: Marcos Mendes Date: Tue, 3 Jan 2023 07:31:51 -0300 Subject: [PATCH 1/4] feat: add isExternal prop --- components/Link.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/components/Link.js b/components/Link.js index 86561bff0..1207f3211 100644 --- a/components/Link.js +++ b/components/Link.js @@ -33,7 +33,7 @@ export const InlineLink = styled.a.attrs((/* props */) => ({ } `; -const Link = ({ ['aria-label']: ariaLabel, children, className, inline, unstyled, white, ...rest }) => { +const Link = ({ ['aria-label']: ariaLabel, children, className, inline, unstyled, white, isExternal, ...rest }) => { let Child = StyledLink; if (inline) { Child = InlineLink; @@ -46,9 +46,14 @@ const Link = ({ ['aria-label']: ariaLabel, children, className, inline, unstyled dataAttrs = { 'data-white': white }; } + let target; + if (isExternal) { + target = '_blank'; + } + return ( - + {children} From e350d5c89cec092151c725d0fc96522d16937235 Mon Sep 17 00:00:00 2001 From: Marcos Mendes Date: Tue, 3 Jan 2023 07:32:12 -0300 Subject: [PATCH 2/4] test: update snapshots --- .../__snapshots__/MobileNavbar.spec.js.snap | 3 +++ .../NavBar/__snapshots__/Navbar.spec.js.snap | 6 ++++++ .../NavBar/__snapshots__/index.spec.js.snap | 18 ++++++++++++++++++ .../__snapshots__/DocsLayout.spec.js.snap | 18 ++++++++++++++++++ 4 files changed, 45 insertions(+) diff --git a/test/components/NavBar/__snapshots__/MobileNavbar.spec.js.snap b/test/components/NavBar/__snapshots__/MobileNavbar.spec.js.snap index ce7162743..2e51986e1 100644 --- a/test/components/NavBar/__snapshots__/MobileNavbar.spec.js.snap +++ b/test/components/NavBar/__snapshots__/MobileNavbar.spec.js.snap @@ -368,6 +368,7 @@ exports[`MobileNavbar renders correctly 1`] = ` Date: Tue, 3 Jan 2023 07:35:35 -0300 Subject: [PATCH 3/4] feat: add target blank on all external links --- components/BlmBanner.js | 2 +- components/Nav/Social.js | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/BlmBanner.js b/components/BlmBanner.js index 3e7285a0c..6de6d2901 100644 --- a/components/BlmBanner.js +++ b/components/BlmBanner.js @@ -17,7 +17,7 @@ const Banner = styled.a` export const BlmBanner = () => { return ( - + #BlackLivesMatter ✊🏿 Support the Equal Justice Initiative ); diff --git a/components/Nav/Social.js b/components/Nav/Social.js index d0e8eaff7..a276d2b70 100644 --- a/components/Nav/Social.js +++ b/components/Nav/Social.js @@ -42,14 +42,14 @@ const SocialLink = styled(Link).attrs((/* props */) => ({ `; const Svg = styled.svg` - width: ${p => rem(Number(p.width))}; - height: ${p => rem(Number(p.height))}; + width: ${(p) => rem(Number(p.width))}; + height: ${(p) => rem(Number(p.height))}; `; const StyledIcon = styled.div` && { - width: ${p => rem(Number(p.width))}; - height: ${p => rem(Number(p.height))}; + width: ${(p) => rem(Number(p.width))}; + height: ${(p) => rem(Number(p.height))}; } `; @@ -73,18 +73,18 @@ const Spectrum = () => ( ); -const Social = props => ( +const Social = (props) => ( - + {/* */} - + - + From 14618ef97c4c008be464c2b6960a57bcc2bd055d Mon Sep 17 00:00:00 2001 From: Marcos Mendes Date: Tue, 3 Jan 2023 07:36:00 -0300 Subject: [PATCH 4/4] refactor: remove commented code --- components/Nav/Social.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/Nav/Social.js b/components/Nav/Social.js index a276d2b70..5bd1adc0d 100644 --- a/components/Nav/Social.js +++ b/components/Nav/Social.js @@ -78,12 +78,11 @@ const Social = (props) => ( - {/* - - */} + +