Status island

A dark pill that hangs from the top of the page and reshapes itself around what is happening: resting on a branch name, stretching out and filling up while a deploy runs, then settling on a green tick.

Ship it from anywhere

Press the island to deploy. It stays out of the way until there is something to say.

Options

Screen
Colour

Code

import { useLayoutEffect, useRef } from "react";
import "./status-island.css";
import "./spinner.css";

/* state is "rest", "busy" or "done". You decide when it changes; the island reshapes
   itself to fit. time is how long it takes to fill, in milliseconds.

   <StatusIsland state={state} onClick={deploy} rest="main" busy="Deploying to production" done="Live" /> */
export function StatusIsland({ state = "rest", rest, busy, done, time = 2600, ...props }) {
  const island = useRef(null);

  useLayoutEffect(() => {
    const fit = () => {
      const part = island.current.querySelector('[data-for="' + state + '"]');
      island.current.style.setProperty("--dh-island-width", part.offsetWidth + "px");
    };
    fit();
    document.fonts?.ready.then(fit);
  }, [state, rest, busy, done]);

  return (
    <button className="dh-island" type="button" data-state={state} aria-live="polite" ref={island} style={{ "--dh-island-time": time + "ms" }} {...props}>
      <span data-for="rest">{rest}</span>
      <span data-for="busy">
        <span className="dh-spinner" />
        {busy}
      </span>
      <span data-for="done">
        <i>
          <svg viewBox="0 0 16 16" width="14" height="14" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
            <path d="M3.500 8.500l3 3 6-7" />
          </svg>
        </i>
        {done}
      </span>
    </button>
  );
}

Ship it from anywhere

Press the island to deploy. It stays out of the way until there is something to say.