Skip to content

Commit

Permalink
feat(history): add delete button
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Jan 23, 2024
1 parent 2381718 commit f14fb16
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion components/pages/home/PageHistory.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { formatTimeAgo } from '@vueuse/core'
import { toast } from 'vue-sonner'
import { XMarkIcon } from '@heroicons/vue/20/solid'
const { isPremium } = useUserData()
const { pageHistory } = usePageHistory()
Expand Down Expand Up @@ -47,6 +48,10 @@
navigateTo(path)
}
function removeHistoryItem(path: string) {
pageHistory.value = pageHistory.value.filter((historyItem) => historyItem.path !== path)
}
</script>

<template>
Expand All @@ -55,7 +60,7 @@
role="list"
>
<li
v-for="(historyItem, index) in pageHistory.slice().reverse()"
v-for="(historyItem, index) in pageHistory.toReversed()"
:key="index"
class="relative flex gap-x-4"
>
Expand Down Expand Up @@ -89,6 +94,14 @@
>
{{ formatTimeAgo(new Date(historyItem.date)) }}
</time>

<button
class="focus-visible:focus-outline-util hover:hover-text-util hover:hover-bg-util h-fit max-h-fit rounded-md px-1 py-0.5"
type="button"
@click="removeHistoryItem(historyItem.path)"
>
<XMarkIcon class="h-5 w-5" />
</button>
</li>
</ol>
</template>

0 comments on commit f14fb16

Please sign in to comment.