diff options
| author | Mar0xy <marie@kaifa.ch> | 2023-10-06 02:32:09 +0200 |
|---|---|---|
| committer | Mar0xy <marie@kaifa.ch> | 2023-10-06 02:32:09 +0200 |
| commit | 4e6439763544f7b96009dd1411035343fb561d2a (patch) | |
| tree | 6f0d183391c27f383297ee1713e821ade4e60d20 /packages/frontend/src | |
| parent | merge: add speakAsCat extension and non-nya speech option (diff) | |
| download | sharkey-4e6439763544f7b96009dd1411035343fb561d2a.tar.gz sharkey-4e6439763544f7b96009dd1411035343fb561d2a.tar.bz2 sharkey-4e6439763544f7b96009dd1411035343fb561d2a.zip | |
add: profile backgrounds
Diffstat (limited to 'packages/frontend/src')
| -rw-r--r-- | packages/frontend/src/components/MkDrive.file.vue | 4 | ||||
| -rw-r--r-- | packages/frontend/src/pages/settings/profile.vue | 32 | ||||
| -rw-r--r-- | packages/frontend/src/pages/user/home.vue | 27 |
3 files changed, 62 insertions, 1 deletions
diff --git a/packages/frontend/src/components/MkDrive.file.vue b/packages/frontend/src/components/MkDrive.file.vue index 530859bc00..0b6bde2c3b 100644 --- a/packages/frontend/src/components/MkDrive.file.vue +++ b/packages/frontend/src/components/MkDrive.file.vue @@ -22,6 +22,10 @@ SPDX-License-Identifier: AGPL-3.0-only <img :class="$style.labelImg" src="/client-assets/label.svg"/> <p :class="$style.labelText">{{ i18n.ts.banner }}</p> </div> + <div v-if="$i?.backgroundId == file.id" :class="[$style.label]"> + <img :class="$style.labelImg" src="/client-assets/label.svg"/> + <p :class="$style.labelText">Background</p> + </div> <div v-if="file.isSensitive" :class="[$style.label, $style.red]"> <img :class="$style.labelImg" src="/client-assets/label-red.svg"/> <p :class="$style.labelText">{{ i18n.ts.sensitive }}</p> diff --git a/packages/frontend/src/pages/settings/profile.vue b/packages/frontend/src/pages/settings/profile.vue index 904ed03ee2..9533707784 100644 --- a/packages/frontend/src/pages/settings/profile.vue +++ b/packages/frontend/src/pages/settings/profile.vue @@ -10,9 +10,11 @@ SPDX-License-Identifier: AGPL-3.0-only <MkAvatar :class="$style.avatar" :user="$i" @click="changeAvatar"/> <MkButton primary rounded @click="changeAvatar">{{ i18n.ts._profile.changeAvatar }}</MkButton> </div> + <MkButton primary rounded :class="$style.backgroundEdit" @click="changeBackground">Change Background</MkButton> <MkButton primary rounded :class="$style.bannerEdit" @click="changeBanner">{{ i18n.ts._profile.changeBanner }}</MkButton> </div> + <MkInput v-model="profile.name" :max="30" manualSave> <template #label>{{ i18n.ts._profile.name }}</template> </MkInput> @@ -254,6 +256,31 @@ function changeBanner(ev) { }); } +function changeBackground(ev) { + selectFile(ev.currentTarget ?? ev.target, i18n.ts.banner).then(async (file) => { + let originalOrCropped = file; + + const { canceled } = await os.confirm({ + type: 'question', + text: i18n.t('cropImageAsk'), + okText: i18n.ts.cropYes, + cancelText: i18n.ts.cropNo, + }); + + if (!canceled) { + originalOrCropped = await os.cropImage(file, { + aspectRatio: 1, + }); + } + + const i = await os.apiWithDialog('i/update', { + backgroundId: originalOrCropped.id, + }); + $i.backgroundId = i.backgroundId; + $i.backgroundUrl = i.backgroundUrl; + }); +} + const headerActions = $computed(() => []); const headerTabs = $computed(() => []); @@ -292,6 +319,11 @@ definePageMetadata({ top: 16px; right: 16px; } +.backgroundEdit { + position: absolute; + top: 103px; + right: 16px; +} .metadataRoot { container-type: inline-size; diff --git a/packages/frontend/src/pages/user/home.vue b/packages/frontend/src/pages/user/home.vue index a4a4ac2fbf..2c81026de4 100644 --- a/packages/frontend/src/pages/user/home.vue +++ b/packages/frontend/src/pages/user/home.vue @@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only --> <template> -<MkSpacer :contentMax="narrow ? 800 : 1100"> +<MkSpacer :contentMax="narrow ? 800 : 1100" :style="background"> <div ref="rootEl" class="ftskorzw" :class="{ wide: !narrow }" style="container-type: inline-size;"> <div class="main _gaps"> <!-- TODO --> @@ -236,6 +236,13 @@ if (props.user.listenbrainz) { } } +const background = computed(() => { + if (props.user.backgroundUrl == null) return {}; + return { + '--backgroundImageStatic': `url('${props.user.backgroundUrl}')` + }; +}); + watch($$(moderationNote), async () => { await os.api('admin/update-user-note', { userId: props.user.id, text: moderationNote }); }); @@ -338,6 +345,24 @@ onUnmounted(() => { <style lang="scss" scoped> .ftskorzw { + &::before { + content: ""; + position: fixed; + inset: 0; + background: var(--backgroundImageStatic); + background-size: cover; + background-position: center; + pointer-events: none; + filter: blur(8px) opacity(0.6); + // Funny CSS schenanigans to make background escape container + padding-left: 20px; + margin-left: -20px; + padding-right: 20px; + margin-right: -20px; + padding-top: 20px; + margin-top: -20px; + background-attachment: fixed; + } > .main { |