Skip to content

Commit 72cc219

Browse files
committed
docs: fix: banner page
1 parent 8570105 commit 72cc219

File tree

3 files changed

+17
-39
lines changed

3 files changed

+17
-39
lines changed

src/lib/accordion/AccordionItem.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</script>
3232

3333
<h2 class={base()}>
34-
<div onclick={handleToggle} onkeydown={(e) => e.key === 'Enter' && handleToggle()} role="button" tabindex="0" class={buttonClass} aria-expanded={open}>
34+
<button onclick={handleToggle} class={buttonClass} aria-expanded={open}>
3535
{#if header}
3636
{@render header()}
3737
{#if open}
@@ -50,7 +50,7 @@
5050
{@render arrowdown()}
5151
{/if}
5252
{/if}
53-
</div>
53+
</button>
5454
</h2>
5555
{#if open}
5656
<div transition:transition={params as ParamsType}>

src/routes/components/accordion/examples/Icon.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<script lang="ts">
22
import { Accordion, AccordionItem } from "$lib";
3-
import { CartFlowbite, CogFlowbite } from "svelte-animated-icons";
3+
import { CartSolid, CogSolid } from "flowbite-svelte-icons";
44
</script>
55

66
<Accordion>
77
<AccordionItem>
88
{#snippet header()}
99
<span class="flex gap-2 text-base">
10-
<CartFlowbite />
10+
<CartSolid />
1111
<span>My Header 1</span>
1212
</span>
1313
{/snippet}
@@ -16,7 +16,7 @@
1616
<AccordionItem>
1717
{#snippet header()}
1818
<span class="flex gap-2 text-base">
19-
<CogFlowbite />
19+
<CogSolid />
2020
<span>My Header 2</span>
2121
</span>
2222
{/snippet}

src/routes/components/banner/+page.svelte

Lines changed: 12 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script lang="ts">
2-
import { type Component } from "svelte";
32
import { Banner, banner, Button, Skeleton, ImagePlaceholder, Label, Radio, type BannerProps, uiHelpers } from "$lib";
43
import { BullhornOutline } from "flowbite-svelte-icons";
54
import { blur, fly, slide, scale } from "svelte/transition";
@@ -10,7 +9,7 @@
109
import CodeWrapper from "../../utils/CodeWrapper.svelte";
1110
import H1 from "../../utils/H1.svelte";
1211
import H2 from "../../utils/H2.svelte";
13-
import { isGeneratedCodeOverflow, isSvelteOverflow, getExampleFileName } from "../../utils/helpers";
12+
import { isGeneratedCodeOverflow } from "../../utils/helpers";
1413
// for Props table
1514
import CompoAttributesViewer from "../../utils/CompoAttributesViewer.svelte";
1615
const dirName = "banner";
@@ -23,20 +22,6 @@
2322
eager: true
2423
}) as Record<string, string>;
2524
26-
const exampleArr = [
27-
{ name: "Newsletter signup banner", component: ExampleComponents.NewsletterSignupBanner },
28-
{ name: "Information banner", component: ExampleComponents.InformationBanner }
29-
];
30-
let selectedExample: string | number = $state(exampleArr[0].name);
31-
let svelteCode = $derived(getExampleFileName(selectedExample, exampleArr));
32-
33-
function findObject(arr: { name: string; component: Component }[], name: string) {
34-
const matchingObject = arr.find((obj) => obj.name === name);
35-
return matchingObject ? matchingObject.component : null;
36-
}
37-
const SelectedComponent = $derived(findObject(exampleArr, selectedExample));
38-
// end of dynamic svelte component
39-
4025
// interactive example
4126
// position, bannerType, color, class:divClass
4227
const colors = Object.keys(banner.variants.color);
@@ -125,16 +110,8 @@
125110
};
126111
// for DynamicCodeBlock setup for examples section. dynamically adjust the height of the code block based on the svelteCode content.
127112
128-
// for examples DynamicCodeBlockHighlight
129-
let codeBlock = uiHelpers();
130-
let exampleExpand = $state(false);
131-
let showExpandButton = $derived(isSvelteOverflow(svelteCode, exampleModules));
132-
const handleExpandClick = () => {
133-
exampleExpand = !exampleExpand;
134-
};
135113
// end of DynamicCodeBlock setup
136114
$effect(() => {
137-
exampleExpand = codeBlock.isOpen;
138115
builderExpand = builder.isOpen;
139116
});
140117
</script>
@@ -190,18 +167,19 @@
190167
{/snippet}
191168
</CodeWrapper>
192169

193-
<H2>Examples</H2>
170+
<H2>Newletter signup banner</H2>
171+
<CodeWrapper>
172+
<ExampleComponents.NewsletterSignupBanner />
173+
{#snippet codeblock()}
174+
<HighlightCompo codeLang="ts" code={exampleModules["./examples/NewsletterSignupBanner.svelte"] as string} />
175+
{/snippet}
176+
</CodeWrapper>
194177

195-
<CodeWrapper innerClass="p-0">
196-
<div class="mb-4 flex flex-wrap p-6">
197-
<Label class="mb-4 w-full font-bold">Example</Label>
198-
{#each exampleArr as style}
199-
<Radio labelClass="w-64 my-1" onclick={() => (exampleExpand = false)} name="block_style" bind:group={selectedExample} value={style.name}>{style.name}</Radio>
200-
{/each}
201-
</div>
202-
<SelectedComponent />
178+
<H2>Information banner</H2>
179+
<CodeWrapper>
180+
<ExampleComponents.InformationBanner />
203181
{#snippet codeblock()}
204-
<DynamicCodeBlockHighlight replaceLib {handleExpandClick} expand={exampleExpand} {showExpandButton} code={exampleModules[`./examples/${svelteCode}`] as string} />
182+
<HighlightCompo codeLang="ts" code={exampleModules["./examples/InformationBanner.svelte"] as string} />
205183
{/snippet}
206184
</CodeWrapper>
207185

0 commit comments

Comments
 (0)