8000 GitHub - bolerish/edge: UI, a little more alive. · GitHub
[go: up one dir, main page]

Skip to content
bolerishPublic

About

UI, a little more alive.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Edge

Connect your React components to one shared directional light.

edge Demo

Quick start

Requires React 18 or 19.

npm install @bolerish/edge
import { Edge } from '@bolerish/edge';

export function Area() {
  return (
    <Edge.Provider>
      <Edge.Surface as="article">Your card</Edge.Surface>
      <Edge.Surface as="button" type="button">
        Save
      </Edge.Surface>
    </Edge.Provider>
  );
}

React prepares the default styles automatically when a surface connects. For SSR, render <Edge.Styles /> once before application styles; pass your request nonce with <Edge.Styles nonce={nonce} /> when CSP requires it. Keep the same nonce during hydration. Existing @bolerish/edge/style.css imports remain supported. Only marked surfaces respond. Existing colors, layout and interactions are preserved.

Connect existing components with attributes

Explicit Edge.Surface and useSurface connections remain supported. To discover marked DOM descendants instead, opt in with discover:

<Edge.Provider discover surfaceOptions={{ edgeStyle: 'raised' }}>
  <Button {...Edge.surface}>Save</Button>
</Edge.Provider>

Edge.surface is a fixed object containing only data-edge-surface; it does not supply classes, styles or refs. Your component must forward that attribute to its DOM host. No CSS-tool adapter is required. surfaceOptions accepts the same appearance options as Edge.Surface, applying only to discovered surfaces.

Discovery adds a div boundary. The nearest discovery boundary owns each marked host, including dynamically added hosts. Portals outside the boundary are excluded; use useSurface or Edge.Surface there. Explicit connections take priority on the same host. A nested Provider without discover creates no DOM boundary and does not change the outer discovery scope. Discovery connects after hydration; render Edge.Styles for SSR. Existing pseudo-elements, overflow and stacking still need review. Do not use discovery where the added div would make the HTML invalid.

Direction and range

<Edge.Provider direction="toward" range={480}>
  <Edge.Surface>Your card</Edge.Surface>
</Edge.Provider>

direction defaults to toward, facing highlights toward the pointer. Use away for the opposite direction. Recessed surfaces draw the highlight one decorative edge thickness inward while preserving the selected direction. range is the fade distance outside each surface in CSS pixels, defaults to 480, and must be positive and finite. These options affect pointer-driven lighting; fixed lighting uses staticDirection instead. With range={40}, the effect fades to zero when the pointer is 40 CSS pixels outside a surface. It does not limit the bright area inside a surface to a 40-pixel circle around the pointer.

The direction values were renamed: replace gather with toward and spread with away, and replace radius with range when upgrading from 0.3.0.

Documentation

See the guides and API reference for styles, motion, integration and rendering.

Contributing

See CONTRIBUTING.md for setup and checks.

License

MIT.

About

UI, a little more alive.

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

0