@exegia/specular 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Emmanuel De Freitas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,10 +1,32 @@
1
+ <div align="center">
2
+
3
+ <img src="assets/logo.svg" alt="" width="132" height="132">
4
+
1
5
  # @exegia/specular
2
6
 
3
- Specular lighting for Tailwind v4 + React: a highlight that tracks the pointer.
4
- Declare a surface, get a utility
5
- family that draws a two-layer inset "bezel" one axis at a time, a
6
- tailwind-merge config that keeps those utilities alive in `cn()`, and React
7
- primitives that light the surface with the pointer.
7
+ **✨ Specular lighting for Tailwind v4 + React — a two-layer inset bezel as
8
+ utilities, a `cn()` that keeps them alive, and a rim highlight that tracks the
9
+ pointer.**
10
+
11
+ [![npm](https://img.shields.io/npm/v/@exegia/specular?color=6366f1&labelColor=1c1917)](https://www.npmjs.com/package/@exegia/specular) [![types](https://img.shields.io/npm/types/@exegia/specular?color=38bdf8&labelColor=1c1917)](https://www.npmjs.com/package/@exegia/specular) [![provenance](https://img.shields.io/badge/npm-provenance-a855f7?labelColor=1c1917)](https://www.npmjs.com/package/@exegia/specular#provenance) [![runtime deps](https://img.shields.io/badge/runtime%20deps-0-f43f5e?labelColor=1c1917)](#install) [![license](https://img.shields.io/npm/l/@exegia/specular?color=fbbf24&labelColor=1c1917)](LICENSE)
12
+
13
+ <img src="assets/demo.gif" alt="Six avatars whose rim highlights turn to follow the pointer as it moves across them" width="100%">
14
+
15
+ <sub>Six discs, one window listener. Recorded from <a href="examples/vite-react"><code>examples/vite-react</code></a>.</sub>
16
+
17
+ </div>
18
+
19
+ ---
20
+
21
+ Declare a surface, get a utility family that draws a two-layer inset "bezel"
22
+ one axis at a time, a tailwind-merge config that keeps those utilities alive
23
+ in `cn()`, and React primitives that light the surface with the pointer.
24
+
25
+ ## Install
26
+
27
+ ```bash
28
+ npm i @exegia/specular # or: bun add / pnpm add / yarn add
29
+ ```
8
30
 
9
31
  | export | contents |
10
32
  |---|---|
@@ -97,8 +119,8 @@ For a surface `S` and a layer `L`. Every utility also emits the base
97
119
  | utility | writes |
98
120
  |---|---|
99
121
  | `S-base` (or `baseClass`) | `box-shadow: var(--tw-S-shadow)` |
100
- | `S-L` | `--tw-S-L-alpha: 100` |
101
- | `S-L/40`, `S-L/[0.4]` | `--tw-S-L-alpha: 40` (fractions are scaled; `/80` ≡ `/[0.8]`) |
122
+ | `S-L` | the base `box-shadow` only: layer `L` at its configured alpha, so the `dark` preset applies |
123
+ | `S-L/40`, `S-L/[0.4]` | `--tw-S-L-alpha: 40` (fractions are scaled; `/80` ≡ `/[0.8]`); `/100` is explicit full strength |
102
124
  | `S-L-t-N` | `--tw-S-L-y: calc(N * 1px)` — light enters from the top, pushes the layer down |
103
125
  | `S-L-b-N` | `--tw-S-L-y: calc(N * -1px)` |
104
126
  | `S-L-l-N` / `S-L-r-N` | `--tw-S-L-x` |
package/dist/plugin.js CHANGED
@@ -20,6 +20,9 @@ export function normalizeAlpha(raw) {
20
20
  return String(Math.round(parseFloat(v) * 10000) / 100);
21
21
  return v;
22
22
  }
23
+ /** The `DEFAULT` value handed to the bare layer class. A sentinel, not a
24
+ * number, so `S-L-[100]` (an arbitrary value) still writes the alpha. */
25
+ const CONFIGURED = "configured";
23
26
  const instanceVar = (s, l, p) => `--tw-${s}-${l}-${p}`;
24
27
  const presetVar = (s, l, p) => `--${s}-${l}-${p}`;
25
28
  function chain(s, l, p) {
@@ -75,8 +78,14 @@ export function createPlugin(surfaces, options = {}) {
75
78
  const n = `${s.name}-${l.name}`;
76
79
  const v = (p) => instanceVar(s.name, l.name, p);
77
80
  const set = (p, f = (x) => x) => (value) => ({ ...base, [v(p)]: f(value) });
78
- // Bare = full alpha; `/40` and `/[0.4]` = 40.
79
- matchUtilities({ [n]: (value, { modifier }) => ({ ...base, [v("alpha")]: normalizeAlpha(modifier ?? value) }) }, { values: { DEFAULT: "100" }, modifiers: "any" });
81
+ // Bare = the configured alpha: the class emits only the composed
82
+ // box-shadow, so the alpha chain falls through to the preset (the
83
+ // `dark` block) and then the config. Writing 100 here would make the
84
+ // canonical `bezel-lit bezel-dim` ignore both. `/40` and `/[0.4]` = 40;
85
+ // `/100` is the explicit full-strength form.
86
+ matchUtilities({
87
+ [n]: (value, { modifier }) => modifier === null && value === CONFIGURED ? base : { ...base, [v("alpha")]: normalizeAlpha(modifier ?? value) },
88
+ }, { values: { DEFAULT: CONFIGURED }, modifiers: "any" });
80
89
  // The letter names the edge the light enters from.
81
90
  matchUtilities({ [`${n}-t`]: set("y"), [`${n}-l`]: set("x"), [`${n}-blur`]: set("blur"), [`${n}-spread`]: set("spread") }, lengths(false));
82
91
  matchUtilities({ [`${n}-b`]: set("y", negate), [`${n}-r`]: set("x", negate) }, lengths(true));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exegia/specular",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/emmanuel-defreitas/specular.git"