diff --git a/app.vue b/app.vue index 686a15e..9aeae9d 100644 --- a/app.vue +++ b/app.vue @@ -25,6 +25,13 @@ onMounted(() => { if (e.target instanceof HTMLElement && e.target.classList.contains("message-text") && e.target.contentEditable) { e.target.contentEditable = "false"; } + const destroyOnClick = document.getElementsByClassName("destroy-on-click"); + for (const element of destroyOnClick) { + const closest = (e.target as HTMLElement).closest(".destroy-on-click"); + if (element != closest) { + unrender(element); + } + } }); document.addEventListener("keyup", (e) => { const messageReply = document.getElementById("message-reply") as HTMLDivElement; diff --git a/components/Banner.vue b/components/Banner.vue new file mode 100644 index 0000000..b9b4da4 --- /dev/null +++ b/components/Banner.vue @@ -0,0 +1,13 @@ + + + + + \ No newline at end of file diff --git a/components/Dropdown.vue b/components/Dropdown.vue new file mode 100644 index 0000000..89be6d6 --- /dev/null +++ b/components/Dropdown.vue @@ -0,0 +1,46 @@ + + + + + \ No newline at end of file diff --git a/components/GuildOptionsMenu.vue b/components/GuildOptionsMenu.vue new file mode 100644 index 0000000..e9bbcf9 --- /dev/null +++ b/components/GuildOptionsMenu.vue @@ -0,0 +1,59 @@ + + + + + \ No newline at end of file diff --git a/components/InviteModal.vue b/components/InviteModal.vue new file mode 100644 index 0000000..d532ae3 --- /dev/null +++ b/components/InviteModal.vue @@ -0,0 +1,70 @@ + + + + + \ No newline at end of file diff --git a/components/Modal.vue b/components/Modal.vue new file mode 100644 index 0000000..041dd1a --- /dev/null +++ b/components/Modal.vue @@ -0,0 +1,84 @@ + + + + + \ No newline at end of file diff --git a/components/Popups/InvitePopup.vue b/components/Popups/InvitePopup.vue deleted file mode 100644 index 262507a..0000000 --- a/components/Popups/InvitePopup.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - - - \ No newline at end of file diff --git a/composables/api.ts b/composables/api.ts index 11c2226..0b438a6 100644 --- a/composables/api.ts +++ b/composables/api.ts @@ -53,6 +53,18 @@ export const useApi = () => { return await fetchWithApi(`/channels/${channelId}/messages/${messageId}`); } + async function createGuild(name: string): Promise { + return await fetchWithApi(`/guilds`, { method: "POST", body: { name } }); + } + + async function joinGuild(invite: string): Promise { + return await fetchWithApi(`/invites/${invite}`, { method: "POST" }) as GuildResponse; + } + + async function createChannel(guildId: string, name: string, description?: string): Promise { + return await fetchWithApi(`/guilds/${guildId}/channels`, { method: "POST", body: { name, description } }); + } + async function fetchInstanceStats(apiBase: string): Promise { return await $fetch(`${apiBase}/stats`, { method: "GET" }); } @@ -76,6 +88,9 @@ export const useApi = () => { removeFriend, fetchMessages, fetchMessage, + createGuild, + joinGuild, + createChannel, fetchInstanceStats, sendVerificationEmail } diff --git a/layouts/client.vue b/layouts/client.vue index 478d025..6b3bfa1 100644 --- a/layouts/client.vue +++ b/layouts/client.vue @@ -10,18 +10,27 @@
- - - -
- - - +
+ + + +
+ + + + +
+
+
+
+ +
+ +
- - -
@@ -29,11 +38,165 @@ \ No newline at end of file diff --git a/types/interfaces.ts b/types/interfaces.ts index 72cda88..2a05c38 100644 --- a/types/interfaces.ts +++ b/types/interfaces.ts @@ -86,6 +86,19 @@ export interface ScrollPosition { offsetLeft: number } +export interface DropdownOption { + name: string, + value: string | number, + callback: () => void +} + +export interface ModalProps { + title?: string, + obscure?: boolean, + onClose?: () => void, + onCancel?: () => void +} + export interface ContextMenuItem { name: string, callback: (...args: any[]) => any; diff --git a/utils/unrender.ts b/utils/unrender.ts new file mode 100644 index 0000000..5caa600 --- /dev/null +++ b/utils/unrender.ts @@ -0,0 +1,6 @@ +import { render } from "vue"; + +export default (div: Element) => { + render(null, div); + div.remove(); +}