Skip to content

feat(shaders): dashedBorder prop, default registration and DOM renderer fallback - #103

Open
lorenzopantano wants to merge 1 commit into
solid-tv:mainfrom
lorenzopantano:feat/dashed-border
Open

lorenzopantano wants to merge 1 commit into
solid-tv:mainfrom
lorenzopantano:feat/dashed-border

Conversation

@lorenzopantano

Copy link
Copy Markdown

Summary

@solidtv/renderer 2.0.9 ships a built-in DashedBorder shader, but Solid doesn't expose it yet. This PR wires it in the same way as the other default shaders:

  • defaultShaderDashedBorder and registerDefaultShaderDashedBorder. registerDefaultShaders registers it as 'dashedBorder'.
  • A dashedBorder prop, using the raw shader accessor like linearGradient/radialGradient. It's typed in Effects and in the DOM renderer's shader props.
  • A DOM renderer fallback that honours the same props (dash, gap, width, color, radius).
<view
  width={300}
  height={170}
  dashedBorder={{ radius: 16, width: 2, color: 0xffffff33, dash: 10, gap: 10 }}
/>

DOM renderer

CSS border-style: dashed lets the browser pick the dash and gap lengths, so it looks nothing like the shader. Instead, dashedBorderStyle() builds CSS gradients and puts them in the node's existing divBorder layer. That layer sits above the fill and below the children, so the node keeps its size and its children don't move.

  • Straight sides: one repeating-linear-gradient strip per side, width thick. Dash and gap are stretched so a whole number of them fits.
  • Corners, when there's a radius: a quarter ring per corner (radial-gradient), drawn as one dash. The straight part between two corners runs gap, dash, …, dash, gap.
  • No radius: each side starts and ends with a dash.
  • Gap and dash at 0: gap <= 0 draws a solid border, and dash <= 0 draws nothing, same as the shader.
  • Older WebKit: each gradient is written twice, with the -webkit- syntax first.

Known difference from WebGL: a rounded corner is always one solid dash, while the shader keeps dashing around the curve. With a large radius, the corner dash is longer than dash.

Renderer peer range

The peer range moves from ^2.0.7 to ^2.0.9, because DashedBorder first ships in 2.0.9. The lockfile is pinned to 2.0.9 on purpose. 2.0.10 and later add a required truncated field to NodeTextLoadedPayload, which breaks tsc in domRenderer.ts (the text loaded payload). That break is unrelated to this change and would need its own fix.

Tests

  • New tests/dashedBorder.test.tsx with 9 tests: the shader type and props, the DOM layer, restyle on update, and the gradient geometry with and without a radius.
  • tests/publicApi.test.ts and tests/contract-types.tsx are updated for the new exports.
  • pnpm test passes (789), as do pnpm run tsc and pnpm run lint:prettier.

🤖 Generated with Claude Code

…er fallback

@solidtv/renderer 2.0.9 ships a built-in DashedBorder shader. Wire it into
Solid like the other default shaders:

- defaultShaderDashedBorder / registerDefaultShaderDashedBorder, registered
  by registerDefaultShaders as 'dashedBorder'
- a `dashedBorder` prop (raw shader accessor), typed in Effects and the DOM
  renderer's shader props
- DOM renderer: CSS gradients in the node's border layer, so dash, gap,
  width, color and radius come from the props there too: a dashed strip per
  straight side and, with a radius, a quarter ring per corner (drawn as one
  dash). -webkit- syntax first for older WebKit.

The renderer peer range moves to ^2.0.9, the first version with DashedBorder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants