mirror of
https://github.com/versia-pub/frontend.git
synced 2025-12-06 08:28:20 +01:00
feat: ✨ Add ability to set custom background images
This commit is contained in:
parent
862839bf34
commit
093ae627b9
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<input :class="['block disabled:opacity-70 disabled:hover:cursor-wait w-full bg-dark-500 rounded-md border-0 py-1.5 text-gray-50 shadow-sm ring-1 ring-inset ring-white/10 placeholder:text-gray-500 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6',
|
<input :class="['block disabled:opacity-70 disabled:hover:cursor-wait w-full bg-dark-500 rounded-md border-0 py-1.5 text-gray-50 shadow-sm ring-1 ring-inset ring-white/10 placeholder:text-gray-500 focus:ring-2 focus:ring-inset focus:ring-primary-600 sm:text-sm sm:leading-6',
|
||||||
isInvalid && '!ring-red-600 ring-2']">
|
isInvalid && '!ring-red-600 ring-2']" v-model="value">
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
@ -10,5 +10,7 @@ interface Props extends /* @vue-ignore */ InputHTMLAttributes {
|
||||||
isInvalid?: boolean;
|
isInvalid?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const value = defineModel<string>("value");
|
||||||
|
|
||||||
defineProps<Props>();
|
defineProps<Props>();
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
<SettingCode v-else-if="setting.type === SettingType.Code" :id="id" />
|
<SettingCode v-else-if="setting.type === SettingType.Code" :id="id" />
|
||||||
<SettingEnum v-else-if="setting.type === SettingType.Enum" :id="id" />
|
<SettingEnum v-else-if="setting.type === SettingType.Enum" :id="id" />
|
||||||
|
<SettingString v-else-if="setting.type === SettingType.String" :id="id" />
|
||||||
<SettingOther v-else :id="id" />
|
<SettingOther v-else :id="id" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -16,6 +17,7 @@ import SettingBoolean from "./types/Boolean.vue";
|
||||||
import SettingCode from "./types/Code.vue";
|
import SettingCode from "./types/Code.vue";
|
||||||
import SettingEnum from "./types/Enum.vue";
|
import SettingEnum from "./types/Enum.vue";
|
||||||
import SettingOther from "./types/Other.vue";
|
import SettingOther from "./types/Other.vue";
|
||||||
|
import SettingString from "./types/String.vue";
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
id: SettingIds;
|
id: SettingIds;
|
||||||
|
|
|
||||||
25
components/settings/types/String.vue
Normal file
25
components/settings/types/String.vue
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
<template>
|
||||||
|
<div class="flex flex-col gap-y-1">
|
||||||
|
<h4 class="row-start-1 select-none text-base/6 sm:text-sm/6 text-white font-semibold">{{ setting.title
|
||||||
|
}}
|
||||||
|
</h4>
|
||||||
|
<TextInput v-model:value="content" class="w-full md:w-auto min-w-72" />
|
||||||
|
<p v-if="setting.description" class="text-xs mt-2 text-gray-400">{{ setting.description }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import TextInput from "~/components/inputs/text-input.vue";
|
||||||
|
import type { SettingIds } from "~/settings";
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
id: SettingIds;
|
||||||
|
}>();
|
||||||
|
|
||||||
|
const setting = useSetting(props.id);
|
||||||
|
const content = ref(setting.value.value as string);
|
||||||
|
|
||||||
|
watch(content, (c) => {
|
||||||
|
setting.value.value = c;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
@ -15,9 +15,9 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||||
// slides in and out from the left or right
|
// slides in and out from the left or right
|
||||||
import type { HTMLAttributes } from "vue";
|
import type { HTMLAttributes } from "vue";
|
||||||
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
|
||||||
|
|
||||||
interface Props extends /* @vue-ignore */ HTMLAttributes {
|
interface Props extends /* @vue-ignore */ HTMLAttributes {
|
||||||
direction?: "left" | "right";
|
direction?: "left" | "right";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<!-- Timeline.vue -->
|
<!-- Timeline.vue -->
|
||||||
<template>
|
<template>
|
||||||
<div class="timeline">
|
<div class="timeline rounded overflow-hidden">
|
||||||
<TransitionGroup name="timeline-item" tag="div" class="timeline-items">
|
<TransitionGroup name="timeline-item" tag="div" class="timeline-items">
|
||||||
<TimelineItem :type="type" v-for="item in items" :key="item.id" :item="item" @update="updateItem"
|
<TimelineItem :type="type" v-for="item in items" :key="item.id" :item="item" @update="updateItem"
|
||||||
@delete="removeItem" />
|
@delete="removeItem" />
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="from-dark-600 to-dark-900 bg-gradient-to-tl relative min-h-dvh">
|
<div class="from-dark-600 to-dark-900 bg-gradient-to-tl relative min-h-dvh" :style="{
|
||||||
<SquarePattern />
|
backgroundImage: canParseURL(backgroundImage.value as string) ? `url(${backgroundImage.value})` : undefined,
|
||||||
|
backgroundSize: 'cover',
|
||||||
|
backgroundPosition: 'center',
|
||||||
|
backgroundRepeat: 'no-repeat',
|
||||||
|
}">
|
||||||
|
<SquarePattern v-if="!canParseURL(backgroundImage.value as string)" />
|
||||||
<Navigation />
|
<Navigation />
|
||||||
|
|
||||||
<div class="relative md:pl-20 min-h-dvh flex flex-row overflow-hidden justify-center xl:justify-between">
|
<div class="relative md:pl-20 min-h-dvh flex flex-row overflow-hidden justify-center xl:justify-between">
|
||||||
|
|
@ -20,6 +25,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
||||||
import ComposerModal from "~/components/composer/modal.client.vue";
|
import ComposerModal from "~/components/composer/modal.client.vue";
|
||||||
import SquarePattern from "~/components/graphics/square-pattern.vue";
|
import SquarePattern from "~/components/graphics/square-pattern.vue";
|
||||||
import CollapsibleAside from "~/components/sidebars/collapsible-aside.vue";
|
import CollapsibleAside from "~/components/sidebars/collapsible-aside.vue";
|
||||||
|
|
@ -27,7 +33,7 @@ import Navigation from "~/components/sidebars/navigation.vue";
|
||||||
import AttachmentDialog from "~/components/social-elements/notes/attachment-dialog.vue";
|
import AttachmentDialog from "~/components/social-elements/notes/attachment-dialog.vue";
|
||||||
import Notifications from "~/components/timelines/notifications.vue";
|
import Notifications from "~/components/timelines/notifications.vue";
|
||||||
import TimelineScroller from "~/components/timelines/timeline-scroller.vue";
|
import TimelineScroller from "~/components/timelines/timeline-scroller.vue";
|
||||||
import { OverlayScrollbarsComponent } from "overlayscrollbars-vue";
|
import { SettingIds } from "~/settings";
|
||||||
const { width } = useWindowSize();
|
const { width } = useWindowSize();
|
||||||
|
|
||||||
const { n } = useMagicKeys();
|
const { n } = useMagicKeys();
|
||||||
|
|
@ -37,6 +43,15 @@ const notUsingInput = computed(
|
||||||
activeElement.value?.tagName !== "INPUT" &&
|
activeElement.value?.tagName !== "INPUT" &&
|
||||||
activeElement.value?.tagName !== "TEXTAREA",
|
activeElement.value?.tagName !== "TEXTAREA",
|
||||||
);
|
);
|
||||||
|
const backgroundImage = useSetting(SettingIds.BackgroundURL);
|
||||||
|
const canParseURL: (url: string) => boolean = (url) => {
|
||||||
|
try {
|
||||||
|
new URL(url);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
watchEffect(async () => {
|
watchEffect(async () => {
|
||||||
if (n?.value && notUsingInput.value) {
|
if (n?.value && notUsingInput.value) {
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@ export enum SettingIds {
|
||||||
ConfirmReblog = "confirm-reblog",
|
ConfirmReblog = "confirm-reblog",
|
||||||
ConfirmFavourite = "confirm-favourite",
|
ConfirmFavourite = "confirm-favourite",
|
||||||
EmojiTheme = "emoji-theme",
|
EmojiTheme = "emoji-theme",
|
||||||
|
BackgroundURL = "background-url",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const settings: Record<SettingIds, Setting> = {
|
export const settings: Record<SettingIds, Setting> = {
|
||||||
|
|
@ -210,6 +211,13 @@ export const settings: Record<SettingIds, Setting> = {
|
||||||
],
|
],
|
||||||
page: SettingPages.Appearance,
|
page: SettingPages.Appearance,
|
||||||
} as EnumSetting,
|
} as EnumSetting,
|
||||||
|
[SettingIds.BackgroundURL]: {
|
||||||
|
title: "Background URL",
|
||||||
|
description: "Change the background image of the site.",
|
||||||
|
type: SettingType.String,
|
||||||
|
value: "",
|
||||||
|
page: SettingPages.Appearance,
|
||||||
|
} as StringSetting,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSettingsForPage = (page: SettingPages): Partial<Settings> => {
|
export const getSettingsForPage = (page: SettingPages): Partial<Settings> => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue