Skip to content

Instantly share code, notes, and snippets.

View caseywatts's full-sized avatar
Hi, I’m Casey!

Casey Watts caseywatts

Hi, I’m Casey!
View GitHub Profile
@caseywatts
caseywatts / pagefindSetup.js
Created October 30, 2025 22:40
Pagefind with auto-updating query parameter
const params = new Proxy(new URL(window.location), {
get: (url, prop) => url.searchParams.get(prop),
set: (url, prop, value) => {
url.searchParams.set(prop, value);
window.history.replaceState({}, "", url);
},
});
window.addEventListener("DOMContentLoaded", async (event) => {
// initialize the search UI
const search = await new PagefindUI({
@caseywatts
caseywatts / example_usage.js
Last active October 31, 2025 16:00
Get/Set Query Parameters
// reading from the search parameter
console.log(params.q);
// writing to the URL in the navigation bar
params.q = "new query";
@caseywatts
caseywatts / README.md
Created October 30, 2025 21:15
Decap Custom Widgets for USWDS Components

These below snippets go into admin/main.js

@caseywatts
caseywatts / login-gov-component.js
Created September 22, 2025 19:46
login-gov-component.js
import { html, LitElement } from "lit";
import { customElement, property } from "lit/decorators.js";
import { submit } from "@open-wc/form-helpers";
import { importMdwdsLinkTag } from "../../lib/mdwdsAssetsPath.js";
@customElement("login-gov-button")
export class LoginGovButton extends LitElement {
@property({ type: Boolean })
big = false;
@caseywatts
caseywatts / maryland-alert.js
Last active August 21, 2025 16:51
USWDS Alert Web Component (Maryland version, alpha)
import { css, html, LitElement, nothing } from "lit";
import {
customElement,
property,
queryAssignedNodes,
state,
} from "lit/decorators.js";
const sharedCSS = css`
:host {
@caseywatts
caseywatts / README.md
Created May 21, 2025 15:36
Rspec custom formatter for CI

When looking at a running CI job, it's nice to see some progress occur so you know it's not stuck. Without this formatter, if you look at a running RSpec job, it looks stuck, because it doesn't display any output until it's run every test.

This formatter was created by a coworker, but I wanted to share this out in case it helps other folks!

@caseywatts
caseywatts / README.md
Last active July 14, 2025 19:24
Auto-generating aasm-diagram from Rails models

How can we automate generation of AASM diagrams, so our documentation will always be up to date with our code?

This gist does two main things that the aasm-diagram repo doesn't do on its own as of today (May 2025):

  1. Finds all of the uses of aasm in our Rails models itself, so we don't have to list them out
  2. Updates a markdown file that embeds each of the AASM diagrams

When should we generate this?

rails-erd uses database migrations as the moment to auto-generate an ERD diagram, which makes a ton of sense!

@caseywatts
caseywatts / README.md
Last active April 7, 2025 16:41
MJML Template for USWDS

This is a proof of concept, re-creating USWDS styles in MJML.

Why?

Email clients don't render everything the same way as web browsers -- for example, <button> element is not supported in email clients. There are many workarounds to get buttons to work in many email clients, each with pros and cons.

How?

Tools like MJML help make this easier, by providing an abstraction layer over the complex markup we need to ensure cross-email-client compatibility.

@caseywatts
caseywatts / color-scale-generation.js
Last active March 13, 2025 21:27
Maryland Color Scale Generation
// note: this is using OKLCH, see https://oklch.com/
// https://evilmartians.com/chronicles/oklch-in-css-why-quit-rgb-hsl
import Color from "colorjs.io";
let marylandRedBase = new Color("oklch(52.44% 0.2043 17)");
let marylandAntiRedBase = new Color("oklch(52.44% 0.2043 197)");
let marylandGoldBase = new Color("oklch(84.63% 0.1611 83.87)");
let marylandAntiGoldBase = new Color("lch(65.14% 57.88 274.65)");
let marylandBlueBase = new Color("oklch(68.06% 0.173 281.52)");
@caseywatts
caseywatts / Web Component Before After Example.html
Last active October 24, 2024 17:13
Web Component Before/After Example
<!-- Before -->
<div class="usa-site-alert usa-site-alert--emergency">
<div class="usa-alert">
<div class="usa-alert__body">
<h4 class="usa-alert__heading">Emergency Status</h4>
<p class="usa-alert__text"> Lorem ipsum dolor sit amet, <a href="#">consectetur adipiscing</a> elit, sed do eiusmod. </p>
</div>
</div>
</div>