Skip to content
This repository was archived by the owner on Jul 24, 2023. It is now read-only.

Commit eef8fb4

Browse files
committed
feat: add cta option to <Link/>
1 parent 0d2b8f1 commit eef8fb4

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/components/Link.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* global window */
2-
import React from 'react'
2+
/** @jsx jsx */
3+
import { jsx } from 'theme-ui'
34
import PropTypes from 'prop-types'
45
import * as QS from '@gaiama/query-string'
56
import { Link as GatsbyLink } from 'gatsby'
@@ -13,6 +14,29 @@ if (typeof window !== `undefined`) {
1314
window.__navigatingToLink = false
1415
}
1516

17+
const Cta = props => (
18+
<div
19+
{...props}
20+
sx={{
21+
display: `inline-block`,
22+
backgroundColor: `cta`,
23+
fontWeight: `400`,
24+
borderRadius: `3px`,
25+
color: `#042f37`,
26+
fontSize: `1.2rem`,
27+
padding: `0.2rem 0.7rem`,
28+
margin: `0 1rem`,
29+
textAlign: `center`,
30+
a: {
31+
border: `none`,
32+
':hover': {
33+
background: `none`,
34+
},
35+
},
36+
}}
37+
/>
38+
)
39+
1640
const Link = ({
1741
children,
1842
to,
@@ -21,6 +45,7 @@ const Link = ({
2145
ext,
2246
blank,
2347
persistQuery,
48+
cta,
2449
...props
2550
}) => {
2651
if (persistQuery) {
@@ -56,7 +81,9 @@ const Link = ({
5681
</GatsbyLink>
5782
)
5883

59-
return isExt ? externalLink : internalLink
84+
const link = isExt ? externalLink : internalLink
85+
86+
return !cta ? link : <Cta>{link}</Cta>
6087
}
6188

6289
Link.propTypes = {
@@ -66,6 +93,7 @@ Link.propTypes = {
6693
ext: PropTypes.bool,
6794
blank: PropTypes.bool,
6895
persistQuery: PropTypes.bool,
96+
cta: PropTypes.bool,
6997
}
7098

7199
Link.defaultProps = {

0 commit comments

Comments
 (0)