Skip to content

Instantly share code, notes, and snippets.

View loganpowell's full-sized avatar

Logan Powell loganpowell

  • Metro DC
View GitHub Profile
// found through: https://blog.graph.cool/all-you-need-to-know-about-apollo-client-2-7e27e36d62fd
import React from 'react'
import ReactDOM from 'react-dom'
import ListPage from './components/ListPage'
import CreatePage from './components/CreatePage'
import DetailPage from './components/DetailPage'
import {BrowserRouter as Router, Route} from 'react-router-dom'
import { ApolloProvider } from 'react-apollo'
import { ApolloClient } from 'apollo-client'
// from: https://github.com/styled-components/styled-components/issues/416#issuecomment-276230181
import React from 'react';
import classnames from 'classnames';
import styled from 'styled-components';
import { ContainerQuery } from 'react-container-query';
const query = {
'box1': {
minWidth: 250,
@loganpowell
loganpowell / mediumUsersFollowedByCount.js
Created January 11, 2018 19:06 — forked from newhouse/mediumUsersFollowedByCount.js
Medium API: get number of followers for User
/**
* Example of how to get the number of followers for a Medium.com User.
*
*
* Related links:
* https://github.com/Medium/medium-api-docs/issues/30#issuecomment-227911763
* https://github.com/Medium/medium-api-docs/issues/73
*/
// LODASH
@loganpowell
loganpowell / react-transition-demo.js
Created January 15, 2018 22:08
Adding animations to your React app with React Transition Group
// from: https://dev.to/underdogio/adding-animations-to-your-react-app-with-react-transition-group
import './styles.css'
import React from 'react'
import Transition from 'react-transition-group/Transition'
import TransitionGroup from 'react-transition-group/TransitionGroup'
import {render} from 'react-dom'
function Card ({children, onRemove}) {
return (
@loganpowell
loganpowell / recompose-animated.jsx
Created January 17, 2018 14:02
Use Recompose with Animated
// from: https://github.com/acdlite/recompose/issues/427#issuecomment-320080852
compose(
withState(
'interaction',
'setInteraction',
// Props get passed in here, but we're ignoring them.
() => {
const interaction = {
scrollPositionY: new Animated.Value(0),
};
@loganpowell
loganpowell / state-hoisting.js
Created January 17, 2018 15:44
State Hoisting in React (Child to Parent communication)
//from: https://reactpatterns.com/#event-switch
class NameContainer extends React.Component {
constructor() {
super()
this.state = {name: ""}
}
render() {
return <Name onChange={newName => this.setState({name: newName})} />
@loganpowell
loganpowell / presenter-pattern.jsx
Created January 17, 2018 16:31
When we want to separate data from its presentation so we can support multiple presentations easily.
// from: https://www.zhubert.com/blog/2016/02/05/react-composability-patterns/
const DataGetter = React.createClass({
render() {
const { children } = this.props
const data = [ 1,2,3,4,5 ]
return children(data)
}
})
@loganpowell
loganpowell / react-transition-children-demo.jsx
Created January 17, 2018 16:34
Add transition animations to a board of cards, animating cards as they are added to and removed from the board.
// from: https://dev.to/underdogio/adding-animations-to-your-react-app-with-react-transition-group
import './styles.css'
import React from 'react'
import Transition from 'react-transition-group/Transition'
import TransitionGroup from 'react-transition-group/TransitionGroup'
import {render} from 'react-dom'
function Card ({children, onRemove}) {
return (
@loganpowell
loganpowell / medium-rss.js
Last active January 17, 2018 17:43
Get Medium.com Posts (RSS)
// from: https://medium.jasonmdesign.com/display-medium-articles-on-your-site-d772b3b05779
// Resources:
// https://codepen.io/loganpowell/pen/ppxYVz
// https://help.medium.com/hc/en-us/articles/214874118-RSS-feeds
$(function () {
var $content = $('#jsonContent');
var data = {
rss_url: 'https://medium.jasonmdesign.com/feed'
};
@loganpowell
loganpowell / NavigationPrompt.jsx
Last active January 24, 2018 23:08 — forked from bummzack/NavigationPrompt.jsx
A replacement component for the react-router `Prompt`.
// from: https://github.com/ReactTraining/react-router/issues/4635#issuecomment-297828995
import React from 'react';
import {withRouter} from 'react-router-dom';
import PropTypes from 'prop-types';
/**
* A replacement component for the react-router `Prompt`.
* Allows for more flexible dialogs.
*