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
// example url: http://localhost:3000/project/26/details | |
const StyledLink = styled(Link)` | |
border: 2px solid green; | |
${props => | |
props.active && | |
css` | |
border: 2px solid red; | |
`} | |
` |
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
class ForceSignIn extends React.Component { | |
handleClick = e => { | |
this.forceSignIn() | |
} | |
render() { | |
return ( | |
<div onClick={this.handleClick}> | |
{this.props.children} | |
</div> |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script> | |
document.addEventListener("DOMContentLoaded", function (event) { | |
var form = document.querySelector('#intercom_form') | |
form.addEventListener('submit', e => { |
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
// User Render Porop | |
// A user can wrap this <GetUser /> component around any other component and have access to the current user. | |
// This strategy helps create modularity and avoids passing the user info down via props which can pollute the code base | |
// Usage | |
<GetUser> | |
{user => | |
user.subscription === 'paid' && ( | |
<GoBoss to="/proposal-preview/go-boss"> | |
<span>Create unlimited proposals only $10 a month!</span> |
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
// Below I am using react's context api to create a modular way to manage modals within an application | |
// Context Environment | |
import React, { Component, createContext } from 'react' | |
const ModalContext = createContext({ | |
component: null, | |
props: {}, | |
showModal: () => {}, |
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
// Name your graph ql queries so that they show up in apollos's dev tools | |
// allPosts will show up in apollos dev tools | |
const POSTS_QUERY = gql` | |
query allPosts { | |
posts { | |
id | |
title | |
} | |
` |
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
import React, { Component } from 'react' | |
// With apollo mutations you are able to access the link state from within a second argument in a mutation render prop | |
export default class App extends Component { | |
render() { | |
return ( | |
<Mutation mutation={UPDATE_POST}> | |
{(updatePost, result) => { | |
// Here | |
const onSuccess = () => result.client.writeData({data: isEditMode: false) | |
return <PostForm post={post} onSubmit={updatePost} onSuccess={onSuccess} /> |
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
// App.js | |
// Need apollo-boost for link state functionality | |
import ApolloClient from 'apollo-boost' | |
const defaultLinkState = { | |
edit: false, | |
open: false | |
} | |
const client = new ApolloClient({ |
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
const QUERY = gql` | |
// This query name needs to be named so that we can put this name in the refetch query array | |
query Resolutions { | |
resolutions { | |
_id | |
name | |
} | |
} | |
` | |
class ResolutionForm extends Component { |
OlderNewer