Skip to content

Instantly share code, notes, and snippets.

View ModulesUnraveled's full-sized avatar

Brian Lewis ModulesUnraveled

View GitHub Profile
@ModulesUnraveled
ModulesUnraveled / Semantic vs. Primitive Variable Names.md
Last active December 28, 2022 21:59
Examples of why to use Semantic variable names

We read our code far more than we write it, so plan accordingly.

Even if you don't plan on anyone reading your code, chances are someone will... even if it's you 12 months from now.

Why we use "semantic" variable names rather than "primitive" names.

What do we mean by "Primitive" names?

Primitive names typically call the thing what it is. Some examples are:

@ModulesUnraveled
ModulesUnraveled / Tailwind vs. 4K Methodologies.md
Last active October 7, 2021 02:25
Comparison of Tailwind example code, and how we'd write it at Four Kitchens

Tailwind vs. Four Kitchens Methodologies

Intro

For this post, I took a look at the card examples provided on the Tailwind website at https://v1.tailwindcss.com/components/cards.

In order to keeps things simple, I chose to focus on one example, the "Horizontal" card.

"Horizontal" example from tailwindcss.com

First of all, the name is poor because on mobile devices, it's stacked... That's why we believe a component's name should "describe it's purpose, rather than its appearance".

But on top of that, looking at the code, I'm even sure where the card styles actually start. As you can see in the screenshot, there's padding around the card... Looking at the code, there's no obvious way to know if that's coming from the card styles, or the component that's wrapping the card.

@ModulesUnraveled
ModulesUnraveled / A commentary on excerpts from the book Frontend Architecture for Design Systems.md
Last active July 5, 2023 11:18
A commentary on excerpts from the book "Frontend Architecture for Design Systems"

A commentary on excerpts from the book "Frontend Architecture for Design Systems"

Chapter 5: CSS

Single Responsibility Principle

Excerpt from the book

The single responsibility principle states that everything you create should be created for a single, focused reason. The styles you apply to a given selector should be created for a single purpose, and should do that single purpose extremely well.

@ModulesUnraveled
ModulesUnraveled / Frontend Methodology.md
Last active June 1, 2023 10:57
Frontend Methodology

Summary:

Defining a frontend architecture that implements modern best practices including component-based development, atomic organization, and the BEM css naming convention may take more forethought when initially starting up, but has consistently (across our projects) proven to actually speed up development as a project matures, and save both time and money when updates or bug fixes are required. It will also make any future frontend developer's experience with the codebase far more pleasant!

Component Based Development

DRY (Don't Repeat Yourself). Write code once, and re-implement it - instead of rewriting it

Because we follow component-based development principles, our projects get faster to work on over time. If you don't do things that way, projects inevitably get SLOWER to work on over time. And you're never sure if the change you're about to make is going to affect all of the places you want it to, nor if it's going to change the way some other element in an unrelated part of the site

@ModulesUnraveled
ModulesUnraveled / 4k
Created October 7, 2020 21:22
4k - Cross platform/language/team/etc. command scripting
#!/bin/sh
# Installation:
# - Copy this file to /usr/local/bin/k4
# - Make it executable `chmod +x /usr/local/bin/4k`
#
# Use:
# - Run `4k <command>`
# - If you haven't configured that command for the current project
# you'll be asked to configure it now
@ModulesUnraveled
ModulesUnraveled / 1. flexible-grid.twig
Last active November 13, 2020 02:29
Nested Paragraphs + PL
{#
# This is the PL template for the "parent" pattern
#}
{% set flexible_grid_base_class = flexible_grid_base_class|default('flexible-grid') %}
{% set item_count = flexible_grid_item_count|default(rows|length) %}
{# Dynamically define grid columns #}
{% if item_count is divisible by(3) %}
{% set flexible_grid_modifiers = ["columns-3"] %}

Intro

In this post, I'm going to run through how I setup visual regression testing on sites. Visual regression testing is essentially the act of taking a screenshot of a web page (whether the whole thing, or just a specific element) and comparing that against an existing screenshot of the same thing to see if there are any differences.

There's nothing worse than adding a new component, tweaking styles, or pushing a config update, only to have the client tell you two months later that some random other part of the site is now broken, and you discover it's because of the change that you pushed... now it's been two months, and reverting that change has significant implications.

That's the worst. Literally the worst.

All kinds of testing can help improve the stability and integrity of a site. There's Functional, Unit, Integration, Stress, Performance, Usability, and Regression, just to name a few. What's most important to you will change depending on the project requirements, but in my experience, Functiona

@ModulesUnraveled
ModulesUnraveled / pl-drupal-theme-images.md
Created July 7, 2018 10:05
How to make theme images work in Pattern Lab and Drupal

Someone recently asked the following in Slack. I didn't want it to get lost in Slack's history, so I thought I'd post it here:

Question: I’m setting a css background image inside my Pattern Lab footer template which displays correctly in Pattern Lab; however, Drupal isn’t locating the image. How is sharing images between PL and Drupal supposed to work?

My Answer: I’ve been using Pattern Lab’s built-in data.json files to handle this lately. e.g. you could do something like:

footer-component.twig:

@ModulesUnraveled
ModulesUnraveled / 01. New Project Setup Steps.md
Last active June 1, 2018 00:10
Setup Visual Regression Testing on a New Project

Install Java command line tools

Install the latest Java JDK (not JRE)

Require all the things

npm install --save-dev webdriverio chai node-notifier wdio-mocha-framework wdio-browserstack-service wdio-visual-regression-service

Add the test scripts to package.json

{
  "scripts": {
@ModulesUnraveled
ModulesUnraveled / 01. Setup a new (M1) mac.md
Last active December 13, 2023 15:37
Setup a new (M1) mac

Before anything else:

  • 1Password: The best password manager (Need this early so that I can enter passwords for the rest of the stuff below)

App Store:

  • Mindnode: Mind Mapping
  • Keynote: Presentations
  • Numbers: Spreadsheets
  • Pages: Documents