Skip to content

Commit 9095cb9

Browse files
committed
feat(Hull): Add CommonStyleProps (fill, fillOpacity, stroke, strokeOpacity, strokeWidth, opacity) for Canvas layer compatibility
1 parent 0bc8bda commit 9095cb9

3 files changed

Lines changed: 29 additions & 7 deletions

File tree

.changeset/hull-style-props.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'layerchart': minor
3+
---
4+
5+
feat(Hull): Add CommonStyleProps (fill, fillOpacity, stroke, strokeOpacity, strokeWidth, opacity) for Canvas layer compatibility

docs/src/examples/components/Hull/scatter.svelte

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,13 @@
3838
{#each dataByGroup as [group, data]}
3939
{@const color = groupColor(group)}
4040
<Points r={3} {data} fill={color} />
41-
<!-- TODO: handle group color differently to work with Canvas -->
4241
<Hull
4342
{data}
4443
{curve}
45-
style="--group-color:{color}"
46-
classes={{
47-
path: 'pointer-events-none stroke-[var(--group-color)] fill-[var(--group-color)] [fill-opacity:0.1]'
48-
}}
44+
stroke={color}
45+
fill={color}
46+
fillOpacity={0.1}
47+
class="pointer-events-none"
4948
/>
5049
{/each}
5150
</Layer>

packages/layerchart/src/lib/components/Hull.svelte

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts" module>
2-
import type { Without } from '$lib/utils/types.js';
2+
import type { Without, CommonStyleProps } from '$lib/utils/types.js';
33
import type { SVGAttributes } from 'svelte/elements';
44
import type { ComponentProps } from 'svelte';
55
@@ -47,7 +47,7 @@
4747
* @bindable
4848
*/
4949
ref?: SVGGElement;
50-
};
50+
} & CommonStyleProps;
5151
5252
export type HullProps = HullPropsWithoutHTML & Without<GroupProps, HullPropsWithoutHTML>;
5353
</script>
@@ -79,6 +79,12 @@
7979
onpointermove,
8080
onclick,
8181
onpointerleave,
82+
fill,
83+
fillOpacity,
84+
stroke,
85+
strokeOpacity,
86+
strokeWidth,
87+
opacity,
8288
class: className,
8389
ref: refProp = $bindable(),
8490
...restProps
@@ -112,6 +118,12 @@
112118
<GeoPath
113119
geojson={polygon}
114120
{curve}
121+
{fill}
122+
{fillOpacity}
123+
{stroke}
124+
{strokeOpacity}
125+
{strokeWidth}
126+
{opacity}
115127
class={['lc-hull-path', classes.path]}
116128
onclick={(e) => onclick?.(e, { points, polygon })}
117129
onpointermove={(e) => onpointermove?.(e, { points, polygon })}
@@ -125,6 +137,12 @@
125137
x={(d) => d[0]}
126138
y={(d) => d[1]}
127139
{curve}
140+
{fill}
141+
{fillOpacity}
142+
{stroke}
143+
{strokeOpacity}
144+
{strokeWidth}
145+
{opacity}
128146
class={['lc-hull-class', classes.path]}
129147
onclick={(e) => onclick?.(e, { points, polygon })}
130148
onpointermove={(e) => onpointermove?.(e, { points, polygon })}

0 commit comments

Comments
 (0)