feat: Improve IPFS demo in Home component

- Added a button to toggle the visibility of the IPFS demo.
- Improved the layout and styling of the IPFS demo section.
- Removed unnecessary alert in IPFS upload functionality.
- Updated button component to correctly handle click events.
This commit is contained in:
Mahmoud Emad 2025-05-13 10:10:14 +03:00
parent 3e1822247d
commit df5aeaef6c
3 changed files with 33 additions and 35 deletions

View File

@ -10,36 +10,28 @@
// Flag to show IPFS demo // Flag to show IPFS demo
let showIPFSDemo = false; let showIPFSDemo = false;
function handleDemoButtonClick() {
console.log("Hello");
showIPFSDemo = !showIPFSDemo;
}
</script> </script>
<div class=""> <div class="">
{#if contentPath}
<div
class="bg-background-secondary shadow-sm p-4 sm:p-6 overflow-x-auto"
>
<MarkdownContent path={actualPath} />
</div>
{:else}
<!-- IPFS Demo Section -->
<section class="mb-12 sm:mb-16 md:mb-20">
<div class="text-center mb-8 sm:mb-12"> <div class="text-center mb-8 sm:mb-12">
<h2 <h2 class="text-2xl sm:text-3xl font-bold mb-3 sm:mb-4 text-text">
class="text-2xl sm:text-3xl font-bold mb-3 sm:mb-4 text-text"
>
IPFS Integration IPFS Integration
</h2> </h2>
<p <p class="text-lg sm:text-xl text-text-secondary max-w-3xl mx-auto">
class="text-lg sm:text-xl text-text-secondary max-w-3xl mx-auto" Experience the power of decentralized content storage and retrieval
> with IPFS.
Experience the power of decentralized content storage and
retrieval with IPFS.
</p> </p>
<div class="mt-6"> <div class="mt-6">
<Button <Button
variant="primary" variant="primary"
size="lg" size="lg"
on:click={() => (showIPFSDemo = !showIPFSDemo)} on:click={handleDemoButtonClick}
> >
{showIPFSDemo ? "Hide IPFS Demo" : "Show IPFS Demo"} {showIPFSDemo ? "Hide IPFS Demo" : "Show IPFS Demo"}
</Button> </Button>
@ -47,8 +39,14 @@
</div> </div>
{#if showIPFSDemo} {#if showIPFSDemo}
<section class="mb-12 sm:mb-16 md:mb-20">
<IPFSDemo /> <IPFSDemo />
{/if}
</section> </section>
{:else if contentPath && contentPath.trim() !== ""}
<div
class="bg-background-secondary shadow-sm p-4 sm:p-6 overflow-x-auto"
>
<MarkdownContent path={actualPath} />
</div>
{/if} {/if}
</div> </div>

View File

@ -87,7 +87,6 @@
variant="primary" variant="primary"
on:click={() => { on:click={() => {
console.log("Upload button clicked directly"); console.log("Upload button clicked directly");
alert("Upload button clicked!");
uploadContent(); uploadContent();
}} }}
disabled={uploading || !content.trim()} disabled={uploading || !content.trim()}

View File

@ -1,11 +1,11 @@
<!-- button.svelte -->
<script lang="ts"> <script lang="ts">
import { cn } from "../../../utils"; import { cn } from "../../../utils";
export let variant: "primary" | "secondary" | "ghost" = "primary"; export let variant: "primary" | "secondary" | "ghost" = "primary";
export let size: "default" | "sm" | "lg" | "icon" = "default"; export let size: "default" | "sm" | "lg" | "icon" = "default";
let className: string | undefined | null = undefined; let className: string | undefined | null = undefined;
export { className as class }; export { className };
const sizeClasses = { const sizeClasses = {
default: "h-10 px-4 py-2", default: "h-10 px-4 py-2",
@ -26,6 +26,7 @@
sizeClasses[size], sizeClasses[size],
className, className,
)} )}
on:click
{...$$restProps} {...$$restProps}
> >
<slot /> <slot />