Skip to content

Instantly share code, notes, and snippets.

@conormcafee
conormcafee / 01_Menu.js
Last active October 9, 2020 08:08
Example of how to use React.cloneElement
// Menu
/*
The benefit now with having the MenuItem controls confined to one component, we can
now wrap our "lists" in this MenuItem, and MenuItem will pass `isOpen` down to
BirthdayCardsList and BirthdayPresentsList without explicty stating that.
We could also pass `setIsOpen` too on MenuItem if there is an action within one of
our lists to trigger a close of the list.
*/
@conormcafee
conormcafee / gatsby-prev-next.js
Created August 6, 2019 21:52
I ran into the scenario this evening needing to show previous/next on 2 different templates on a Gatsby JS project. There is a solution to do this in the gatsby-node.js file but this relies on you having a flat structure - ie just a blog. My project renders different templates based on a category specified in the frontmatter which meant that my …
import React from "react"
import { StaticQuery, graphql, Link } from "gatsby"
import styled from "styled-components"
import { Flex } from "@rebass/grid"
const PrevNext = props => {
const { data, slug, category } = props
const getAllPages = data.allMarkdownRemark.edges
const pages = getAllPages
.filter(page => page.node.frontmatter.category === category)
@conormcafee
conormcafee / .htaccess
Last active March 26, 2020 11:49
Jekyll .htaccess for Apache Server
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.+)/$ $1.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule .*[^/]$ %{REQUEST_URI}/ [L,R=301]
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
@conormcafee
conormcafee / index.html
Last active January 8, 2016 16:31
Savings
<form id="myform">
<h1>Please enter data</h1>
<input id="salary" type="number" placeholder="Salary" />
<br />
<input id="bills" type="number" placeholder="Bills" />
<br />
<input id="savings" type="number" placeholder="Savings" />
<br />
<input type="button" value="Save/Show" id="subButton"/>
<br />
@conormcafee
conormcafee / SassMeister-input.scss
Created December 21, 2015 16:11
Generated by SassMeister.com.
// ----
// libsass (v3.3.2)
// ----
$grey: #C1CAD6;
$orange: #EF4640;
$blue: #4392F1;
$green: #00A676;
$purple: #67597A;
$white: #ffffff;
@conormcafee
conormcafee / card.html
Created October 7, 2015 09:29
Flexbox Card
<section class="cards">
<div class="card">
<p>Title</p>
<p>Description</p>
<a href="#">Link</a>
</div>
<div class="card">
<p>Title</p>
<p>Description</p>
<a href="#">Link</a>
@conormcafee
conormcafee / SassMeister-input-HTML.html
Created October 5, 2015 13:18
Generated by SassMeister.com.
<!doctype html>
<html class="no-js" lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Grid</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
@conormcafee
conormcafee / grid.scss
Last active October 1, 2015 09:42
Generated by SassMeister.com.
// Define Max-Width & Margin
$max-width: 1200px;
$gutter: 50px;
$padding: 50px;
// Margin Percentage
$gutter-p: percentage($gutter / $max-width);
$padding-p: percentage($padding / $max-width);
$grid: (
@conormcafee
conormcafee / SassMeister-input.scss
Created September 25, 2015 16:02
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$max-width: 1100px;
$margin: 15px;
$margin-p: percentage(15px / 1100px);
$grid: (
one-col: 1100px - $margin,
@conormcafee
conormcafee / content.json
Last active September 8, 2015 11:05
JSON
{
"01": {
"title": "Title",
"content" : [
{
"subTitle": "Super Category"
}
]
}