Skip to content

Instantly share code, notes, and snippets.

View esr360's full-sized avatar
👽
Best CSS-in-JS solution of 2020?

Edmund esr360

👽
Best CSS-in-JS solution of 2020?
View GitHub Profile
/// Map Search
/// Get the first occurance of a key from a nested map
///
/// @author [@esr360](http://twitter.com/esr360)
///
/// @access public
/// @group Tools
///
/// @param {map} $map - the map you would like to search
/// @param {string} $target-key - the key you are searching for
@esr360
esr360 / sass.js
Last active February 26, 2017 23:48
// Requirements
var sass = require('node-sass');
var fs = require('fs');
var mkdirp = require('mkdirp');
var getDirName = require('path').dirname;
function compileSass(options = {}) {
// set default options
options = Object.assign({
style: 'expanded'
var sass = require('node-sass');
sass.render({
file: scss_filename,
[, options..]
}, function(err, result) { /*...*/ });
// OR
var result = sass.renderSync({
data: scss_content
[, options..]
});
import * as app from '../../app';
/**
* Determine if an element is in the viewport
*
* @access public
*
* @param {Object} custom - where custom options are passed
*/
export function inViewport(custom) {
@esr360
esr360 / extend-module.scss
Created October 24, 2017 08:01
Extend a module within another module/component
@include module('header') {
@include component('social-links') {
@include _module('list', ('reset', 'inline'), false);
@include component('item') {
@include _module('button', (
'brand-1-light', 'circle', 'icon', 'border', 'size-3'
));
}
}
const MODULE = 'accordion';
document.querySelectorAll(`.${MODULE}`).forEach(accordion => {
const panels = accordion.querySelectorAll(`.${MODULE}__panel`);
panels.forEach(panel => {
const TITLE = panel.querySelector(`.${MODULE}__title`);
const CONTENT = panel.querySelector(`.${MODULE}__content`);
...
});
.accordion {
color: map-get($colors, brand-2);
...
}
@import 'modules/utilities/colors/colors';
@import 'modules/elements/accordion/accordion';
//*****************************************************************
// Utilities
//*****************************************************************
@import 'modules/utilities/grid/grid';
@import 'modules/utilities/colors/colors';
@import 'modules/utilities/container/container';
@import 'modules/utilities/typography/typography';
@import 'modules/utilities/core/core';
@import 'modules/utilities/helpers/helpers';
@mixin accordion($custom: ()) {
$options: map-merge((
panel-bg: #,
panel-text-color: #
), $custom);
.accordion {
&__panel {
background: map-get($options, panel-bg);