Skip to content

Commit a10e467

Browse files
authored
Merge pull request #196 from scientist-softserv/footer-links-in-new-tab-option
add target option to links
2 parents addb323 + 48a4a3b commit a10e467

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

src/components/Link/Link.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
33
import PropTypes from 'prop-types'
44
import './link.css'
55

6-
const Link = ({ addClass, href, icon, label, style, ...props }) => {
6+
const Link = ({ addClass, href, icon, label, style, target, ...props }) => {
77
return (
88
<a
99
href={href}
1010
className={`link ${addClass}`}
1111
style={style}
12+
target={target}
1213
{...props}
1314
>
1415
{icon && (
@@ -31,12 +32,14 @@ Link.propTypes = {
3132
icon: PropTypes.string,
3233
label: PropTypes.string.isRequired,
3334
style: PropTypes.shape({}),
35+
target: PropTypes.string,
3436
}
3537

3638
Link.defaultProps = {
3739
addClass: '',
3840
icon: '',
3941
style: {},
42+
target: '_self'
4043
}
4144

4245
export default Link

src/components/Link/Link.stories.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,11 @@ NoLabel.args = {
3636
label: '',
3737
style: {},
3838
}
39+
40+
export const ExternalLinkInNewTab = Template.bind({})
41+
ExternalLinkInNewTab.args = {
42+
href: 'https://www.google.com',
43+
label: 'I should open in a new tab',
44+
style: {},
45+
target: '_blank'
46+
}

src/compounds/LinkGroup/LinkGroup.jsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,16 @@ import './link-group.css'
66
const LinkGroup = ({ header, headerStyle, links, linkStyle }) => (
77
<div className='link-group-container'>
88
<p className='link-group-header mb-2' style={headerStyle}>{header}</p>
9-
{links.map(({ name, url }) => <Link href={url} key={name} label={name} addClass='link-group-links' style={linkStyle} />)}
9+
{links.map(({ name, url, target }) =>
10+
<Link
11+
href={url}
12+
key={name}
13+
label={name}
14+
target={target}
15+
addClass='link-group-links'
16+
style={linkStyle}
17+
/>
18+
)}
1019
</div>
1120
)
1221

@@ -16,6 +25,7 @@ LinkGroup.propTypes = {
1625
links: PropTypes.arrayOf(PropTypes.shape({
1726
name: PropTypes.string.isRequired,
1827
url: PropTypes.string.isRequired,
28+
target: PropTypes.string,
1929
})).isRequired,
2030
linkStyle: PropTypes.shape({}),
2131
}

src/resources/args.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ export const links = [
7575
name: 'Services',
7676
url: '/services',
7777
},
78+
{
79+
name: 'External tab link',
80+
url: 'http://www.google.com',
81+
target: '_blank',
82+
},
7883
]
7984

8085
export const sections = [

0 commit comments

Comments
 (0)