-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from solocommand/google-analytics
Google analytics
- Loading branch information
Showing
15 changed files
with
286 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react'; | ||
import { Query } from 'react-apollo'; | ||
import PropTypes from 'prop-types'; | ||
import query from '../gql/account.graphql'; | ||
|
||
export const AccountContext = React.createContext({}); | ||
|
||
export const AccountProvider = props => ( | ||
<Query query={query}> | ||
{({ error, data }) => { | ||
if (error) return <p><strong>{error.message}</strong></p>; | ||
return ( | ||
<AccountContext.Provider value={data}> | ||
{props.children} | ||
</AccountContext.Provider> | ||
); | ||
}} | ||
</Query> | ||
); | ||
|
||
|
||
AccountProvider.propTypes = { | ||
children: PropTypes.oneOfType([ | ||
PropTypes.arrayOf(PropTypes.node), | ||
PropTypes.node, | ||
]).isRequired, | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { pageview } from '../lib/gtag'; | ||
|
||
class Analytics extends React.Component { | ||
componentDidMount() { | ||
pageview(this.props.accountKey, this.props.storyId); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="ga-track" /> | ||
); | ||
} | ||
} | ||
|
||
Analytics.defaultProps = { | ||
storyId: undefined, | ||
}; | ||
|
||
Analytics.propTypes = { | ||
accountKey: PropTypes.string.isRequired, | ||
storyId: PropTypes.string, | ||
}; | ||
|
||
export default Analytics; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import Link from 'next/link'; | ||
import { Navbar, NavbarBrand, Nav } from 'reactstrap'; | ||
import NavbarStyle from './NavbarStyle'; | ||
// import Imgix from './Imgix'; | ||
// import { AccountContext } from './AccountProvider'; | ||
|
||
export default () => ( | ||
<Navbar expand fixed="top"> | ||
<NavbarStyle /> | ||
<Link href="/" passHref> | ||
<NavbarBrand> | ||
{/* <AccountContext.Consumer> | ||
{({ branding }) => { | ||
return ( | ||
<Imgix | ||
className="d-flex bg-imgIx img-fluid" | ||
src={branding.logo.url} | ||
alt={branding.name} | ||
title={branding.name} | ||
w="250" | ||
h="45" | ||
/> | ||
) }} | ||
</AccountContext.Consumer> */} | ||
</NavbarBrand> | ||
</Link> | ||
<Nav className="mr-auto" navbar> | ||
{/* <ActiveNavItem href="/" title="Home">Home</ActiveNavItem> | ||
<ActiveNavItem href="/about" title="About">About</ActiveNavItem> */} | ||
</Nav> | ||
</Navbar> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
|
||
export default () => ( | ||
<style jsx global>{` | ||
nav.fixed-top { | ||
transition: top 0.1s ease-in-out; | ||
transition: background-color 0.1s ease-in-out; | ||
background-color: transparent; | ||
} | ||
.fixed-top.nav-down { | ||
background-color: rgba(0,0,0,0.75); | ||
} | ||
.fixed-top.nav-up { | ||
top: -71px; | ||
} | ||
`} | ||
</style> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from 'react'; | ||
|
||
export default () => ( | ||
<style jsx global>{` | ||
a.card-title { | ||
color: white; | ||
} | ||
div.story-header { | ||
background-color: #000; | ||
} | ||
div.story-header > div { | ||
max-width:1700px; | ||
margin: 0 auto; | ||
} | ||
div.bg-imgIx { | ||
height: 80vh; | ||
background: url() center/cover no-repeat fixed; | ||
} | ||
div.bg-imgIx:before { | ||
backgound: transparent; | ||
transition: background 0.5s linear; | ||
margin-bottom: 20vh; | ||
} | ||
div.bg-imgIx:before { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
bottom: 0; | ||
left: 0; | ||
background:rgba(0,0,0,0.45); | ||
-webkit-transition: background 1.5s ease-out; | ||
-moz-transition: background 1.5s ease-out; | ||
-o-transition: background 1.5s ease-out; | ||
transition: background 1.5s ease-out; | ||
} | ||
@media screen and (min-width: 1600px) { | ||
div.bg-imgIx:before { | ||
background: -moz-linear-gradient(left, rgba(0,0,0,1) 0%, rgba(0,0,0,0.25) 300px, rgba(0,0,0,0.25) calc(100% - 300px), rgba(0,0,0,1) 100%); /* FF3.6-15 */ | ||
background: -webkit-linear-gradient(left, rgba(0,0,0,1) 0%,rgba(0,0,0,0.25) 300px,rgba(0,0,0,0.25) calc(100% - 300px),rgba(0,0,0,1) 100%); /* Chrome10-25,Safari5.1-6 */ | ||
background: linear-gradient(to right, rgba(0,0,0,1) 0%,rgba(0,0,0,0.25) 300px,rgba(0,0,0,0.25) calc(100% - 300px),rgba(0,0,0,1) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ | ||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 */ | ||
max-width: 1700px; | ||
margin-left: auto; | ||
margin-right: auto; | ||
} | ||
} | ||
.post-heading h1 { | ||
color: #fff; | ||
font-size: 5vmax; | ||
font-family: 'Ubuntu', sans-serif; | ||
} | ||
`} | ||
</style> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
query AccountBranding { | ||
account { | ||
key | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
query AllStories($pagination: PaginationInput, $sort: StorySortInput) { | ||
allStories(pagination: $pagination, sort: $sort) { | ||
totalCount | ||
edges { | ||
node { | ||
id | ||
title | ||
slug | ||
primaryImage { | ||
id | ||
src | ||
} | ||
advertiser { | ||
id | ||
name | ||
} | ||
} | ||
cursor | ||
} | ||
pageInfo { | ||
hasNextPage | ||
endCursor | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
query Story($input: ModelIdInput!) { | ||
story(input: $input) { | ||
id | ||
title | ||
teaser | ||
body | ||
primaryImage { | ||
id | ||
src | ||
} | ||
advertiser { | ||
id | ||
name | ||
logo { | ||
id | ||
src | ||
filename | ||
mimeType | ||
size | ||
width | ||
height | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const { GA_TRACKING_ID } = process.env; | ||
|
||
// https://developers.google.com/analytics/devguides/collection/gtagjs/pages | ||
const pageview = (accountKey, storyId) => { | ||
window.gtag('event', 'page_view', { accountKey, storyId }); | ||
}; | ||
|
||
module.exports = { | ||
GA_TRACKING_ID, | ||
pageview, | ||
}; |
Oops, something went wrong.