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,45 +10,43 @@
// Flag to show IPFS demo
let showIPFSDemo = false;
function handleDemoButtonClick() {
console.log("Hello");
showIPFSDemo = !showIPFSDemo;
}
</script>
<div class="">
{#if contentPath}
<div class="text-center mb-8 sm:mb-12">
<h2 class="text-2xl sm:text-3xl font-bold mb-3 sm:mb-4 text-text">
IPFS Integration
</h2>
<p 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.
</p>
<div class="mt-6">
<Button
variant="primary"
size="lg"
on:click={handleDemoButtonClick}
>
{showIPFSDemo ? "Hide IPFS Demo" : "Show IPFS Demo"}
</Button>
</div>
</div>
{#if showIPFSDemo}
<section class="mb-12 sm:mb-16 md:mb-20">
<IPFSDemo />
</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>
{:else}
<!-- IPFS Demo Section -->
<section class="mb-12 sm:mb-16 md:mb-20">
<div class="text-center mb-8 sm:mb-12">
<h2
class="text-2xl sm:text-3xl font-bold mb-3 sm:mb-4 text-text"
>
IPFS Integration
</h2>
<p
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.
</p>
<div class="mt-6">
<Button
variant="primary"
size="lg"
on:click={() => (showIPFSDemo = !showIPFSDemo)}
>
{showIPFSDemo ? "Hide IPFS Demo" : "Show IPFS Demo"}
</Button>
</div>
</div>
{#if showIPFSDemo}
<IPFSDemo />
{/if}
</section>
{/if}
</div>

View File

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

View File

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