Skip to content

Commit

Permalink
add gatsby link component.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradgarropy committed Apr 17, 2021
1 parent 0b4cbbe commit b0de40d
Show file tree
Hide file tree
Showing 20 changed files with 24,564 additions and 25,077 deletions.
49,483 changes: 24,480 additions & 25,003 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dailytexascountry.com",
"version": "1.1.0",
"version": "1.2.0",
"description": "🤠 daily texas country",
"keywords": [
"gatsby",
Expand Down Expand Up @@ -49,8 +49,9 @@
"new": "plop"
},
"dependencies": {
"@bradgarropy/gatsby-link": "^0.0.2",
"@bradgarropy/gatsby-plugin-seo": "^1.0.0",
"airtable": "^0.10.1",
"airtable": "^0.11.0",
"babel-plugin-styled-components": "^1.12.0",
"copyright": "0.0.5",
"date-fns": "^2.16.1",
Expand Down Expand Up @@ -95,12 +96,12 @@
"@hot-loader/react-dom": "^17.0.1",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"@testing-library/user-event": "^12.6.0",
"@testing-library/user-event": "^13.1.3",
"all-contributors-cli": "^6.20.0",
"babel-eslint": "^10.1.0",
"cross-env": "^7.0.3",
"eslint": "^7.16.0",
"eslint-config-prettier": "^7.1.0",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
Expand Down
9 changes: 4 additions & 5 deletions src/components/Episode/Episode.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Link from "@bradgarropy/gatsby-link"
import EpisodeMeta from "components/EpisodeMeta"
import PropTypes from "prop-types"
import styled from "styled-components"
Expand All @@ -14,14 +15,12 @@ const Episode = ({episode}) => {

return (
<StyledEpisode>
<a
<Link
aria-label={title}
href={`https://youtube.com/watch?v=${videoId}`}
target="_blank"
rel="noopener noreferrer"
to={`https://youtube.com/watch?v=${videoId}`}
>
<Image fluid={thumbnail} />
</a>
</Link>

<EpisodeMeta episode={episode} />
</StyledEpisode>
Expand Down
9 changes: 3 additions & 6 deletions src/components/EpisodeMeta/EpisodeMeta.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Link from "@bradgarropy/gatsby-link"
import PropTypes from "prop-types"
import styled from "styled-components"
import Title from "styles/Title"
Expand All @@ -6,7 +7,7 @@ const StyledEpisodeMeta = styled.div`
display: grid;
`

const TitleLink = styled.a`
const TitleLink = styled(Link)`
justify-self: start;
`

Expand All @@ -17,11 +18,7 @@ const EpisodeMeta = ({episode}) => {
<StyledEpisodeMeta>
<span>{publishedAt}</span>

<TitleLink
href={`https://youtube.com/watch?v=${videoId}`}
target="_blank"
rel="noopener noreferrer"
>
<TitleLink to={`https://youtube.com/watch?v=${videoId}`}>
<Title>{title}</Title>
</TitleLink>
</StyledEpisodeMeta>
Expand Down
14 changes: 5 additions & 9 deletions src/components/FeaturedPlaylist/FeaturedPlaylist.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Link from "@bradgarropy/gatsby-link"
import PropTypes from "prop-types"
import styled from "styled-components"
import Image from "styles/Image"
Expand Down Expand Up @@ -37,19 +38,14 @@ const FeaturedPlaylist = ({playlist}) => {

return (
<StyledFeaturedPlaylist>
<a
aria-label={name}
href={url}
target="_blank"
rel="noopener noreferrer"
>
<Link aria-label={name} to={url}>
<PlaylistImage fluid={image} />
</a>
</Link>

<PlaylistInfo>
<a href={url} target="_blank" rel="noopener noreferrer">
<Link to={url}>
<h1>{name}</h1>
</a>
</Link>

<span>{description}</span>
</PlaylistInfo>
Expand Down
2 changes: 1 addition & 1 deletion src/components/FeaturedPosts/FeaturedPosts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Link} from "gatsby"
import Link from "@bradgarropy/gatsby-link"
import PropTypes from "prop-types"
import styled from "styled-components"
import Image from "styles/Image"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/Footer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from "@bradgarropy/gatsby-link"
import BG from "components/BG"
import Copyright from "components/Copyright"
import Social from "components/Social"
import {Link} from "gatsby"
import styled from "styled-components"

const StyledFooter = styled.footer`
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/Header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from "@bradgarropy/gatsby-link"
import Navigation from "components/Navigation"
import {Link} from "gatsby"
import styled from "styled-components"
import DTXC from "svg/dtxc.svg"

Expand Down
2 changes: 1 addition & 1 deletion src/components/MobileFooter/MobileFooter.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Link from "@bradgarropy/gatsby-link"
import BG from "components/BG"
import Copyright from "components/Copyright"
import Social from "components/Social"
import {Link} from "gatsby"
import styled from "styled-components"

const StyledFooter = styled.footer`
Expand Down
2 changes: 1 addition & 1 deletion src/components/MobileHeader/MobileHeader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Link from "@bradgarropy/gatsby-link"
import MobileNavigation from "components/MobileNavigation"
import Navigation from "components/Navigation"
import {Link} from "gatsby"
import {useApp} from "hooks"
import styled from "styled-components"
import DTXC from "svg/dtxc.svg"
Expand Down
2 changes: 1 addition & 1 deletion src/components/MobileNavigation/MobileNavigation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Link} from "gatsby"
import Link from "@bradgarropy/gatsby-link"
import {useApp} from "hooks"
import PropTypes from "prop-types"
import styled from "styled-components"
Expand Down
2 changes: 1 addition & 1 deletion src/components/Navigation/Navigation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Link} from "gatsby"
import Link from "@bradgarropy/gatsby-link"
import {useApp} from "hooks"
import styled from "styled-components"
import {navLink} from "styles/partials"
Expand Down
10 changes: 3 additions & 7 deletions src/components/Playlist/Playlist.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Link from "@bradgarropy/gatsby-link"
import PlaylistMeta from "components/PlaylistMeta"
import PropTypes from "prop-types"
import styled from "styled-components"
Expand Down Expand Up @@ -30,14 +31,9 @@ const Playlist = ({playlist}) => {

return (
<StyledPlaylist>
<a
aria-label={name}
href={url}
target="_blank"
rel="noopener noreferrer"
>
<Link aria-label={name} to={url}>
<PlaylistImage fluid={image} />
</a>
</Link>

<PlaylistMeta playlist={playlist} />
</StyledPlaylist>
Expand Down
5 changes: 3 additions & 2 deletions src/components/PlaylistMeta/PlaylistMeta.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Link from "@bradgarropy/gatsby-link"
import PropTypes from "prop-types"
import styled from "styled-components"
import Title from "styles/Title"
Expand All @@ -13,7 +14,7 @@ const StyledPlaylistMeta = styled.div`
}
`

const PlaylistLink = styled.a`
const PlaylistLink = styled(Link)`
justify-self: start;
@media (max-width: ${({theme}) => theme.breakpoints.mobile}) {
Expand Down Expand Up @@ -43,7 +44,7 @@ const PlaylistMeta = ({playlist}) => {

return (
<StyledPlaylistMeta>
<PlaylistLink href={url} target="_blank" rel="noopener noreferrer">
<PlaylistLink to={url}>
<PlaylistName>{name}</PlaylistName>
</PlaylistLink>

Expand Down
2 changes: 1 addition & 1 deletion src/components/Post/Post.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Link from "@bradgarropy/gatsby-link"
import PostMeta from "components/PostMeta"
import {Link} from "gatsby"
import PropTypes from "prop-types"
import styled from "styled-components"
import Image from "styles/Image"
Expand Down
2 changes: 1 addition & 1 deletion src/components/PostMeta/PostMeta.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Link} from "gatsby"
import Link from "@bradgarropy/gatsby-link"
import PropTypes from "prop-types"
import styled from "styled-components"
import Tag from "styles/Tag"
Expand Down
37 changes: 15 additions & 22 deletions src/components/Social/Social.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Link from "@bradgarropy/gatsby-link"
import {useSiteMetadata} from "hooks"
import styled from "styled-components"
import Instagram from "svg/instagram.svg"
import Spotify from "svg/spotify.svg"
Expand Down Expand Up @@ -32,43 +34,34 @@ const StyledSpotify = styled(Spotify)`
`

const Social = () => {
const {twitter, youtube, instagram, spotify} = useSiteMetadata()

return (
<StyledSocial>
<a
aria-label="Twitter"
href="/twitter"
target="_blank"
rel="noopener noreferrer"
>
<Link aria-label="Twitter" to={`https://twitter.com/${twitter}`}>
<StyledTwitter />
</a>
</Link>

<a
<Link
aria-label="YouTube"
href="/youtube"
target="_blank"
rel="noopener noreferrer"
to={`https://youtube.com/channel/${youtube}`}
>
<StyledYouTube />
</a>
</Link>

<a
<Link
aria-label="Instagram"
href="/instagram"
target="_blank"
rel="noopener noreferrer"
to={`https://instagram.com/${instagram}`}
>
<StyledInstagram />
</a>
</Link>

<a
<Link
aria-label="Spotify"
href="/spotify"
target="_blank"
rel="noopener noreferrer"
to={`https://open.spotify.com/user/${spotify}`}
>
<StyledSpotify />
</a>
</Link>
</StyledSocial>
)
}
Expand Down
43 changes: 35 additions & 8 deletions src/components/Social/Social.test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
import Social from "components/Social"
import {useSiteMetadata} from "hooks"
import {mockSiteMetadata} from "test-utils/mocks"
import {render, screen} from "test-utils/render"

test("shows social", () => {
jest.mock("hooks")
useSiteMetadata.mockReturnValue(mockSiteMetadata)

test("shows twitter", () => {
render(<Social />)

expect(screen.getByLabelText("Twitter")).toHaveAttribute(
"href",
`https://twitter.com/${mockSiteMetadata.twitter}`,
)
})

test("shows youtube", () => {
render(<Social />)

const socials = ["Twitter", "YouTube", "Instagram", "Spotify"]
expect(screen.getByLabelText("YouTube")).toHaveAttribute(
"href",
`https://youtube.com/channel/${mockSiteMetadata.youtube}`,
)
})

test("shows instagram", () => {
render(<Social />)

expect(screen.getByLabelText("Instagram")).toHaveAttribute(
"href",
`https://instagram.com/${mockSiteMetadata.instagram}`,
)
})
test("shows spotify", () => {
render(<Social />)

socials.forEach(social => {
expect(screen.getByLabelText(social)).toHaveAttribute(
"href",
`/${social.toLowerCase()}`,
)
})
expect(screen.getByLabelText("Spotify")).toHaveAttribute(
"href",
`https://open.spotify.com/user/${mockSiteMetadata.spotify}`,
)
})
2 changes: 1 addition & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Link from "@bradgarropy/gatsby-link"
import SEO from "@bradgarropy/gatsby-plugin-seo"
import FeaturedPlaylist from "components/FeaturedPlaylist"
import FeaturedPosts from "components/FeaturedPosts"
import YouTube from "components/YouTube"
import {Link} from "gatsby"
import {useEpisode, usePlaylist, usePosts} from "hooks"
import styled from "styled-components"
import Section from "styles/Section"
Expand Down
2 changes: 1 addition & 1 deletion src/styles/Tag.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Link} from "gatsby"
import Link from "@bradgarropy/gatsby-link"
import styled from "styled-components"

const fontSize = size => {
Expand Down

0 comments on commit b0de40d

Please sign in to comment.