Skip to content
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

Update sub-component spread prop type #86

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-rings-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'layerchart': patch
---

Update sub-component props type that are spread (`ComponentProps<SomeComponent>`) to be more accurate (`Partial<...>`)
2 changes: 1 addition & 1 deletion packages/layerchart/src/lib/components/Area.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
export let defined: Parameters<Area<any>['defined']>[0] | undefined = undefined;

/** Enable showing line */
export let line: boolean | ComponentProps<Spline> = false;
export let line: boolean | Partial<ComponentProps<Spline>> = false;

$: tweenedOptions = tweened ? { interpolate: interpolatePath, ...tweened } : false;
$: tweened_d = motionStore('', { tweened: tweenedOptions });
Expand Down
2 changes: 1 addition & 1 deletion packages/layerchart/src/lib/components/Axis.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
/** Length of the tick line */
export let tickSize = 4;
export let format: FormatType = undefined;
export let labelProps: ComponentProps<Text> | undefined = undefined;
export let labelProps: Partial<ComponentProps<Text>> | undefined = undefined;

$: orientation = ['top', 'bottom'].includes(placement) ? 'horizontal' : 'vertical';
$: scale = orientation === 'horizontal' ? $xScale : $yScale;
Expand Down
2 changes: 1 addition & 1 deletion packages/layerchart/src/lib/components/Calendar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
export let cellSize: number | [number, number] | undefined = undefined;

/** Enable drawing path around each month. If object, pass as props to underlying <path> */
export let monthPath: boolean | ComponentProps<MonthPath> = false;
export let monthPath: boolean | Partial<ComponentProps<MonthPath>> = false;

/**
* Tooltip context to setup mouse events to show tooltip for related data
Expand Down
4 changes: 2 additions & 2 deletions packages/layerchart/src/lib/components/Chart.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
*/
$: yReverse = yScale ? !isScaleBand(yScale) : true;

export let tooltip: ComponentProps<TooltipContext> | boolean | undefined = undefined;
export let tooltip: Partial<ComponentProps<TooltipContext>> | boolean | undefined = undefined;

export let geo: ComponentProps<GeoContext> | undefined = undefined;
export let geo: Partial<ComponentProps<GeoContext>> | undefined = undefined;
</script>

<LayerCake
Expand Down
8 changes: 4 additions & 4 deletions packages/layerchart/src/lib/components/Graticule.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import GeoPath from './GeoPath.svelte';

// TODO: Support full api (stepMinor/Major, extent[Minor/Major], etc
export let lines: Omit<ComponentProps<GeoPath>, 'geojson'> | boolean | undefined = undefined;
export let outline: Omit<ComponentProps<GeoPath>, 'geojson'> | boolean | undefined = undefined;
export let lines: Partial<ComponentProps<GeoPath>> | boolean | undefined = undefined;
export let outline: Partial<ComponentProps<GeoPath>> | boolean | undefined = undefined;
export let step: [number, number] = [10, 10];

$: graticule = geoGraticule();
Expand All @@ -22,11 +22,11 @@

{#if lines}
{#each graticule.lines() as line}
<GeoPath geojson={line} {...lines} />
<GeoPath geojson={line} {...typeof lines === 'object' ? lines : null} />
{/each}
{/if}

{#if outline}
<GeoPath geojson={graticule.outline()} {...outline} />
<GeoPath geojson={graticule.outline()} {...typeof outline === 'object' ? outline : null} />
{/if}
</g>
12 changes: 6 additions & 6 deletions packages/layerchart/src/lib/components/Highlight.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
export let axis: 'x' | 'y' | 'both' | 'none' | undefined = undefined;

/** Show points and pass props to Circles */
export let points: boolean | ComponentProps<Circle> = false;
export let points: boolean | Partial<ComponentProps<Circle>> = false;

/** Show lines and pass props to Lines */
export let lines: boolean | ComponentProps<Line> = false;
export let lines: boolean | Partial<ComponentProps<Line>> = false;

/** Show area and pass props to Rect */
export let area: boolean | ComponentProps<Rect> = false;
export let area: boolean | Partial<ComponentProps<Rect>> = false;

/** Show bar and pass props to Rect */
export let bar: boolean | ComponentProps<Rect> = false;
export let bar: boolean | Partial<ComponentProps<Rect>> = false;

// TODO: Fix circle points being backwards for stack (see AreaStack)

let _points = [];
let _lines = [];
let _points: { x: number; y: number }[] = [];
let _lines: { x1: number; y1: number; x2: number; y2: number }[] = [];
let _area = {
x: 0,
y: 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/layerchart/src/lib/components/Points.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
export let offsetY: Offset = undefined;

/** Enable showing links between related points (array x/y accessors) */
export let links: boolean | ComponentProps<Link> = false;
export let links: boolean | Partial<ComponentProps<Link>> = false;

function getOffset(value, offset: Offset, scale: any) {
if (typeof offset === 'function') {
Expand Down