Skip to content

Commit

Permalink
Merge pull request #12 from externref/master
Browse files Browse the repository at this point in the history
ui: update ui and add transitions
  • Loading branch information
jatiinyadav authored Jun 20, 2024
2 parents bfdaa1f + b64ccf6 commit ece61b1
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 23 deletions.
1 change: 1 addition & 0 deletions ui/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ h1 {
button {
border-radius: 8px;
border: 1px solid transparent;
margin-top: 5px;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
Expand Down
76 changes: 53 additions & 23 deletions ui/src/lib/Landing.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<script lang="ts">
// import { onMount } from "svelte";
import { onMount } from "svelte";
import type { IResponseType } from "../interfaces/IResponseType";
import { fade, slide } from "svelte/transition";
let mount: boolean = false;
onMount(() => {
mount = true;
});
// let message = "";
let items: IResponseType[] = [];
// const endpoint = "http://localhost:8080/api/message";
Expand All @@ -26,11 +30,11 @@
console.log(inputValue1);
const response = await fetch(
`http://localhost:8080/api/weburl?url1=${inputValue1}&url2=${inputValue2}`
`http://localhost:8080/api/weburl?url1=${inputValue1}&url2=${inputValue2}`,
);
const data = await response.json();
console.log(data); // Process the response data as needed
items = data
items = data;
} catch (error) {
console.error("Error fetching data:", error);
}
Expand All @@ -40,35 +44,61 @@
}
</script>

<main>
<!-- <h1>{message}</h1> -->

<!-- svelte-ignore a11y-autofocus -->
<input type="text" bind:value={inputValue1} />
{#if mount}
<main>
<!-- <h1>{message}</h1> -->
<!-- svelte-ignore a11y-autofocus -->
<input type="text" bind:value={inputValue1} />

<!-- svelte-ignore a11y-autofocus -->
<input type="text" bind:value={inputValue2} />
<button on:click={fetchData}>Fetch Data</button>
<!-- svelte-ignore a11y-autofocus -->
<input type="text" bind:value={inputValue2} /><br />
<button transition:fade={{ delay: 100, duration: 400 }} on:click={fetchData}
>Fetch Data</button
>


<h1>List of Items</h1>
<ul>
{items.length}
{#each items as item}
<li><span>Header: </span> {item.header}</li>
<li><span>Description: </span> {item.desc}</li>
<li><span>URL: </span> {item.href}</li>
{#if items.length > 0}
<button
transition:fade={{ delay: 100, duration: 400 }}
on:click={() => {
items = [];
}}>Reset</button
>
<flex>
<div id="loi">List of Items</div>
<div>(<b> Total items:</b> {items.length})</div></flex
>
<hr />
{/each}
</ul>
</main>

<ul>
<div transition:slide={{ duration: 400, delay: 100, axis: "y" }}>
{#each items as item}
<div transition:slide={{ duration: 400, delay: 100, axis: "y" }}>
<li><span>Header: </span> {item.header}</li>
<li><span>Description: </span> {item.desc}</li>
<li><span>URL: </span> {item.href}</li>
<hr />
</div>
{/each}
</div>
</ul>
{/if}
</main>
{/if}

<style>
ul {
text-align: left;
}
input {
border-radius: 5%;
outline: none;
}
span {
font-weight: bold;
font-size: 1.3rem;
}
#loi {
font-size: xx-large;
}
</style>

0 comments on commit ece61b1

Please sign in to comment.