Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/components/Link/Link.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import PropTypes from 'prop-types'
import './link.css'

const Link = ({ addClass, href, icon, label, style, ...props }) => {
const Link = ({ addClass, href, icon, label, style, target, ...props }) => {
return (
<a
href={href}
className={`link ${addClass}`}
style={style}
target={target}
{...props}
>
{icon && (
Expand All @@ -31,12 +32,14 @@ Link.propTypes = {
icon: PropTypes.string,
label: PropTypes.string.isRequired,
style: PropTypes.shape({}),
target: PropTypes.string,
}

Link.defaultProps = {
addClass: '',
icon: '',
style: {},
target: '_self'
}

export default Link
8 changes: 8 additions & 0 deletions src/components/Link/Link.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ NoLabel.args = {
label: '',
style: {},
}

export const ExternalLinkInNewTab = Template.bind({})
ExternalLinkInNewTab.args = {
href: 'https://www.google.com',
label: 'I should open in a new tab',
style: {},
target: '_blank'
}
12 changes: 11 additions & 1 deletion src/compounds/LinkGroup/LinkGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ import './link-group.css'
const LinkGroup = ({ header, headerStyle, links, linkStyle }) => (
<div className='link-group-container'>
<p className='link-group-header mb-2' style={headerStyle}>{header}</p>
{links.map(({ name, url }) => <Link href={url} key={name} label={name} addClass='link-group-links' style={linkStyle} />)}
{links.map(({ name, url, target }) =>
<Link
href={url}
key={name}
label={name}
target={target}
addClass='link-group-links'
style={linkStyle}
/>
)}
</div>
)

Expand All @@ -16,6 +25,7 @@ LinkGroup.propTypes = {
links: PropTypes.arrayOf(PropTypes.shape({
name: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
target: PropTypes.string,
})).isRequired,
linkStyle: PropTypes.shape({}),
}
Expand Down
5 changes: 5 additions & 0 deletions src/resources/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export const links = [
name: 'Services',
url: '/services',
},
{
name: 'External tab link',
url: 'http://www.google.com',
target: '_blank',
},
]

export const sections = [
Expand Down
Loading