Skip to content

Instantly share code, notes, and snippets.

View silouanwright's full-sized avatar

Silouan Wright silouanwright

  • StitchFix
  • New York
View GitHub Profile
@silouanwright
silouanwright / input.scss
Created March 7, 2024 17:05
Generated by SassMeister.com.
// Define SCSS variables with default values
$header-color: purple;
$font-size: 16px;
// Create CSS custom properties with the same names and default values
:root {
--header-color: #{$header-color};
--font-size: #{$font-size};
}
@silouanwright
silouanwright / classnames-to-classcat.js
Created May 27, 2020 21:04
Codemod to convert from classnames to classcat
// v.0.1.0
// This is a somewhat of a naive mod and can be improved.
module.exports = (file, api) => {
const j = api.jscodeshift; // alias the jscodeshift API
let root = j(file.source); // parse JS code into an AST
// Can we find an import path
const findImport = root.find(j.ImportDeclaration, {
specifiers: [
@silouanwright
silouanwright / store.js
Created October 19, 2015 19:29
Access useRoutes-enhanced history outside of components
var temporaryHistory = useRoutes(createHistory)({
routes: createRoutes(routes)
});
let unlisten = temporaryHistory.listen(function(error, state) {
if (error){
} else {
// Have to set the routes here somehow
console.log(state);