diff --git a/.changeset/plain-rings-itch.md b/.changeset/plain-rings-itch.md new file mode 100644 index 000000000..df28d97fd --- /dev/null +++ b/.changeset/plain-rings-itch.md @@ -0,0 +1,5 @@ +--- +'layerchart': patch +--- + +feat: Add Month component diff --git a/packages/layerchart/src/lib/components/Month.svelte b/packages/layerchart/src/lib/components/Month.svelte new file mode 100644 index 000000000..ea5e40141 --- /dev/null +++ b/packages/layerchart/src/lib/components/Month.svelte @@ -0,0 +1,274 @@ + + + + + + + {#if children} + {@render children({ cells: allCells.cells, cellSize })} + {:else} + {#each allCells.cells as cell} + tooltip?.show(e, cell.data)} + onpointerleave={(e) => tooltip?.hide()} + {...extractLayerProps(restProps, 'lc-month-cell')} + /> + + {#if showDayNumber} + + {/if} + {/each} + {/if} + + + {#if monthLabel} + {#each monthLabels as label} + + {/each} + {/if} + + + diff --git a/packages/layerchart/src/lib/components/index.ts b/packages/layerchart/src/lib/components/index.ts index 48e14a6fd..29618840c 100644 --- a/packages/layerchart/src/lib/components/index.ts +++ b/packages/layerchart/src/lib/components/index.ts @@ -93,6 +93,8 @@ export { default as Link } from './Link.svelte'; export * from './Link.svelte'; export { default as MotionPath } from './MotionPath.svelte'; export * from './MotionPath.svelte'; +export { default as Month } from './Month.svelte'; +export * from './Month.svelte'; export { default as Pack } from './Pack.svelte'; export * from './Pack.svelte'; export { default as Partition } from './Partition.svelte'; diff --git a/packages/layerchart/src/routes/_NavMenu.svelte b/packages/layerchart/src/routes/_NavMenu.svelte index 5faa8e2ac..a2159e980 100644 --- a/packages/layerchart/src/routes/_NavMenu.svelte +++ b/packages/layerchart/src/routes/_NavMenu.svelte @@ -91,6 +91,7 @@ 'Hull', 'Labels', 'Link', + 'Month', 'Pie', 'Points', 'Spline', diff --git a/packages/layerchart/src/routes/docs/components/Month/+page.svelte b/packages/layerchart/src/routes/docs/components/Month/+page.svelte new file mode 100644 index 000000000..35c43c42b --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/Month/+page.svelte @@ -0,0 +1,272 @@ + + +

Examples

+ +

Current year

+ + +
+ + {#snippet children({ context })} + + + + + + {#snippet children({ data })} + + + {#if data.value != null} + + + + {/if} + {/snippet} + + {/snippet} + +
+
+ +

Last 90 days

+ + +
+ + {#snippet children({ context })} + + + + + + {#snippet children({ data })} + + + {#if data.value != null} + + + + {/if} + {/snippet} + + {/snippet} + +
+
+ +

Multiple years

+ + +
+ + {#snippet children({ context })} + + + + + + {#snippet children({ data })} + + + {#if data.value != null} + + + + {/if} + {/snippet} + + {/snippet} + +
+
+ +

Custom cell size

+ + +
+ + {#snippet children({ context })} + + + + + + {#snippet children({ data })} + + + {#if data.value != null} + + + + {/if} + {/snippet} + + {/snippet} + +
+
+ +

Without day numbers

+ + +
+ + {#snippet children({ context })} + + + + + + {#snippet children({ data })} + + + {#if data.value != null} + + + + {/if} + {/snippet} + + {/snippet} + +
+
+ +

Without month labels

+ + +
+ + {#snippet children({ context })} + + + + + + {#snippet children({ data })} + + + {#if data.value != null} + + + + {/if} + {/snippet} + + {/snippet} + +
+
diff --git a/packages/layerchart/src/routes/docs/components/Month/+page.ts b/packages/layerchart/src/routes/docs/components/Month/+page.ts new file mode 100644 index 000000000..e90988ada --- /dev/null +++ b/packages/layerchart/src/routes/docs/components/Month/+page.ts @@ -0,0 +1,14 @@ +import api from '$lib/components/Month.svelte?raw&sveld'; +import source from '$lib/components/Month.svelte?raw'; +import pageSource from './+page.svelte?raw'; + +export async function load() { + return { + meta: { + api, + source, + pageSource, + supportedContexts: ['svg', 'canvas', 'html'], + }, + }; +}