Skip to content

Instantly share code, notes, and snippets.

View AndrewIngram's full-sized avatar
🦊
Being foxy

Andy Ingram AndrewIngram

🦊
Being foxy
View GitHub Profile
@AndrewIngram
AndrewIngram / LoginForm.js
Created January 30, 2019 19:21
Login Hook usage
import React from "react";
import useLogin from "@zego/hooks/useLogin";
import BaseLoginForm from "./BaseLoginForm";
import { withTrackableFeature } from "@zego/tracking";
const LoginFormImpl = props => {
const login = useLogin();
@AndrewIngram
AndrewIngram / routes.js
Created January 10, 2019 18:20
Basic router on top of Next.js
import { include, createRouter } from "./lib/router";
const commonRoutes = [
{
path: "/terms-of-business/",
name: "terms-of-business",
page: "TermsOfBusinessPage",
},
];
@AndrewIngram
AndrewIngram / routes.js
Last active January 9, 2019 17:10
Router API Idea
import { routes, include } from "@framework/router";
import { relayView, xmlView } from "@framework/engine";
const gbRoutes = routes(
route({ path: "/", view: "./views/gb/HomepageGb" }),
route({ path: "/scooter/", view: "./views/gb/ScooterGb" }),
route({ path: "/car/", view: "./views/gb/CarGb" }),
route({ path: "/private-hire/", view: "./views/gb/PrivateHireGb" }),
route({ path: "/blog/:slug/", view: "./views/BlogPost" })
);
const path = require('path');
const { createFileNode } = require(`gatsby-source-filesystem/create-file-node`);
async function createLocaleFileNode(filePath, createNode, createNodeId) {
// HACKITY HACK HACK
const fileNode = await createFileNode(
path.resolve(__dirname, filePath),
createNodeId
);
@AndrewIngram
AndrewIngram / Example.js
Last active October 17, 2018 17:19
Interpose FFS
<Interpose separator={<Hairline />}>
{products.map(products => <ProductListItem product={product} key={product.id} />)}
</Interpose>
@AndrewIngram
AndrewIngram / Price.js
Created May 10, 2018 22:25
Simple Relay component
// @flow
import { PureComponent } from 'react';
import { graphql, createFragmentContainer } from 'react-relay';
import FormatCurrency from '@zego/components/FormatCurrency';
import { type Price_price } from './__generated__/Price_price.graphql';
type Props = {
price: Price_price,
const authRequired = resolver => (obj, args, context, info) => {
if (!context.user) {
return new UserError('Authentication Required');
}
return resolver(obj, args, context, info);
}
const myResolver = authRequired((obj, args, context, info) => {
// Normal logic
});
import { makeExecutableSchema } from "graphql-tools";
import RawSchema from "./RawSchema";
import nodeResolver from "./nodeResolver";
import * as graphQLModules from "glob:./**/*.graphql.js";
const schema = new RawSchema();
export default schema => {
schema.define`
type Venue implements Node {
id: ID!
name: String!
address1: String
address2: String
description: String
postalCode: String
location: Point
const App = () => <Typography baseLine="24" baseSize="16" scale="classic" render={
typeComponents => md(typeComponents)`
# this will be a custom header
[custom link component](/url/to/link)`
} />;