CopyPasteComposer
Build copy-ready file, dependency, and usage bundles from catalogue metadata.
Live demo
01Catalogue handoff
Copy-paste composer
Choose a component and build the exact source, docs, demo, dependency, and usage bundle to hand to another repo.
Selected files
3- source
src/lib/components/Sidebar.svelterequired - docs
src/lib/components/Sidebar.md - demo
src/routes/sidebar/+page.svelte
Command block
5mkdir -p ./src/lib/components
mkdir -p ./src/routes/sidebar
cp src/lib/components/Sidebar.svelte ./src/lib/components/Sidebar.svelte
cp src/lib/components/Sidebar.md ./src/lib/components/Sidebar.md
cp src/routes/sidebar/+page.svelte ./src/routes/sidebar/+page.svelteChecklist
- Confirm the target app is already on Svelte 5.
- Copy 3 selected files into matching project paths.
- Paste the usage snippet into the target route.
- Review the docs for props, accessibility notes, and edge cases.
- Open the demo route and remove sample-only data before shipping.
- Run or port the selected tests after adapting imports.
Usage
<script lang="ts">
import Sidebar from '$lib/components/Sidebar.svelte';
const items = [
{ label: 'Dashboard', href: '/dashboard', icon: 'β€' },
{ label: 'Reports', href: '/reports', icon: 'π', children: [
{ label: 'Sales', href: '/reports/sales', icon: 'β’' }
] }
];
</script>
<Sidebar {items} activeHref="/dashboard" title="Acme" />Implementation
02<script lang="ts">
import CopyPasteComposer from '$lib/components/CopyPasteComposer.svelte';
</script>
β
<CopyPasteComposer {entries} />CopyPasteComposer keeps catalogue transformation logic in module exports, then renders the same derived file list, command block, usage snippet, and checklist in the interactive view.
Logic explainer
03Purpose
CopyPasteComposer turns the component catalogue into a practical handoff surface. A visitor chooses one catalogue entry, toggles the supporting artefacts they want, and receives the files, dependency command, copy commands, usage snippet, and final checklist in one place.
Data Model
The component consumes catalogue-shaped entries with source, docs, demo, dependencies, relatedFiles, and usage. It does not read the filesystem directly; routes pass the catalogue rows in, which keeps the component testable and usable in static contexts.
Helper Exports
deriveSelectedFiles(entry, options)returns the ordered source/docs/demo/test/related file list for the current toggles.deriveInstallCommands(entry, options)returns dependency, directory, and copy commands for the selected file list.testCandidatesFor(entry)derives colocated.test.ts,.test.svelte, andTestHarness.test.sveltecandidates from Svelte source paths.checklistFor(entry, options)turns the selected bundle into implementation review steps.
Behaviour Notes
The source component is always included because the bundle is meaningless without it. Docs, demo route, tests, and related files are optional so the receiving project can choose a minimal install or a fuller migration pack.
Test files listed in relatedFiles are treated as tests when the Tests toggle is enabled. Non-test relatedFiles stay behind the Related files toggle, which prevents helper utilities from being silently bundled unless the user asks for them.
API
04| Export | Type | Description |
|---|---|---|
deriveSelectedFiles | (entry, options) => CopyPasteSelectedFile[] | Builds the ordered source/docs/demo/tests/related file bundle. |
deriveInstallCommands | (entry, options) => string[] | Builds dependency, directory, and copy commands for the selected bundle. |
CopyPasteComposer | Svelte component | Renders selector controls, command block, selected files, checklist, and usage. |