mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
docs: omit Prettier from client JS
This commit is contained in:
parent
7bd4c3ee41
commit
12b3485d9b
5 changed files with 4019 additions and 918 deletions
9
docs/package-lock.json
generated
9
docs/package-lock.json
generated
|
@ -33,9 +33,15 @@
|
||||||
"flatpickr": "4.6.9"
|
"flatpickr": "4.6.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
||||||
|
"@testing-library/jest-dom": "^6.6.3",
|
||||||
|
"@testing-library/svelte": "^5.2.6",
|
||||||
|
"@testing-library/user-event": "^14.5.2",
|
||||||
"autoprefixer": "^10.4.8",
|
"autoprefixer": "^10.4.8",
|
||||||
"carbon-components": "10.58.12",
|
"carbon-components": "10.58.12",
|
||||||
"carbon-icons-svelte": "^12.1.0",
|
"carbon-icons-svelte": "^12.1.0",
|
||||||
|
"carbon-preprocess-svelte": "^0.11.7",
|
||||||
|
"jsdom": "^25.0.1",
|
||||||
"postcss": "^8.4.16",
|
"postcss": "^8.4.16",
|
||||||
"prettier": "^3.3.3",
|
"prettier": "^3.3.3",
|
||||||
"prettier-plugin-svelte": "^3.2.8",
|
"prettier-plugin-svelte": "^3.2.8",
|
||||||
|
@ -45,7 +51,8 @@
|
||||||
"svelte": "^4.2.10",
|
"svelte": "^4.2.10",
|
||||||
"svelte-check": "^4.0.6",
|
"svelte-check": "^4.0.6",
|
||||||
"tinyglobby": "^0.2.10",
|
"tinyglobby": "^0.2.10",
|
||||||
"typescript": "^5.6.3"
|
"typescript": "^5.6.3",
|
||||||
|
"vitest": "^2.1.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@ampproject/remapping": {
|
"node_modules/@ampproject/remapping": {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -127,7 +127,6 @@
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={AsyncPreviewTypeScript}
|
this={AsyncPreviewTypeScript}
|
||||||
type="inline"
|
type="inline"
|
||||||
noFormat
|
|
||||||
code={typeMap[type]}
|
code={typeMap[type]}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -138,7 +137,6 @@
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={AsyncPreviewTypeScript}
|
this={AsyncPreviewTypeScript}
|
||||||
type="inline"
|
type="inline"
|
||||||
noFormat
|
|
||||||
code={type}
|
code={type}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -152,7 +150,6 @@
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={AsyncPreviewTypeScript}
|
this={AsyncPreviewTypeScript}
|
||||||
type="inline"
|
type="inline"
|
||||||
noFormat
|
|
||||||
code={type}
|
code={type}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -179,8 +176,7 @@
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={AsyncPreviewTypeScript}
|
this={AsyncPreviewTypeScript}
|
||||||
type="inline"
|
type="inline"
|
||||||
noFormat
|
code={prop.value}
|
||||||
code={prop.value.replace(/\s+/g, " ")}
|
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{:else if prop.value === undefined}
|
{:else if prop.value === undefined}
|
||||||
|
@ -189,7 +185,6 @@
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={AsyncPreviewTypeScript}
|
this={AsyncPreviewTypeScript}
|
||||||
type="inline"
|
type="inline"
|
||||||
noFormat
|
|
||||||
code={prop.value}
|
code={prop.value}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -220,21 +215,41 @@
|
||||||
<h2 id="typedefs">Typedefs</h2>
|
<h2 id="typedefs">Typedefs</h2>
|
||||||
|
|
||||||
{#if component.typedefs.length > 0}
|
{#if component.typedefs.length > 0}
|
||||||
|
<div class="my-layout-01-03">
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={AsyncPreviewTypeScript}
|
this={AsyncPreviewTypeScript}
|
||||||
code={component.typedefs.map((t) => t.ts).join(";\n\n")}
|
code={component.typedefs.map((t) => t.ts).join("\n")}
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<p class="my-layout-01-03">No typedefs.</p>
|
<p class="my-layout-01-03">No typedefs.</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<h2 id="slots">Slots</h2>
|
<h2 id="slots">Slots</h2>
|
||||||
{#if component.slots.length > 0}
|
{#if component.slots.length > 0}
|
||||||
<UnorderedList class="my-layout-01-03">
|
<StructuredList class="my-layout-01-03">
|
||||||
|
<StructuredListHead>
|
||||||
|
<StructuredListRow>
|
||||||
|
<StructuredListCell>Slot name</StructuredListCell>
|
||||||
|
<StructuredListCell>Slot detail</StructuredListCell>
|
||||||
|
</StructuredListRow>
|
||||||
|
</StructuredListHead>
|
||||||
|
<StructuredListBody>
|
||||||
{#each component.slots as slot (slot.name)}
|
{#each component.slots as slot (slot.name)}
|
||||||
<ListItem>{slot.default ? "default" : slot.name}</ListItem>
|
<StructuredListRow>
|
||||||
|
<StructuredListCell>
|
||||||
|
<strong>{slot.default ? "default" : slot.name}</strong>
|
||||||
|
</StructuredListCell>
|
||||||
|
<StructuredListCell>
|
||||||
|
<svelte:component
|
||||||
|
this={AsyncPreviewTypeScript}
|
||||||
|
code={slot.slot_props}
|
||||||
|
/>
|
||||||
|
</StructuredListCell>
|
||||||
|
</StructuredListRow>
|
||||||
{/each}
|
{/each}
|
||||||
</UnorderedList>
|
</StructuredListBody>
|
||||||
|
</StructuredList>
|
||||||
{:else}
|
{:else}
|
||||||
<p class="my-layout-01-03">No slots.</p>
|
<p class="my-layout-01-03">No slots.</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -273,7 +288,7 @@
|
||||||
<StructuredListCell>
|
<StructuredListCell>
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={AsyncPreviewTypeScript}
|
this={AsyncPreviewTypeScript}
|
||||||
code={"type EventDetail = " + event.detail}
|
code={event.detail}
|
||||||
/>
|
/>
|
||||||
</StructuredListCell>
|
</StructuredListCell>
|
||||||
<StructuredListCell>
|
<StructuredListCell>
|
||||||
|
@ -317,12 +332,7 @@
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if full_code}
|
{#if full_code}
|
||||||
<svelte:component
|
<svelte:component this={AsyncPreviewTypeScript} code={full_code} />
|
||||||
this={AsyncPreviewTypeScript}
|
|
||||||
code={full_code.startsWith("()")
|
|
||||||
? `const ${full_code_prop} = ` + full_code
|
|
||||||
: full_code}
|
|
||||||
/>
|
|
||||||
{/if}
|
{/if}
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
{/if}
|
{/if}
|
||||||
<div class="preview-viewer" class:framed>
|
<div class="preview-viewer" class:framed>
|
||||||
{#if framed}
|
{#if framed}
|
||||||
<iframe loading="lazy" title={src.split("/").pop()} src={themedSrcUrl}></iframe>
|
<iframe loading="lazy" title={src.split("/").pop()} src={themedSrcUrl}
|
||||||
|
></iframe>
|
||||||
{:else}
|
{:else}
|
||||||
<slot />
|
<slot />
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -1,30 +1,14 @@
|
||||||
<script>
|
<script>
|
||||||
export let code = "";
|
export let code = "";
|
||||||
export let noFormat = false;
|
|
||||||
export let type = "multi";
|
export let type = "multi";
|
||||||
|
|
||||||
import { CodeSnippet } from "carbon-components-svelte";
|
import { CodeSnippet } from "carbon-components-svelte";
|
||||||
import { format } from "prettier/standalone";
|
|
||||||
import { highlight } from "prismjs";
|
import { highlight } from "prismjs";
|
||||||
import "prismjs/components/prism-typescript";
|
import "prismjs/components/prism-typescript";
|
||||||
import plugin from "prettier/parser-typescript";
|
|
||||||
import copy from "clipboard-copy";
|
import copy from "clipboard-copy";
|
||||||
|
|
||||||
let formattedCode = "";
|
|
||||||
let highlightedCode = "";
|
|
||||||
|
|
||||||
$: {
|
|
||||||
try {
|
|
||||||
formattedCode = noFormat
|
|
||||||
? code
|
|
||||||
: format(code, { parser: "typescript", plugins: [plugin] });
|
|
||||||
} catch (e) {
|
|
||||||
formattedCode = code;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$: highlightedCode = highlight(
|
$: highlightedCode = highlight(
|
||||||
formattedCode,
|
code,
|
||||||
Prism.languages.typescript,
|
Prism.languages.typescript,
|
||||||
"typescript",
|
"typescript",
|
||||||
);
|
);
|
||||||
|
@ -32,19 +16,14 @@
|
||||||
|
|
||||||
{#if type === "multi"}
|
{#if type === "multi"}
|
||||||
<div class="code-override">
|
<div class="code-override">
|
||||||
<CodeSnippet type="multi" code={formattedCode} {copy}>
|
<CodeSnippet type="multi" {code} {copy}>
|
||||||
{@html highlightedCode}
|
{@html highlightedCode}
|
||||||
</CodeSnippet>
|
</CodeSnippet>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if type === "inline"}
|
{#if type === "inline"}
|
||||||
<CodeSnippet
|
<CodeSnippet type="inline" class="code-override-inline" {code} {copy}>
|
||||||
type="inline"
|
|
||||||
class="code-override-inline"
|
|
||||||
code={formattedCode}
|
|
||||||
{copy}
|
|
||||||
>
|
|
||||||
{@html highlightedCode}
|
{@html highlightedCode}
|
||||||
</CodeSnippet>
|
</CodeSnippet>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue