Skip to content

Instantly share code, notes, and snippets.

View nathansmith's full-sized avatar
😎
Ask me about free high fives!

Nathan Smith nathansmith

😎
Ask me about free high fives!
View GitHub Profile
@nathansmith
nathansmith / _wp-block-columns.scss
Created May 28, 2020 15:06
Sass version of the WordPress column block.
.wp-block-columns {
display: flex;
margin-bottom: $gutter;
flex-wrap: wrap;
}
@media (min-width: 782px) {
.wp-block-columns {
flex-wrap: nowrap;
}
@nathansmith
nathansmith / _wp-block-buttons.scss
Last active May 23, 2020 01:57
WordPress updates inject new/different markup and CSS. This attempts to "fix" it.
div.wp-block-buttons {
/*
=====
NOTE:
=====
I know this code looks a bit gross.
But that is more of a reflection upon
the WordPress block styles themselves.
@nathansmith
nathansmith / flex-row-reverse.css
Last active May 13, 2020 16:45
Example of auto layout flexbox, with reverse order
.flex-parent {
align-items: center;
display: flex;
flex-direction: row-reverse;
flex-wrap: wrap;
margin-left: auto;
margin-right: auto;
max-width: 1200px;
}
@nathansmith
nathansmith / AppLayout.js
Last active April 29, 2020 18:50
Spreading specific "other" props
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
// UI.
import SkipLink from '../components/SkipLink';
// Layout.
import AppLayoutFooter from './AppLayoutFooter';
import AppLayoutHeader from './AppLayoutHeader';
@nathansmith
nathansmith / README.md
Last active December 10, 2021 16:08
PurgeCSS example usage

Read more here…

https://purgecss.com


To install PurgeCSS, run this command.

npm install purgecss --save-dev
@nathansmith
nathansmith / _has-css-animation.scss
Created April 14, 2020 16:43
How to enable (or disable) CSS animation via JS.
html:not([data-has-css-animation='true']) {
@include remove-css-animation;
}
@media (prefers-reduced-motion: reduce) {
@include remove-css-animation;
}
@nathansmith
nathansmith / callUseEffect.js
Created March 31, 2020 15:25
Forces `useEffect` to be called in Jest tests
import React from 'react';
import { render } from 'react-dom';
// Helper.
const callUseEffect = () => {
const Noop = () => null;
const root = document.createElement('div');
render(<Noop />, root);
};
@nathansmith
nathansmith / _block-code.scss
Created March 25, 2020 18:51
Styling for syntax highlighted code blocks
// ==========================
// `<pre>` and `<code>` tags.
// ==========================
code,
pre,
pre .token[class] {
font-family: $font-family-mono;
}
@nathansmith
nathansmith / _colors.scss
Last active March 24, 2020 20:41
How to manage Sass colors, in a "map" object
// ====================
// Default placeholder.
// ====================
/*
This is empty by default, but the intent
is that it would be overwritten by another
variable for a custom site implementation.
*/