mtpsandClaude Opus 5.5 86c73641a3
Publish / publish (push) Successful in 5s
Dark mode from mtps/homepage
Under prefers-color-scheme: dark, use homepage's translucent
magenta-to-blue gradient with exclusion instead of difference.
--waves-dark-from/-to/-blend override it, --waves-blend the light
blend. The texture is referenced once, so it's inlined once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-20 13:52:53 +00:00
2026-10-20 13:52:53 +00:00
2026-10-20 13:52:53 +00:00
2026-10-20 13:52:53 +00:00

@mtps/waves

The wave background from mtps/auth: a tiling wave texture under a colour gradient, blended with difference. It ships as one self-contained CSS file with the texture inlined, so it works the same in Astro, Vite or a plain <link>, with no asset paths to resolve.

Open demo.html after pnpm build to see it; switch the OS to dark mode for the dark look.

Install

The package is on the Gitea npm registry. Tell npm/pnpm where @mtps lives with an .npmrc in the consuming project:

@mtps:registry=https://git.app.ygg/api/packages/mtps/npm/
pnpm add @mtps/waves

Use

import '@mtps/waves'; // or '@mtps/waves/waves.css'
<body class="waves">

The class works on any element, not just body. Set these variables on the element or any ancestor to change the look:

variable default
--waves-from #f7b440 gradient start
--waves-to hsl(7 82% 63%) gradient end
--waves-angle -45deg gradient direction
--waves-tile 400px texture tile size
--waves-blend difference blend of gradient and texture

With prefers-color-scheme: dark it switches to the dark look from mtps/homepage: a translucent magenta-to-blue gradient blended with exclusion. These replace --waves-from, --waves-to and --waves-blend in dark mode:

variable default
--waves-dark-from hsl(304 97% 37% / 0.4)
--waves-dark-to hsl(218 97% 37% / 0.4)
--waves-dark-blend exclusion
.night { --waves-from: #3a6073; --waves-to: #16222a; --waves-angle: 160deg; }

Develop and release

  • src/waves.css is the source. It refers to ./waves.png.
  • pnpm build writes dist/waves.css with the PNG inlined as a data URI. It also runs on pnpm pack/publish through prepack.
  • Bump version in package.json, commit, then git tag vX.Y.Z && git push --follow-tags. .gitea/workflows/publish.yml publishes the version to the registry. The tag has to match package.json.

TODO: switch the texture to SVG

The texture is still the 400×400 PNG from mtps/auth (src/waves.png, ~10 KiB, ~14 KiB inlined as base64). An SVG version would be better:

  • Size: a wave tile is a couple of <path>s, a few hundred bytes instead of ~14 KiB of base64.
  • Sharpness: it stays crisp on high-DPI screens and at any --waves-tile; the PNG blurs when scaled up.
  • Styling: line colour, stroke width and opacity could become variables too, instead of being baked into the pixels.
  • Licensing: the PNG's origin isn't recorded. Its old name, papyrus-dark.png, suggests it came from a pattern collection, possibly one that requires attribution. Redrawing it removes that question.

How to switch:

  1. Draw one repeating tile (e.g. two offset sine-like <path>s with stroke and fill="none") whose edges line up, and save it as src/waves.svg.
  2. Reference it as url('./waves.svg') in src/waves.css.
  3. Teach scripts/build.mjs to inline .svg as data:image/svg+xml,… (URL-encoded rather than base64, which is smaller).
  4. Compare it with demo.html against the current version and release it as a minor version. The look should stay the same, so it isn't a breaking change.
S
Description
Wave background with a gradient overlay, as a CSS package (@mtps/waves)
Readme
43 KiB
0 Stars 1 Watchers 0 Forks
Languages
CSS 39.9%
JavaScript 32.7%
HTML 27.4%