Skip to content

Instantly share code, notes, and snippets.

View sarahsweat's full-sized avatar

Sarah Sweat sarahsweat

View GitHub Profile
export const GET_RECIPE = gql`
query Search($id: String!) {
search(q: $id, brand: FOOD, types: RECIPE) {
results {
...recipeResults
}
}
}
${RECIPE_ATTRIBUTES}
`
import { gql } from 'apollo-boost'
const RECIPE_ATTRIBUTES = gql`
fragment recipeAttributes on Recipe {
id
title
directions
ingredients
bylines {
id
export const GET_RECIPE = gql`
query Search($id: String!) {
search(q: $id, brand: FOOD, types: RECIPE) {
results {
...on Recipe {
id
title
directions
ingredients
bylines {
export const GET_RECIPES = gql`
query Search($searchInput: String!) {
search(q: $searchInput, brand: FOOD, types: RECIPE, limit: 50) {
count
pageInfo {
endCursor
hasNextPage
}
results {
results {
import { gql } from 'apollo-boost'
const RECIPE_ATTRIBUTES = gql`
fragment recipeResults on Recipe {
id
title
directions
ingredients
bylines {
id
@sarahsweat
sarahsweat / Component1.jsx
Last active April 1, 2019 14:26
ContextBlog
import React from 'react'
import styled from 'styled-components'
import Component2 from './component2'
const initialValue = {
message: "This is my message from context"
}
export const MyContext = React.createContext(initialValue)
export default class Toggler extends React.Component {
state = {
isToggled: false
}
toggle = () => {
this.setState(state => ({isToggled: !state.isToggled}))
}
render() {
import React from 'react'
import styled from 'styled-components'
//----------------------------------------------------------------------------------
// Reusable Toggler Component
//----------------------------------------------------------------------------------
class Toggler extends React.Component {
state = {
isToggled: false
import React from 'react'
import styled from 'styled-components'
export default class BasicToggler extends React.Component {
state = {
isToggled: false
}
toggle = () => {
this.setState(state => ({isToggled: !state.isToggled}))
import React from 'react'
import styled from 'styled-components'
class ScrollingWrapper extends React.Component {
state = { hasScrolled: false }
componentDidMount() {
this.scrollingWrapper.addEventListener('scroll', this.onScroll)
}