From f681af46587755d15d174670e68d7cd37c9fdc06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20J=C3=BAlio=20Moreira?= Date: Fri, 28 Apr 2023 18:31:49 +0100 Subject: [PATCH] Add generalized text field --- src/lib/component/IconButton.svelte | 14 +++++ src/lib/component/Icons.ts | 8 ++- src/lib/component/input/TextField.svelte | 70 ++++++++++++++++++++++++ src/routes/events/+page.svelte | 27 +++++---- 4 files changed, 106 insertions(+), 13 deletions(-) create mode 100644 src/lib/component/IconButton.svelte create mode 100644 src/lib/component/input/TextField.svelte diff --git a/src/lib/component/IconButton.svelte b/src/lib/component/IconButton.svelte new file mode 100644 index 00000000..3c291a3a --- /dev/null +++ b/src/lib/component/IconButton.svelte @@ -0,0 +1,14 @@ + + + diff --git a/src/lib/component/Icons.ts b/src/lib/component/Icons.ts index 7d476435..c5e8dc88 100644 --- a/src/lib/component/Icons.ts +++ b/src/lib/component/Icons.ts @@ -7,6 +7,7 @@ import FaBrandsLinkedin from 'svelte-icons-pack/fa/FaBrandsLinkedin'; import FaSolidUser from 'svelte-icons-pack/fa/FaSolidUser'; import FaBars from 'svelte-icons-pack/fa/FaSolidBars'; import FaTimes from 'svelte-icons-pack/fa/FaSolidTimes'; +import AiOutlineSearch from "svelte-icons-pack/ai/AiOutlineSearch"; const Icons = { Instagram: FaBrandsInstagram, @@ -17,7 +18,12 @@ const Icons = { Linkedin: FaBrandsLinkedin, User: FaSolidUser, Bars: FaBars, - Times: FaTimes + Times: FaTimes, + Search: AiOutlineSearch }; +type Keys = keyof typeof Icons; +export type IconsType = typeof Icons[Keys]; + + export default Icons; diff --git a/src/lib/component/input/TextField.svelte b/src/lib/component/input/TextField.svelte new file mode 100644 index 00000000..cd64d699 --- /dev/null +++ b/src/lib/component/input/TextField.svelte @@ -0,0 +1,70 @@ + + + + +
+ {#if beforeIcon } + + {#if beforeIcon.button} + + {:else} + + {/if} + + {/if} + + + {#if afterIcon } + + {#if afterIcon.button} + + {:else} + + {/if} + + {/if} +
diff --git a/src/routes/events/+page.svelte b/src/routes/events/+page.svelte index 26fe6f5b..ac05bc33 100644 --- a/src/routes/events/+page.svelte +++ b/src/routes/events/+page.svelte @@ -1,22 +1,25 @@
</div> + + <form class="flex flex-wrap justify-around mt-10" on:submit={searchEvents}> + <TextField + beforeIcon={{button: true, icon: Icons.Search, type: "submit"}} + name="search" + placeholder="Search" + value="" + /> + </form> </div>