diff --git a/README.md b/README.md index fdaff5f..9dbc6a7 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ The wave background from [mtps/auth](https://git.app.ygg/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 ``, with no asset paths to resolve. -Open `demo.html` after `pnpm build` to see it. +Open `demo.html` after `pnpm build` to see it; switch the OS to dark mode for the dark look. ## Install @@ -34,6 +34,15 @@ The class works on any element, not just `body`. Set these variables on the elem | `--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](https://git.app.ygg/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` | ```css .night { --waves-from: #3a6073; --waves-to: #16222a; --waves-angle: 160deg; } diff --git a/package.json b/package.json index ac26ad6..647b0df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@mtps/waves", - "version": "0.1.0", + "version": "0.2.0", "description": "Wave texture under a colour gradient, as one self-contained CSS file", "license": "UNLICENSED", "type": "module", diff --git a/src/waves.css b/src/waves.css index 36c1166..1f547cb 100644 --- a/src/waves.css +++ b/src/waves.css @@ -3,15 +3,22 @@ * `difference`. Originally the page background of mtps/auth. * * Put class="waves" on any element (body included) and override the - * variables on it or any ancestor. + * variables on it or any ancestor. Under prefers-color-scheme: dark it + * switches to the darker look from mtps/homepage, with its own variables. */ .waves { + --_waves-from: var(--waves-from, #f7b440); + --_waves-to: var(--waves-to, hsl(7 82% 63%)); + --_waves-blend: var(--waves-blend, difference); background: - linear-gradient( - var(--waves-angle, -45deg), - var(--waves-from, #f7b440) 0%, - var(--waves-to, hsl(7 82% 63%)) 100% - ), + linear-gradient(var(--waves-angle, -45deg), var(--_waves-from) 0%, var(--_waves-to) 100%), url('./waves.png') 0 0 / var(--waves-tile, 400px) repeat; - background-blend-mode: difference; + background-blend-mode: var(--_waves-blend); +} +@media (prefers-color-scheme: dark) { + .waves { + --_waves-from: var(--waves-dark-from, hsl(304 97% 37% / 0.4)); + --_waves-to: var(--waves-dark-to, hsl(218 97% 37% / 0.4)); + --_waves-blend: var(--waves-dark-blend, exclusion); + } }