Skip to content

Instantly share code, notes, and snippets.

View MattMcAdams's full-sized avatar
🏠
Working from home

Matthew McAdams MattMcAdams

🏠
Working from home
View GitHub Profile
@MattMcAdams
MattMcAdams / settings.json
Last active April 24, 2022 21:39
Code Comment Anchors
"commentAnchors.tags.list": [
{
"tag": "ANCHOR",
"iconColor": "default",
"highlightColor": "",
"scope": "file",
"styleComment": true
},
{
"tag": "TEMP",
function filterSelection(filter) {
const posts = document.getElementsByClassName("post-card"); // find all posts
console.log(posts);
if (filter === "all") filter = null;
console.log(filter);
for ( let i = 0; i < posts.length; i++) {
let post = posts[i];
console.log(post);
@MattMcAdams
MattMcAdams / responsive-typography.scss
Created October 11, 2019 21:26
proof of concept of a more powerful system to consistantly control typographical styles across viewports
// The initial idea here is that we want to have a typographical scale based on a ratio
// and then use a different ratio for larger screens.
// This gist uses mixins and functions from other gists and the current build of Stratus, which will
// hoepfully implement this in the future.
$scale: 1.2; // Set the type scale for the small screen
:root {
--type-size-h1: type-size(h1); // This will set the CSS variable for h1 to the h1 size as calculated by our function
}
@MattMcAdams
MattMcAdams / reset-mixin.scss
Created September 24, 2019 21:14
mixin that allows easy resets to common properties
@mixin reset($properties...) {
@for $i from 0 to length($properties) {
@if nth($properties, $i + 1) == margin {
margin: 0;
}
@if nth($properties, $i + 1) == padding {
padding: 0;
}
@if nth($properties, $i + 1) == border {
border: 0;
@MattMcAdams
MattMcAdams / position-shorthand.scss
Created September 24, 2019 21:13
Mixin for a position shorthand that includes a "cover" property value that makes the element cover its parent
/// Shorthand for the position property
/// includes quick option to make the element cover its parent
/// @group utility
/// @param {string | keyword(cover)} $position - value for position property
/// @param {number} $top - value for top property
/// @param {number} $right [$top] - value for right property
/// @param {number} $bottom [$top] - value for bottom property
/// @param {number} $left [$right] - value for the left property
@mixin position($position, $top: null, $right: $top, $bottom: $top, $left: $right) {
@if $position == cover {
@MattMcAdams
MattMcAdams / clearfix.scss
Created September 24, 2019 21:12
utility mixin to add a clearfix. Intended to be used on an ::after element
/// Clearfix for floated containers, used as a bugfix
/// @group utility
@mixin clearfix {
content: '';
visibility: hidden;
display: block;
font-size: 0;
height: 0;
clear: both;
}
@MattMcAdams
MattMcAdams / functions.scss
Last active October 21, 2019 07:58
A group of functions to calculate font sizes and line heights based on a typographical scale
/// Power function
/// @group utility
/// @param {number} $base - number to be multiplied
/// @param {number (unitless)} $exponents - number of times it should be multiplied
/// @return `$base` to the power of `$exponents`
@function pow($base, $exponents) {
$raised: 1;
@for $i from 1 through $exponents {
$raised: $raised * $base;
}
@MattMcAdams
MattMcAdams / space-unit.scss
Last active September 24, 2019 21:03
custom measurement unit to help maintain relationships between elements
/// base unit of measurement for spacing
/// @type number
$space-unit: $line-height !default;
/// function to create a general unit of measurement for spacing
/// @requires $space-unit
/// @group spacing
/// @param {number} $value
/// @return number(rem) = `$space-unit` times `$value`
@function s($value) {
@MattMcAdams
MattMcAdams / color-functions.scss
Created September 24, 2019 21:02
Several functions and mixins to set and manipulate colors according to a scale
/// Tint color
/// @group utility
/// @param {color} $color - color to be tinted
/// @param {number(%)} $percentage - key to extract value of
/// @return `$color` mixed with white by `$percentage`
@function tint($color, $percentage) {
@return mix(white, $color, $percentage);
}
/// Shade color
@MattMcAdams
MattMcAdams / deepmap.scss
Created September 24, 2019 21:00
utility function to get value of a key in a deep map
/// Get value from a deep map
/// @group utility
/// @param {map} $map - source map to pull key from
/// @param {string...} $keys - key to extract value of
/// @return key value
@function map-deep-get($map, $keys...) {
@each $key in $keys {
$map: map-get($map, $key);
}
@return $map;