Skip to content

Instantly share code, notes, and snippets.

View stephenway's full-sized avatar

Stephen Way stephenway

View GitHub Profile
@kof
kof / button-hooked.js
Last active November 23, 2021 08:13
Inject styles with custom hooks
const styles = {
button: {
color: 'red'
}
}
const Button = () => {
const {classes} = useStyles(styles)
return <button className={classes.button}>Test<Button>
}
@kitze
kitze / conditionalwrap.js
Created October 25, 2017 16:54
one-line React component for conditionally wrapping children
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
<div>
<ConditionalWrap
condition={shouldLinkToHome}
wrap={children => <a href="/">{children}</a>}
>
@HaNdTriX
HaNdTriX / AppBarWithTabs.js
Last active August 11, 2021 03:00
Example next.js and Material-UI next: TabNav with shared state
import React from 'react'
import Router from 'next/router'
import AppBarMD from 'material-ui/AppBar'
import Tabs, { Tab } from 'material-ui/Tabs'
const routes = [
'/',
'/articles'
]
@marc-rutkowski
marc-rutkowski / README.md
Last active June 17, 2021 13:17
react-storybook with react-boilerplate (content of the .storybook/ directory)

react-storybook with react-boilerplate

Explains how to install and configure react-storybook into a project created from the react-boilerplate setup.

Intro

React-boilerplate (rbp) is a good starting point to create React apps, with a focus on performance, best practices and DX.

The community around the repository is amazing and a constant source of learning.

@jawb
jawb / cssImage.php
Last active July 31, 2016 14:23
Image to CSS
<?php
/*
Demos:
https://jsbin.com/gakudi/1/edit?output
https://jsbin.com/xunifo/edit?output
Usage:
php cssImage.php scale image output
*/
@LeaVerou
LeaVerou / dabblet.css
Last active January 6, 2022 10:30
Media query to detect full screen mode!
/**
* Media query to detect full screen mode!
* Y U NO WORK Chrome??
* Firefox, you’re lovely.
*/
body {
background: red;
font: bold 400% Helvetica Neue, sans-serif;
color: white;
@geelen
geelen / gulpfile.js
Last active October 11, 2017 11:47 — forked from superhighfives/gulpfile.js
Harp with BrowserSync! Woo!
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var harp = require('harp');
/**
* Serve the Harp Site from the src directory
*/
gulp.task('serve', function () {
harp.server(__dirname + '/src', {
@MattWilcox
MattWilcox / gist:89e04beb7843b21c204a
Created July 18, 2014 15:18
How easy it would be to do Responsive Images in HTML and CSS if https://developer.mozilla.org/en-US/docs/Web/CSS/attr worked.
<!doctype html>
<html>
<head>
<style>
img:after { content: attr(data-small url); }
@media screen and (min-width:400px) {
img:after { content: attr(data-medium url); }
}
@noprompt
noprompt / slurp.clj
Created February 19, 2014 04:52
How to use slurp from ClojureScript
(ns foo.core
(:refer-clojure :exclude [slurp]))
(defmacro slurp [file]
(clojure.core/slurp file))
;; In CLJS
(ns bar.core
(:require [foo.core :include-macros true :refer [slurp]]))
@jackie
jackie / breakpoints.json
Last active December 19, 2015 15:28
Sass Script function to get breakpoint values from a JSON file.
{
"phone" : "all and (max-width: 603px)",
"desktop": "all and (min-width: 1025px)",
"tablet" : "all and (min-width: 604px) and (max-width: 1024px)"
}