Skip to content

Commit

Permalink
some i18n, new post modal
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed Oct 8, 2023
1 parent 1dbe285 commit 72e6eef
Show file tree
Hide file tree
Showing 20 changed files with 833 additions and 161 deletions.
6 changes: 5 additions & 1 deletion kitsune-fe/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
"@fortawesome/vue-fontawesome": "^3.0.2",
"@hcaptcha/vue3-hcaptcha": "^1.3.0",
"@mcaptcha/vanilla-glue": "^0.1.0-alpha-3",
"@tiptap/pm": "^2.1.11",
"@tiptap/starter-kit": "^2.1.11",
"@tiptap/vue-3": "^2.1.11",
"@urql/exchange-graphcache": "^6.3.3",
"@urql/vue": "^1.1.2",
"@vueuse/core": "^10.4.1",
"@vueuse/core": "^10.5.0",
"@zxcvbn-ts/core": "^3.0.4",
"@zxcvbn-ts/language-common": "^3.0.4",
"@zxcvbn-ts/language-en": "^3.0.2",
Expand All @@ -32,6 +35,7 @@
"pinia-plugin-persistedstate": "^3.2.0",
"unhead": "^1.7.4",
"vue": "^3.2.41",
"vue-i18n": "^9.5.0",
"vue-powerglitch": "^1.0.0",
"vue-router": "^4.2.5",
"vue-virtual-scroller": "^2.0.0-beta.8"
Expand Down
2 changes: 1 addition & 1 deletion kitsune-fe/src/components/AuthForms.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
/>
</FormKit>

<BaseModal :closed="!modalData.show" :title="modalData.title">
<BaseModal v-model="modalData.show" :title="modalData.title">
<!-- This is returned from the backend and created from an error type, and only "enhanced" with HTML newlines by us -->
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="modalData.content" />
Expand Down
40 changes: 0 additions & 40 deletions kitsune-fe/src/components/BaseModal.vue

This file was deleted.

