@boyernick/standard-ui-react 0.4.2-canary.67 → 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.67",
3
+ "version": "0.4.2-canary.68",
4
4
  "description": "React components for StandardUI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -19,10 +19,11 @@ export interface GlassConfig {
19
19
  /** Rim light width. Default 3.5, less on small panes. */
20
20
  rimWidth?: number;
21
21
  /**
22
- * A hairline shade just inside the outline, deepest away from the light.
23
- * On a light page the rim light has nothing to brighten, so without it a
24
- * pane's only edge is its soft shadow. Default 0.16 over a light ground,
25
- * 0 over a dark one.
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.
26
27
  */
27
28
  edge?: number;
28
29
  /** Specular sheen on the lit side of the bezel. Default 0.35. */
@@ -152,7 +153,7 @@ export function resolveGlass(
152
153
  dispersionBlue: pick(config.dispersionBlue, 0.8, 0, 1),
153
154
  rim: pick(config.rim, 0.5, 0, 2),
154
155
  rimWidth: pick(config.rimWidth, Math.min(3.5, Math.max(1.25, short * 0.04)), 0.5, 12),
155
- edge: pick(config.edge, options?.lightGround ? 0.16 : 0, 0, 1),
156
+ edge: pick(config.edge, options?.lightGround ? 0.22 : 0, 0, 1),
156
157
  specular: pick(config.specular, 0.35, 0, 2),
157
158
  frost: pick(config.frost, 3, 0, 16),
158
159
  grain: pick(config.grain, 0.07, 0, 0.5),
@@ -118,18 +118,28 @@ void main() {
118
118
  );
119
119
  color *= u_dim + 0.06 * u_hover;
120
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
+
121
129
  // Rim light, strongest where the edge faces the light (top left), and a
122
130
  // sheen across the lit side of the bezel.
123
131
  vec2 light = normalize(vec2(-0.55, -1.0));
124
132
  float facing = max(dot(n, light), 0.0);
125
133
  float rim = 1.0 - smoothstep(0.0, u_rimWidth, inside);
126
- 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;
127
136
  color += u_specular * 0.35 * pow(t, 3.0) * facing;
128
137
 
129
138
  // Hairline edge: a light ground clips the rim to white, so shade one CSS
130
- // pixel inside the outline instead, more on the side away from the light.
139
+ // pixel inside the outline too, deepest at the bottom right.
131
140
  float hairline = 1.0 - smoothstep(0.0, 1.0, inside);
132
- color = min(color, vec3(1.0)) * (1.0 - u_edge * hairline * (1.0 - 0.45 * facing));
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);
133
143
 
134
144
  // Grain, fixed to the device pixel grid so a still pane never needs redrawing.
135
145
  color += (hash(floor(scenePx * u_dpr)) - 0.5) * u_grain;