-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: ✨ Create new user profile view, refine components, add dropdown…
… to notes
- Loading branch information
1 parent
a0d0737
commit a17df9f
Showing
21 changed files
with
470 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<template> | ||
<ButtonsBase | ||
class="bg-white/10 hover:bg-white/20 !text-left flex flex-row gap-x-3 !rounded-none !ring-0 !p-4 sm:!p-3"> | ||
<Icon :name="icon" class="h-5 w-5 text-gray-200" aria-hidden="true" /> | ||
<slot /> | ||
</ButtonsBase> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import type { ButtonHTMLAttributes } from "vue"; | ||
interface Props extends /* @vue-ignore */ ButtonHTMLAttributes { } | ||
defineProps<Props & { | ||
icon: string; | ||
}>(); | ||
</script> | ||
|
||
<style></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<template> | ||
<HeadlessMenu v-slot="{ close }"> | ||
<slot name="button"></slot> | ||
|
||
<HeadlessMenuItems @click="close" class="fixed inset-0 z-5 bg-black/50"> | ||
|
||
</HeadlessMenuItems> | ||
|
||
<transition enter-active-class="transition ease-in duration-100" | ||
enter-from-class="transform opacity-0 translate-y-full sm:translate-y-0 scale-95" | ||
enter-to-class="transform translate-y-0 opacity-100 scale-100" | ||
leave-active-class="transition ease-out duration-75" leave-from-class="transform opacity-100 scale-100" | ||
leave-to-class="transform opacity-0 scale-95"> | ||
<HeadlessMenuItems | ||
:class="['z-10 mt-2 rounded overflow-hidden bg-dark-900 shadow-lg ring-1 ring-white/10 focus:outline-none', | ||
isSmallScreen ? 'bottom-0 fixed inset-x-0 w-full origin-bottom' : 'absolute right-0 origin-top-right top-full min-w-56']"> | ||
<div v-if="isSmallScreen" class="w-full bg-white/10 py-2"> | ||
<div class="rounded-full h-1 bg-gray-400 w-12 mx-auto"></div> | ||
</div> | ||
<slot name="items"></slot> | ||
</HeadlessMenuItems> | ||
</transition> | ||
</HeadlessMenu> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
const { width } = useWindowSize() | ||
const isSmallScreen = computed(() => width.value < 640) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import type { Mastodon } from "megalodon"; | ||
import type { Status } from "~/types/mastodon/status"; | ||
|
||
export const useAccountTimeline = ( | ||
client: Mastodon | null, | ||
id: string | null, | ||
options: MaybeRef< | ||
Partial<{ | ||
limit?: number | undefined; | ||
max_id?: string | undefined; | ||
since_id?: string | undefined; | ||
min_id?: string | undefined; | ||
pinned?: boolean | undefined; | ||
exclude_replies?: boolean | undefined; | ||
exclude_reblogs?: boolean | undefined; | ||
only_media: boolean; | ||
}> | ||
>, | ||
): { | ||
timeline: Ref<Status[]>; | ||
loadNext: () => Promise<void>; | ||
loadPrev: () => Promise<void>; | ||
} => { | ||
if (!client || !id) { | ||
return { | ||
timeline: ref([]), | ||
loadNext: async () => {}, | ||
loadPrev: async () => {}, | ||
}; | ||
} | ||
|
||
const fetchedNotes = ref<Status[]>([]); | ||
const fetchedNoteIds = new Set<string>(); | ||
let nextMaxId: string | undefined = undefined; | ||
let prevMinId: string | undefined = undefined; | ||
|
||
const loadNext = async () => { | ||
const response = await client.getAccountStatuses(id, { | ||
only_media: false, | ||
...ref(options).value, | ||
max_id: nextMaxId, | ||
limit: useConfig().NOTES_PER_PAGE, | ||
}); | ||
|
||
const newNotes = response.data.filter( | ||
(note) => !fetchedNoteIds.has(note.id), | ||
); | ||
if (newNotes.length > 0) { | ||
fetchedNotes.value = [...fetchedNotes.value, ...newNotes]; | ||
nextMaxId = newNotes[newNotes.length - 1].id; | ||
for (const note of newNotes) { | ||
fetchedNoteIds.add(note.id); | ||
} | ||
} else { | ||
nextMaxId = undefined; | ||
} | ||
}; | ||
|
||
const loadPrev = async () => { | ||
const response = await client.getAccountStatuses(id, { | ||
only_media: false, | ||
...ref(options).value, | ||
min_id: prevMinId, | ||
limit: useConfig().NOTES_PER_PAGE, | ||
}); | ||
|
||
const newNotes = response.data.filter( | ||
(note) => !fetchedNoteIds.has(note.id), | ||
); | ||
if (newNotes.length > 0) { | ||
fetchedNotes.value = [...newNotes, ...fetchedNotes.value]; | ||
prevMinId = newNotes[0].id; | ||
for (const note of newNotes) { | ||
fetchedNoteIds.add(note.id); | ||
} | ||
} else { | ||
prevMinId = undefined; | ||
} | ||
}; | ||
|
||
watch( | ||
() => ref(options).value, | ||
async ({ max_id, min_id }) => { | ||
nextMaxId = max_id; | ||
prevMinId = min_id; | ||
await loadNext(); | ||
}, | ||
{ immediate: true }, | ||
); | ||
|
||
return { timeline: fetchedNotes, loadNext, loadPrev }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.