From ac751098541200630a0c4cdc731e92629a875207 Mon Sep 17 00:00:00 2001 From: Mateusz Rybczonek Date: Fri, 27 Oct 2023 11:52:39 +0200 Subject: [PATCH 1/2] feat(inactive-happs): add tab select and filtering --- src/components/BaseTabSelect.vue | 121 +++++++++++++++++++++++++++++++ src/locales/en.ts | 3 +- src/pages/HAppsPage.vue | 77 +++++++++++++++----- 3 files changed, 182 insertions(+), 19 deletions(-) create mode 100644 src/components/BaseTabSelect.vue diff --git a/src/components/BaseTabSelect.vue b/src/components/BaseTabSelect.vue new file mode 100644 index 00000000..8971befe --- /dev/null +++ b/src/components/BaseTabSelect.vue @@ -0,0 +1,121 @@ + + + + + diff --git a/src/locales/en.ts b/src/locales/en.ts index 202b2577..32f7cbd5 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -49,7 +49,8 @@ export default { }, hosted_happs: { hosted_for: 'Hosted for', - no_happs: 'You’re not hosting any hApps', + no_active_happs: 'You’re not hosting any hApps', + no_inactive_happs: 'You do not have any inactive hApps', no_filtered_happs: 'No hApps match your search', title: 'Top Hosted hApps' }, diff --git a/src/pages/HAppsPage.vue b/src/pages/HAppsPage.vue index 435e6b48..3aa68b3b 100644 --- a/src/pages/HAppsPage.vue +++ b/src/pages/HAppsPage.vue @@ -4,6 +4,7 @@ import BaseSearchInput from '@uicommon/components/BaseSearchInput.vue' import HAppCard from '@uicommon/components/HAppCard.vue' import { EChipType } from '@uicommon/types/ui' import { computed, onMounted, ref } from 'vue' +import BaseTabSelect from '@/components/BaseTabSelect.vue' import SortByDropdown from '@/components/hApps/SortByDropdown.vue' import PrimaryLayout from '@/components/PrimaryLayout.vue' import { kSortOptions } from '@/constants/ui' @@ -15,6 +16,22 @@ const { getHostedHapps } = useHposInterface() const isLoading = ref(false) const isError = ref(false) +const selectedTab = ref('active') + +const tabs = computed(() => [ + { value: 'active', name: 'Active hApps', current: selectedTab.value === 'active' }, + { + value: 'inactive', + name: 'Inactive hApps', + href: '#', + current: selectedTab.value === 'inactive' + } +]) + +function onTabChange(value: string): void { + selectedTab.value = value +} + const filterValue = ref('') const filterIsActive = ref(false) @@ -32,25 +49,34 @@ const happs = ref([]) const sortBy = ref(kSortOptions.alphabetical.value) const filteredHapps = computed((): HApp[] => { - const sortByLogic: (a: HApp, b: HApp) => number = + let hAppsFilteredByActivity: HApp[] = [] + + const sortByLogic: (a: HApp, b: HApp) => number = // Sorting by earnings is not available now as we don't have a property // like that in the HApp, we use 'sourceChains' for now sortBy.value === kSortOptions.earnings.value ? (a: HApp, b: HApp): number => (a.sourceChains < b.sourceChains ? 1 : -1) : (a: HApp, b: HApp): number => (a.name > b.name ? 1 : -1) + // If no hosted hApps if (isErrorPredicate(happs.value) && happs.value.error) { return [] + } else if (!isErrorPredicate(happs.value)) { + // If hApps are hosted filter them by activity + hAppsFilteredByActivity = + selectedTab.value === 'active' + ? happs.value.filter((hApp: HApp) => hApp.enabled) + : happs.value.filter((hApp: HApp) => !hApp.enabled) } - if (!isErrorPredicate(happs.value) && filterIsActive.value && filterValue.value) { - return happs.value + if (!isErrorPredicate(hAppsFilteredByActivity) && filterIsActive.value && filterValue.value) { + return hAppsFilteredByActivity .filter((hApp: HApp) => hApp.name.toLowerCase().includes(filterValue.value.toLowerCase())) .sort(sortByLogic) } - if (!isErrorPredicate(happs.value)) { - return [...happs.value].sort(sortByLogic) + if (!isErrorPredicate(hAppsFilteredByActivity)) { + return [...hAppsFilteredByActivity].sort(sortByLogic) } return [] @@ -89,19 +115,26 @@ onMounted(async () => { @try-again-clicked="getData" >
- - +
+ + + +
@@ -131,7 +164,7 @@ onMounted(async () => { >
@@ -145,8 +178,16 @@ onMounted(async () => { position: relative; display: flex; align-items: center; - justify-content: flex-end; + justify-content: space-between; padding: 9px 0; + + &--left { + position: relative; + display: flex; + align-items: center; + justify-content: flex-end; + padding: 9px 0; + } } &__happ-list { From 12ef964f64bd86d99aa19c8eff13c79eff808965 Mon Sep 17 00:00:00 2001 From: Mateusz Rybczonek Date: Fri, 27 Oct 2023 12:03:02 +0200 Subject: [PATCH 2/2] feat(inactive-happs): final style updates --- src/assets/css/variables.css | 2 +- src/components/BaseTabSelect.vue | 2 +- src/pages/HAppsPage.vue | 1 - ui-common-library | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/assets/css/variables.css b/src/assets/css/variables.css index f45aa909..0b955de1 100644 --- a/src/assets/css/variables.css +++ b/src/assets/css/variables.css @@ -5,7 +5,7 @@ --black-color: #000000; --primary-color: #00cad9; - --primary-light-color: rgba(176, 236, 240, 0.72); + --primary-light-color: rgba(0, 202, 217, 0.06); --grey-color: #606c8b; --grey-dark-color: #313c59; diff --git a/src/components/BaseTabSelect.vue b/src/components/BaseTabSelect.vue index 8971befe..c668b1fd 100644 --- a/src/components/BaseTabSelect.vue +++ b/src/components/BaseTabSelect.vue @@ -68,7 +68,7 @@ const emit = defineEmits(['update']) flex: 1; overflow: hidden; background-color: white; - padding: 2px 16px; + padding: 2px 14px; text-align: center; font-size: 12px; font-weight: 800; diff --git a/src/pages/HAppsPage.vue b/src/pages/HAppsPage.vue index 3aa68b3b..51ad66f2 100644 --- a/src/pages/HAppsPage.vue +++ b/src/pages/HAppsPage.vue @@ -195,7 +195,6 @@ onMounted(async () => { grid-template-columns: repeat(auto-fill, minmax(600px, 600px)); grid-template-rows: repeat(auto-fill, 180px); grid-gap: 24px; - margin-top: 12px; height: calc(100vh - 175px); overflow-y: scroll; } diff --git a/ui-common-library b/ui-common-library index 0ff574a0..ca3e781a 160000 --- a/ui-common-library +++ b/ui-common-library @@ -1 +1 @@ -Subproject commit 0ff574a0544366d3bb8a9e38af0ba052552f8c1f +Subproject commit ca3e781a29e9da520c9522f8cbb4037c912262a2