Skip to content

Instantly share code, notes, and snippets.

View caseywatts's full-sized avatar

Casey Watts caseywatts

View GitHub Profile
@caseywatts
caseywatts / styles.css
Created November 17, 2026 16:18
"Print page" fixes for Firefox
@media print {
/* Fixes paragraph truncation in Firefox */
body {
display: block !important;
overflow: visible !important;
}
.flex-fill {
min-height: 0 !important;
}
@caseywatts
caseywatts / README.md
Last active October 19, 2026 21:32
USWDS-themed Instantsearchjs (Algolia search / Meillisearch)
@caseywatts
caseywatts / README.md
Created October 1, 2026 16:30
USWDS Decap Widgets

Decap Widgets for USWDS Components

Decap offers custom widgets, that can be added from Decap's markdown editor.

Dependencies:

  • Some widgets here use the UWSDS core library (e.g. usa-button class must be available)
  • Some depend on OGDS Elements (an implementation of USWDS). This is needed to make the markup simple enough for it to be reliable parsing with a regular expression (RegEx).

Widgets:

  • USWDS Button link (for a call to action)
  • the usa-button class must be available, from USWDS
@caseywatts
caseywatts / README.md
Last active October 9, 2026 14:35
Eleventy Custom Markdown Parser

Using Eleventy for USWDS projects

This eleventy config does several things to make it easier to work with USWDS:

  • Exposes a filter asMarkdown that can be used in hard-coded (non-markdown) HTML files. This uses the same markdown parser that Markdown uses, to prevent issues with having multiple instances or libraries.
  • External links get formatted as usa-link--external, and open in a new tab
  • Lists are formatted with usa-list
  • The typographer setting is enabled, giving us features like smart quotes.
@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!