From e867e216d8e80622755634ad7cb27f13ab49d1c3 Mon Sep 17 00:00:00 2001 From: Scott Rhamy Date: Sat, 9 May 2026 09:55:32 -0400 Subject: [PATCH] Auto-notes - example code is a tough mix of recommended best practices and having to support how layers support things differently. Examples (class: fill-primary/50 vs fill: var(--color-primary) fillOpacity={.5} or even worse, using color-mix(...)). - AutoNotes.svelte has been added to Example.svelte - It checks auto-notes.ts dictionary and filters based on regex search of source and/or displayed layer to display conditional notifications below example. - AutoNotes uses upgraded Blockquote.svelte supporting 'basic', 'note', 'tip', 'warning', 'caution' mirroring markdown equivilents. - no included auto-notes currently, but you uncomment auto-notes.ts and check `Chart` to see. --- docs/src/lib/auto-notes.ts | 20 ++++++++ docs/src/lib/components/AutoNotes.svelte | 33 +++++++++++++ docs/src/lib/components/Blockquote.svelte | 58 +++++++++++++++++++++-- docs/src/lib/components/Example.svelte | 2 + 4 files changed, 108 insertions(+), 5 deletions(-) create mode 100644 docs/src/lib/auto-notes.ts create mode 100644 docs/src/lib/components/AutoNotes.svelte diff --git a/docs/src/lib/auto-notes.ts b/docs/src/lib/auto-notes.ts new file mode 100644 index 000000000..4a539a79a --- /dev/null +++ b/docs/src/lib/auto-notes.ts @@ -0,0 +1,20 @@ +export type Note = { + text: string; /* the text of the note */ + search?: string | RegExp; /* default '' - diplays for any source */ + layers?: ('svg' | 'canvas' | 'html')[]; /* default [] = shows for all layers */ + type?: 'basic' | 'note' | 'tip' | 'warning' | 'caution'; /* default 'warning' */ +}; + +export const autoNotes: Note[] = [ + // { + // text: 'your source include the word "createDateSeries" and your layer is "canvas"', + // search: '/createDateSeries/', + // layers: ['canvas'], + // type: 'caution' + // }, + // { + // text: 'your source include the word "integer" and your layer is "canvas"', + // search: '/integer/', + // layers: ['canvas'] + // } +]; diff --git a/docs/src/lib/components/AutoNotes.svelte b/docs/src/lib/components/AutoNotes.svelte new file mode 100644 index 000000000..5b5a9ffbf --- /dev/null +++ b/docs/src/lib/components/AutoNotes.svelte @@ -0,0 +1,33 @@ + + +{#each notes as { text, type }, i (i)} +
+
+

{text}

+
+
+{/each} diff --git a/docs/src/lib/components/Blockquote.svelte b/docs/src/lib/components/Blockquote.svelte index 76852e623..e089b082e 100644 --- a/docs/src/lib/components/Blockquote.svelte +++ b/docs/src/lib/components/Blockquote.svelte @@ -1,17 +1,65 @@
a]:font-medium [&>a]:underline [&>a]:decoration-dashed [&>a]:decoration-primary/50 [&>a]:underline-offset-2' + 'border border-l-[6px] px-4 py-2 my-4 rounded-sm flex items-center gap-2 text-sm', + '[&>a]:font-medium [&>a]:underline [&>a]:decoration-dashed [&>a]:underline-offset-2', + classes.container )} > - + {#if type === 'note'} + {:else if type === 'tip'} + {:else if type === 'warning'} + {:else if type === 'caution'} + {:else} + {/if} {@render children()}
diff --git a/docs/src/lib/components/Example.svelte b/docs/src/lib/components/Example.svelte index 62ae649af..faf5e07bf 100644 --- a/docs/src/lib/components/Example.svelte +++ b/docs/src/lib/components/Example.svelte @@ -38,6 +38,7 @@ getChartSvgString, getSettings } from 'layerchart'; + import AutoNotes from './AutoNotes.svelte'; const settings = getSettings(); import { movable } from '$lib/actions/movable'; @@ -439,6 +440,7 @@ /> {/if} + (pngDialogOpen = false)} class="max-w-md">
{pngAction === 'copy' ? 'Copy as PNG' : 'Export as PNG'}