-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Svelte and add snippetFormatter utility; enhance Slider compon…
…ent with label formatting
- Loading branch information
1 parent
1e105ce
commit 225b564
Showing
17 changed files
with
302 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import type { Snippet } from 'svelte'; | ||
|
||
type Convert<A extends unknown[]> = { | ||
[K in keyof A]: A[K] extends A[K] ? (() => A[K]) | undefined : never; | ||
}; | ||
|
||
// type FillArgs<A extends unknown[], B extends unknown[]> = { | ||
// [K in keyof A]: A[K] extends undefined ? B[K] : A[K]; | ||
// }; | ||
|
||
export function snippetFormatter<Args extends unknown[] = []>( | ||
snippet: Snippet<Args>, | ||
args: Convert<Args> | ||
) { | ||
function fillArgs(arg1: Args[], arg2: Args[]): Args[] { | ||
for (let index = 0; index < arg1.length; index++) { | ||
if (arg1[index] === undefined) { | ||
arg1[index] = arg2.shift(); | ||
} | ||
} | ||
if (arg2.length > 0) { | ||
arg1.push(...arg2); | ||
} | ||
return arg1; | ||
} | ||
|
||
if (snippet.length - 1 === args.length) { | ||
return function ($$anchor: any) { | ||
return snippet($$anchor, ...args); | ||
}; | ||
} | ||
|
||
return function ($$anchor: any, ...arg: Partial<Args>) { | ||
const fullArguments = fillArgs(args, arg); | ||
return snippet($$anchor, ...fullArguments); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 11 additions & 2 deletions
13
src/routes/applet/linear_combinations/span_one/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 11 additions & 4 deletions
15
src/routes/applet/lines_and_planes/parametric_line_space/+page.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.