13 changes: 10 additions & 3 deletions kitsune-fe/src/components/BaseTimeline.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template>
<fieldset class="timeline" ref="scroller">
<legend>INCOMING TRANSMISSIONS</legend>
<legend class="timeline-legend">
{{ $t('messages.timeline.title') }}
</legend>
<DynamicScroller class="scroller" :items="posts" :min-item-size="50">
<template
v-slot="{
Expand Down Expand Up @@ -39,6 +41,7 @@
import { useInfiniteScroll } from '@vueuse/core';
import { ref } from 'vue';
import { DynamicScroller, DynamicScrollerItem } from 'vue-virtual-scroller';
import Post, { Post as PostType } from './Post.vue';
Expand All @@ -47,7 +50,7 @@
const scroller = ref<HTMLElement>();
useInfiniteScroll(
scroller,
() => {
async () => {
console.log('hmm');
},
{ distance: 3 },
Expand All @@ -59,9 +62,13 @@
margin: auto;
border-color: grey;
max-height: 80vh;
max-height: 82vh;
max-width: 100ch;
overflow-y: scroll;
&-legend {
text-transform: uppercase;
}
}
.post-container * {
Expand Down
4 changes: 4 additions & 0 deletions kitsune-fe/src/components/GenericFooter.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<template>
<footer>
<div class="footer">
<LanguageSelector />

<span>Kitsune v{{ instanceData?.version }}</span>

<a target="_blank" href="https://github.com/kitsune-soc/kitsune">
Source code
</a>
Expand All @@ -11,6 +14,7 @@

<script setup lang="ts">
import { useInstanceInfo } from '../graphql/instance-info';
import LanguageSelector from './LanguageSelector.vue';
const instanceData = useInstanceInfo();
</script>
Expand Down
7 changes: 7 additions & 0 deletions kitsune-fe/src/components/LanguageSelector.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<select v-model="$i18n.locale">
<option v-for="(lang, i) in $i18n.availableLocales" :key="i" :value="lang">
{{ lang }}
</option>
</select>
</template>
11 changes: 11 additions & 0 deletions kitsune-fe/src/components/NavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@
<NavBarLink :to="route" :icon="details.icon" :detail="details.detail" />
</template>
</div>

<div class="nav-bar-profile">
<div class="nav-bar-element profile-menu-button">
<img :src="DEFAULT_PROFILE_PICTURE_URL" />
</div>

<div class="nav-bar-element">
<font-awesome-icon
@click="showPostModal = true"
class="icon create-status"
icon="fa-pen-to-square fa-solid"
/>
</div>
</div>
</nav>

<NewPostModal v-model="showPostModal" />
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { DEFAULT_PROFILE_PICTURE_URL } from '../consts';
import NavBarLink from './NavBarLink.vue';
import NewPostModal from './modal/NewPostModal.vue';
type RouteInfo = {
icon: string;
Expand Down Expand Up @@ -50,6 +58,8 @@
detail: 'Federated',
},
};
const showPostModal = ref(false);
</script>

<style scoped lang="scss">
Expand Down Expand Up @@ -89,6 +99,7 @@
.create-status {
height: 25px;
cursor: pointer;
}
.profile-menu-button {
Expand Down
22 changes: 16 additions & 6 deletions kitsune-fe/src/components/Post.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,42 @@
:src="profilePictureUrl"
:alt="`${account.username}'s profile picture`"
/>

<div class="account-info-names">
<strong class="account-info-names-displayname">
{{ account.displayName ? account.displayName : account.username }}
{{ account.displayName ?? account.username }}
</strong>
<span class="account-info-names-username">
@{{ account.username }}
</span>
</div>
</a>

<p v-if="subject">
<strong><span v-html="subject" /></strong>
<strong>
<!-- Cleaned on the backend -->
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="subject" />
</strong>
</p>

<!-- Cleaned on the backend -->
<!-- eslint-disable-next-line vue/no-v-html -->
<span class="post-content" v-html="content" />

<div class="post-attachments">
<div v-for="attachment in attachments" :title="attachment.description!">
<audio
v-if="attachment.contentType.startsWith('audio')"
:src="attachment.url"
/>

<video
v-else-if="attachment.contentType.startsWith('video')"
:src="attachment.url"
controls
/>

<img v-else :src="attachment.url" :alt="attachment.description!" />
</div>
</div>
Expand Down Expand Up @@ -64,10 +76,8 @@
};
const props = defineProps<Post>();
const profilePictureUrl = computed(() =>
props.account.avatar
? props.account.avatar.url
: DEFAULT_PROFILE_PICTURE_URL,
const profilePictureUrl = computed(
() => props.account.avatar?.url ?? DEFAULT_PROFILE_PICTURE_URL,
);
</script>

Expand Down
59 changes: 59 additions & 0 deletions kitsune-fe/src/components/modal/BaseModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<template>
<div v-if="modelValue" class="modal">
<fieldset ref="modalContent" class="modal-content">
<legend class="modal-title">
{{ title }}
</legend>
<slot />
</fieldset>
</div>
</template>

<script lang="ts" setup>
import { onClickOutside } from '@vueuse/core';
import { ref } from 'vue';
defineProps<{
modelValue: boolean;
title: string;
}>();
const emit = defineEmits<{
(event: 'update:modelValue', modelValue: boolean): void;
}>();
const modalContent = ref();
onClickOutside(modalContent, () => {
emit('update:modelValue', false);
});
</script>

<style lang="scss" scoped>
@use '../../styles/colours' as *;
.modal {
position: absolute;
display: flex;
justify-content: center;
align-items: center;
top: 0;
bottom: 0;
left: 0;
right: 0;
background-color: rgba(0, 0, 0, 0.75);
z-index: 999;
&-title {
text-transform: uppercase;
}
&-content {
background-color: $dark1;
height: fit-content;
}
}
</style>
79 changes: 79 additions & 0 deletions kitsune-fe/src/components/modal/NewPostModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<BaseModal
:model-value="modelValue"
@update:model-value="$emit('update:modelValue', $event)"
:title="$t('messages.newPost.title')"
>
<BubbleMenu v-if="editor" :editor="editor" :tippy-options="tippyOptions">
<button
@click="editor.chain().focus().toggleBold().run()"
:class="{ 'is-active': editor.isActive('bold') }"
>
Bold
</button>

<button
@click="editor.chain().focus().toggleCodeBlock().run()"
:class="{ 'is-active': editor.isActive('codeBlock') }"
>
Code block
</button>
</BubbleMenu>

<FloatingMenu v-if="editor" :editor="editor" :tippy-options="tippyOptions">
<button
:class="{ 'is-active': editor.isActive('heading', { level: 1 }) }"
@click="editor.chain().focus().toggleHeading({ level: 1 }).run()"
>
H1
</button>
<button
:class="{ 'is-active': editor.isActive('heading', { level: 2 }) }"
@click="editor.chain().focus().toggleHeading({ level: 2 }).run()"
>
H2
</button>

<button
:class="{ 'is-active': editor.isActive('bulletList') }"
@click="editor.chain().focus().toggleBulletList().run()"
>
Toggle list
</button>
</FloatingMenu>

<EditorContent class="editor" :editor="editor" />
</BaseModal>
</template>

<script lang="ts" setup>
import StarterKit from '@tiptap/starter-kit';
import {
useEditor,
BubbleMenu,
EditorContent,
FloatingMenu,
} from '@tiptap/vue-3';
import { reactive } from 'vue';
import BaseModal from './BaseModal.vue';
defineProps<{
modelValue: boolean;
}>();
const editor = useEditor({
extensions: [StarterKit],
});
const tippyOptions = reactive({ duration: 200 });
</script>

<style lang="scss" scoped>
.editor {
width: 500px;
height: fit-content;
max-width: 90vw;
}
</style>
2 changes: 1 addition & 1 deletion kitsune-fe/src/graphql/types/fragment-masking.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {
ResultOf,
DocumentTypeDecoration,
ResultOf,
TypedDocumentNode,
} from '@graphql-typed-document-node/core';

Expand Down
Loading

0 comments on commit 72e6eef

Please sign in to comment.