Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor sharing and analytics into components #1152

Merged
merged 8 commits into from
Jul 12, 2017

Conversation

jeremiak
Copy link
Contributor

@jeremiak jeremiak commented Jul 11, 2017

This PR doesn't change any functionality but removes some of the code we were using as utils (analytics and sharing) and turns them into react components since they are things that will be added to the DOM.

@jeremiak jeremiak force-pushed the jk-sharing-components branch from 9f2cf87 to 9f33485 Compare July 11, 2017 17:12
Jeremia Kimelman added 2 commits July 11, 2017 13:43
Closes #1137

Also disable linting reporting for this component for now since it just
uses code snippets
@jeremiak jeremiak force-pushed the jk-sharing-components branch from 1c3c2eb to 221f914 Compare July 11, 2017 18:06
@jeremiak jeremiak changed the title [WIP] Refactor sharing and analytics into components Refactor sharing and analytics into components Jul 11, 2017
/* eslint-disable */
import React from 'react'

class Analytics extends React.Component {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not convinced this is better than what we have; to me, the componentizing (of this) adds misdirection that feels a little confusing/clunky

Copy link
Contributor Author

@jeremiak jeremiak Jul 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this apply to both new components or just the analytics one? Here are some reasons why I like this approach:

  1. These things change the DOM so it makes sense to have them be components
  2. We get syntax highlighting since its actual javascript instead of strings of javascript code. This might not matter as much right now, but I know there is upcoming DAP integration work where having syntax highlighting will be useful.

Copy link
Contributor

@brendansudol brendansudol Jul 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alright, i'm convinced :)

import { getPlaceInfo } from '../util/place'
import usa from '../util/usa'

const SharingTags = ({ agency, crime, place, since, until }) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this play nice with the other components that are present in some of our parent components (i.e., the ones that set the page titles)?

Copy link
Contributor Author

@jeremiak jeremiak Jul 11, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so. It looks like helmet is a sort of global object and so this plays nicely and doesn't change the current title tags. They are actually separated in the head object passed into html.js so that I had to add head.meta there.

To add onto the points above about why I like this approach, for the sharing component in particular, it gives us the ability to wrap it with react-redux's connect and therefore pull out any information we need across the entire site without needing to keep track of what we're passing in

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@brendansudol
Copy link
Contributor

🚢

@brendansudol brendansudol merged commit 470af3f into master Jul 12, 2017
@brendansudol brendansudol deleted the jk-sharing-components branch July 12, 2017 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants