Skip to content

Add Layer component to easily switch between Svg, Canvas, and Html layers #480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
techniq opened this issue Apr 30, 2025 · 1 comment
Closed

Comments

@techniq
Copy link
Owner

techniq commented Apr 30, 2025

Instead of requiring imports for each render context layer...

<script>
  import { Canvas, Html, Svg } from 'layerchart';
</script>

<Canvas>...</Canvas>
<Html>...</Html>
<Svg>...</Svg>

it would be nice if a single component could be imported with a type prop to declare the type of component to use

<script>
  import { Layer } from 'layerchart';
</script>

<Layer type="canvas">...</Layer>
<Layer type="html">...</Layer>
<Layer type="svg">...</Layer>

The default type could probably be svg as well.

This is especially helpful for the docs where we allow switching between contexts and currently must do something like this....

{@const Component = renderContext === 'canvas' ? Canvas : Svg}

<Component
  this={renderContext === 'canvas' ? Canvas : Svg}
  {...asAny(renderContext === 'canvas' ? props.canvas : props.svg)}
  ...
>
@techniq techniq mentioned this issue May 1, 2025
30 tasks
@techniq
Copy link
Owner Author

techniq commented May 5, 2025

Completed as part of [email protected]

@techniq techniq closed this as completed May 5, 2025
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

No branches or pull requests

1 participant