Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added loading state animation on search bar #229

Merged
merged 2 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions frontend/components/CardAPI.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ const getFavicon = (url: string, size: number) => {
backdrop-filter: blur(16px) saturate(200%);
-webkit-backdrop-filter: blur(16px) saturate(200%);
background-color: var(--bg-card-glass);
border-radius: 12px;
border-radius: 8px;
border: 1px solid var(--border-color-cards);
transition-property: scale, background-color;
transition: 0.3s ease !important;
Expand Down Expand Up @@ -270,7 +270,7 @@ const getFavicon = (url: string, size: number) => {
backdrop-filter: blur(16px) saturate(200%);
-webkit-backdrop-filter: blur(16px) saturate(200%);
background-color: var(--bg-card-glass);
border-radius: 12px;
border-radius: 8px;
}
}

Expand All @@ -279,7 +279,7 @@ const getFavicon = (url: string, size: number) => {
backdrop-filter: blur(16px) saturate(200%);
-webkit-backdrop-filter: blur(16px) saturate(200%);
background-color: var(--bg-card-glass);
border-radius: 12px;
border-radius: 8px;
}
}

Expand Down
4 changes: 2 additions & 2 deletions frontend/components/LoadMoreButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const { isLoading } = defineProps({
<style scoped>
.load-more-button {
background: var(--bg-card-glass);
border-radius: 12px;
border-radius: 8px;
border: 1px solid var(--border-color-cards);
color: var(--text-color);
font-weight: 600;
Expand All @@ -40,7 +40,7 @@ const { isLoading } = defineProps({
@media only screen and (max-width: 680px) {
.load-more-button {
background: var(--bg-card-glass);
border-radius: 12px;
border-radius: 8px;
color: var(--text-color);
font-weight: 600;
font-size: 20px;
Expand Down
18 changes: 12 additions & 6 deletions frontend/components/SearchBar.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<template>
<form @submit.prevent="searchForApi">
<div class="search-bar text-black" >
<label
><font-awesome-icon
<label>
<LoadingEffectSmall v-if="loadingState" class="ms-2" />
<font-awesome-icon
v-else
class="icon-color"
:icon="['fas', 'magnifying-glass']"
style="margin-left: 1em; margin-right: 1vw"
Expand All @@ -23,25 +25,29 @@ import ApivaultServices from "~/services/ApivaultServices";

const emit = defineEmits(["search:apiSearch", "search:apiSearchTitle"]);
const accessToken = useCookie("accessToken");
const loadingState = ref<boolean>(false);

/**
Computes a filtered list of API data based on the value of apiInputSearch.
If apiInputSearch has at least 4 characters, emits a "search:apiSearch" event
with the filtered list of APIs and the apiInputSearch object. Otherwise, emits a
"search:apiSearch" event with a value of false.
"search:apiSearch" event with a false value.
@returns {undefined}
*/
const query = ref<string>("");
const searchForApi = async () => {
if (query.value.length <= 3) return;
loadingState.value = true;
if (query.value.length < 3) { loadingState.value = false; return };
const response = await ApivaultServices.search(query.value, accessToken.value!);

switch (response.length) {
case 0:
emit("search:apiSearch", false);
loadingState.value = false;
break;
default:
emit("search:apiSearch", response, query.value);
loadingState.value = false;
break;
}
}
Expand All @@ -58,7 +64,7 @@ const searchForApi = async () => {
}
.search-bar {
align-items: center;
border-radius: 16px;
border-radius: 8px;
display: flex;
justify-content: center;
transition: all 0.3s ease-in-out;
Expand All @@ -75,7 +81,7 @@ const searchForApi = async () => {
}

label {
--search-radius: 12px;
--search-radius: 8px;
--border-width: 2px;
position: relative;
overflow: hidden;
Expand Down
2 changes: 1 addition & 1 deletion frontend/components/generics/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ defineProps({
backdrop-filter: blur(16px) saturate(200%);
-webkit-backdrop-filter: blur(16px) saturate(200%);
background-color: var(--bg-card-glass);
border-radius: 12px;
border-radius: 8px;
border: 1px solid var(--border-color-cards);
transition-property: scale, background-color;
transition: 0.3s ease !important;
Expand Down