These below snippets go into admin/main.js
| 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({ |
| // reading from the search parameter | |
| console.log(params.q); | |
| // writing to the URL in the navigation bar | |
| params.q = "new query"; |
| 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; |
| import { css, html, LitElement, nothing } from "lit"; | |
| import { | |
| customElement, | |
| property, | |
| queryAssignedNodes, | |
| state, | |
| } from "lit/decorators.js"; | |
| const sharedCSS = css` | |
| :host { |
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!
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):
- Finds all of the uses of aasm in our Rails models itself, so we don't have to list them out
- 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!
This is a proof of concept, re-creating USWDS styles in MJML.
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.
Tools like MJML help make this easier, by providing an abstraction layer over the complex markup we need to ensure cross-email-client compatibility.
| // 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)"); |
| <!-- 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> |