@boyernick/standard-ui-react 0.4.2-canary.66 → 0.4.2-canary.68

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@boyernick/standard-ui-react",
3
- "version": "0.4.2-canary.66",
3
+ "version": "0.4.2-canary.68",
4
4
  "description": "React components for StandardUI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,6 +18,14 @@ export interface GlassConfig {
18
18
  rim?: number;
19
19
  /** Rim light width. Default 3.5, less on small panes. */
20
20
  rimWidth?: number;
21
+ /**
22
+ * A hairline shade just inside the outline. On a light page the rim light
23
+ * has nothing to brighten, so without it a pane's only edge is its soft
24
+ * shadow. Any edge also turns the border into an angled gradient: rim and
25
+ * hairline are strongest at the top-left and bottom-right corners and fade
26
+ * toward the other two. Default 0.22 over a light ground, 0 over a dark one.
27
+ */
28
+ edge?: number;
21
29
  /** Specular sheen on the lit side of the bezel. Default 0.35. */
22
30
  specular?: number;
23
31
  /** Frost blur, as a Gaussian sigma. Default 3. */
@@ -94,6 +102,7 @@ export interface ResolvedGlass {
94
102
  dispersionBlue: number;
95
103
  rim: number;
96
104
  rimWidth: number;
105
+ edge: number;
97
106
  specular: number;
98
107
  frost: number;
99
108
  grain: number;
@@ -144,6 +153,7 @@ export function resolveGlass(
144
153
  dispersionBlue: pick(config.dispersionBlue, 0.8, 0, 1),
145
154
  rim: pick(config.rim, 0.5, 0, 2),
146
155
  rimWidth: pick(config.rimWidth, Math.min(3.5, Math.max(1.25, short * 0.04)), 0.5, 12),
156
+ edge: pick(config.edge, options?.lightGround ? 0.22 : 0, 0, 1),
147
157
  specular: pick(config.specular, 0.35, 0, 2),
148
158
  frost: pick(config.frost, 3, 0, 16),
149
159
  grain: pick(config.grain, 0.07, 0, 0.5),
@@ -765,7 +765,7 @@ export function createLensGlass({ root, glassElements, defaults = {} }: LensGlas
765
765
  ["u_radius", glass.radius], ["u_power", glass.power], ["u_bezel", glass.bezel],
766
766
  ["u_bend", glass.bend], ["u_dispersionRed", glass.dispersionRed],
767
767
  ["u_dispersionBlue", glass.dispersionBlue], ["u_rim", glass.rim],
768
- ["u_rimWidth", glass.rimWidth], ["u_specular", glass.specular], ["u_frost", glass.frost],
768
+ ["u_rimWidth", glass.rimWidth], ["u_edge", glass.edge], ["u_specular", glass.specular], ["u_frost", glass.frost],
769
769
  ["u_grain", glass.grain], ["u_dim", glass.dim], ["u_fadeStart", glass.fadeStart],
770
770
  ["u_fadeEnd", glass.fadeEnd], ["u_shadow", glass.shadow],
771
771
  ["u_hover", glass.button ? pane.hover : 0], ["u_press", glass.button ? pane.press : 0],
@@ -31,6 +31,7 @@ uniform float u_dispersionRed;
31
31
  uniform float u_dispersionBlue;
32
32
  uniform float u_rim;
33
33
  uniform float u_rimWidth;
34
+ uniform float u_edge;
34
35
  uniform float u_specular;
35
36
  uniform float u_frost;
36
37
  uniform float u_grain;
@@ -117,14 +118,29 @@ void main() {
117
118
  );
118
119
  color *= u_dim + 0.06 * u_hover;
119
120
 
121
+ // Where the edge sits on the diagonal through the lit corner: 1 at the top
122
+ // left and bottom right, 0 at the other two corners. Over a light ground the
123
+ // rim and hairline follow it, so the border runs as an angled gradient
124
+ // rather than an even ring.
125
+ float diagonal = dot(n, normalize(vec2(-1.0, -1.0)));
126
+ float angled = pow(abs(diagonal), 1.5);
127
+ float lightGround = step(0.001, u_edge);
128
+
120
129
  // Rim light, strongest where the edge faces the light (top left), and a
121
130
  // sheen across the lit side of the bezel.
122
131
  vec2 light = normalize(vec2(-0.55, -1.0));
123
132
  float facing = max(dot(n, light), 0.0);
124
133
  float rim = 1.0 - smoothstep(0.0, u_rimWidth, inside);
125
- color += u_rim * (1.0 + 0.4 * u_hover) * rim * (0.55 + 0.45 * facing);
134
+ float rimShape = mix(0.55 + 0.45 * facing, 0.1 + 0.9 * angled * (diagonal > 0.0 ? 1.0 : 0.7), lightGround);
135
+ color += u_rim * (1.0 + 0.4 * u_hover) * rim * rimShape;
126
136
  color += u_specular * 0.35 * pow(t, 3.0) * facing;
127
137
 
138
+ // Hairline edge: a light ground clips the rim to white, so shade one CSS
139
+ // pixel inside the outline too, deepest at the bottom right.
140
+ float hairline = 1.0 - smoothstep(0.0, 1.0, inside);
141
+ float shade = (0.2 + 0.8 * angled) * (diagonal > 0.0 ? 0.65 : 1.0);
142
+ color = min(color, vec3(1.0)) * (1.0 - u_edge * hairline * shade);
143
+
128
144
  // Grain, fixed to the device pixel grid so a still pane never needs redrawing.
129
145
  color += (hash(floor(scenePx * u_dpr)) - 0.5) * u_grain;
130
146