Skip to content

Commit 21c0ecd

Browse files
committed
fix: #74, #75
1 parent e8fe9c9 commit 21c0ecd

File tree

5 files changed

+27
-34
lines changed

5 files changed

+27
-34
lines changed

src/lib/banner/Banner.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
let { children, header, open = $bindable(true), dismissable = true, color = "gray", type, class: className, innerClass, transition = fade, params, ...restProps }: Props = $props();
99
10-
const { base, insideDiv, dismissable: dismissableClass } = banner({ type, color });
10+
const { base, insideDiv, dismissable: dismissableClass } = $derived(banner({ type, color }));
1111
</script>
1212

1313
{#if open}

src/lib/carousel/Carousel.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
type TransitionFunc = (node: HTMLElement, params: ParamsType) => TransitionConfig;
1313
const SLIDE_DURATION_RATIO = 0.25; // TODO: Expose one day?
1414
15-
let { children, slide, images, index = $bindable(), slideDuration = 1000, transition, duration = 0, "aria-label": ariaLabel = "Draggable Carousel", disableSwipe = false, imgClass = "", class: className, onchange, ...restProps }: Props = $props();
15+
let { children, slide, images, index = $bindable(0), slideDuration = 1000, transition, duration = 0, "aria-label": ariaLabel = "Draggable Carousel", disableSwipe = false, imgClass = "", class: className, onchange, ...restProps }: Props = $props();
1616
1717
const { set, subscribe, update } = writable<State>({ images, index: index ?? 0, forward: true, slideDuration, lastSlideChange: new Date() });
1818

src/lib/carousel/type.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ interface CarouselProps extends CarouselVariants, Omit<HTMLAttributes<HTMLDivEle
1717
children?: Snippet<[number]>;
1818
slide?: Snippet<[{ index: number; Slide: typeof Slide }]>;
1919
images: HTMLImgAttributes[];
20-
index: number;
21-
slideDuration: number;
20+
index?: number;
21+
slideDuration?: number;
2222
transition?: TransitionFunc;
23-
duration: number;
24-
disableSwipe: boolean;
25-
imgClass: string;
23+
duration?: number;
24+
disableSwipe?: boolean;
25+
imgClass?: string;
2626
onchange?: (x: HTMLImgAttributes) => {};
2727
}
2828

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

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,19 @@
1919
// interactive example
2020
// position, bannerType, color, class:divClass
2121
const colors = Object.keys(banner.variants.color);
22-
let position: BannerProps["position"] = $state("sticky");
23-
const changePosition = () => {
24-
position = position === "sticky" ? "absolute" : "sticky";
25-
if (position === "sticky") {
26-
bannerType = "default";
27-
}
28-
};
29-
let bannerType: BannerProps["bannerType"] = $state("default");
30-
const changeBannerType = () => {
31-
bannerType = bannerType === "default" ? "cta" : "default";
32-
if (bannerType === "cta") {
33-
position = "absolute";
34-
}
35-
};
22+
// let position: BannerProps["type"] = $state("top");
23+
// const changePosition = () => {
24+
// position = position === "top" ? "bottom" : "top";
25+
// };
26+
// let bannerType: BannerProps["type"] = $state("top");
27+
// const changeBannerType = () => {
28+
// bannerType = bannerType === "default" ? "cta" : "default";
29+
// if (bannerType === "cta") {
30+
// }
31+
// };
3632
let color: BannerProps["color"] = $state("primary");
37-
let bannerClass: BannerProps["class"] = $state("");
33+
$inspect('color', color);
34+
let bannerClass: BannerProps["class"] = $state("absolute");
3835
const changeClass = () => {
3936
bannerClass = bannerClass === "" ? "mt-4" : "";
4037
};
@@ -66,8 +63,6 @@
6663
// position, bannerType color, class
6764
let props = [];
6865
if (color !== "primary") props.push(` color="${color}"`);
69-
if (bannerType !== "default") props.push(` bannerType="${bannerType}"`);
70-
if (position !== "sticky") props.push(` position="${position}"`);
7166
if (bannerClass) props.push(` class="${bannerClass}"`);
7267
if (!bannerStatus) props.push(" bannerStatus={false}");
7368
if (currentTransition !== transitions[0]) {
@@ -120,7 +115,7 @@
120115
<Skeleton class="py-4" />
121116
<ImagePlaceholder class="py-4" />
122117
</div>
123-
<Banner id="sample-banner" {position} {bannerType} {color} class={bannerClass} bind:bannerStatus transition={currentTransition.transition} params={currentTransition.params}>
118+
<Banner id="sample-banner" {color} bind:open={bannerStatus} class={bannerClass} transition={currentTransition.transition} params={currentTransition.params}>
124119
<p class="flex items-center text-sm font-normal text-gray-500 dark:text-gray-400">
125120
<span class="me-3 inline-flex rounded-full bg-gray-200 p-1 dark:bg-gray-600">
126121
<BullhornOutline class="h-3 w-3 text-gray-500 dark:text-gray-400" />
@@ -148,11 +143,6 @@
148143
<Radio labelClass="w-16 my-1" name="interactive_transition" bind:group={selectedTransition} value={transition.name}>{transition.name}</Radio>
149144
{/each}
150145
</div>
151-
<div class="flex flex-wrap justify-center gap-2 md:justify-start">
152-
<Button class="w-40" onclick={changePosition}>Position: {position === "sticky" ? "absolute" : "sticky"}</Button>
153-
<Button class="w-40" color="blue" onclick={changeBannerType}>Type: {bannerType === "default" ? "cta" : "default"}</Button>
154-
<Button class="w-40" color="green" onclick={changeClass}>{bannerClass ? "Remove class" : "Add class"}</Button>
155-
</div>
156146
</div>
157147
{#snippet codeblock()}
158148
<DynamicCodeBlockHighlight handleExpandClick={handleBuilderExpandClick} expand={builderExpand} showExpandButton={showBuilderExpandButton} code={generatedCode} />

src/routes/docs/components/popover.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,22 +238,25 @@ Dynamically show the password strength progress when creating a new password pos
238238
<script lang="ts">
239239
import { Popover, Label, Input, Checkbox, Button } from "flowbite-svelte";
240240
import { CheckOutline, CloseOutline } from "flowbite-svelte-icons";
241-
function preventDefault<E extends Event>(fn: (event: E) => void) {
241+
const preventDefault = <E extends Event>(fn: (event: E) => void) => {
242242
return function (this: any, event: E) {
243243
event.preventDefault();
244244
fn.call(this, event);
245245
};
246246
}
247+
const handler = ()=>{
248+
alert('Submitted!')
249+
}
247250
</script>
248251
249-
<form onsubmit={preventDefault} class="mb-8">
252+
<form onsubmit={preventDefault(handler)} class="mb-8">
250253
<div class="mb-6">
251254
<Label for="email" class="mb-2">Your email</Label>
252-
<Input type="email" id="email" placeholder="name@flowbite.com" required="" />
255+
<Input type="email" id="email" placeholder="name@flowbite.com" />
253256
</div>
254257
<div class="mb-6">
255258
<Label for="password" class="mb-2">Your password</Label>
256-
<Input type="password" id="password" required="" />
259+
<Input type="password" id="password" />
257260
</div>
258261
<Checkbox class="mb-6">Remember me</Checkbox>
259262
<Button type="submit">Submit</Button>

0 commit comments

Comments
 (0)