mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
Merge branch 'main' of https://github.com/BetterSEQTA/BetterSEQTA-Plus
This commit is contained in:
@@ -3,6 +3,11 @@
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth";
|
||||
import CloudLoginForm from "./CloudLoginForm.svelte";
|
||||
|
||||
let { alwaysShowUserName = false } = $props<{
|
||||
/** When true (e.g. narrow extension popup), show display name below sm breakpoint */
|
||||
alwaysShowUserName?: boolean;
|
||||
}>();
|
||||
|
||||
let cloudState = $state(cloudAuth.state);
|
||||
let open = $state(false);
|
||||
let dropdownEl: HTMLElement;
|
||||
@@ -65,7 +70,11 @@
|
||||
{getInitials()}
|
||||
</div>
|
||||
{/if}
|
||||
<span class="hidden max-w-24 truncate sm:inline text-base">
|
||||
<span
|
||||
class={alwaysShowUserName
|
||||
? "inline max-w-[10rem] truncate text-sm"
|
||||
: "hidden max-w-24 truncate sm:inline text-base"}
|
||||
>
|
||||
{cloudState.user?.displayName || cloudState.user?.username || cloudState.user?.email || "User"}
|
||||
</span>
|
||||
{:else}
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
{/each}
|
||||
|
||||
{#if filteredThemes.length !== 0}
|
||||
<a href="https://betterseqta.gitbook.io/betterseqta-docs" class="block relative z-0 hover:z-20 w-full cursor-pointer">
|
||||
<a href="https://docs.betterseqta.org/theme-creation/" class="block relative z-0 hover:z-20 w-full cursor-pointer">
|
||||
<div class="bg-zinc-50 h-48 w-full transition-all duration-500 ease-out relative overflow-clip rounded-xl border group group/card flex flex-col justify-center items-center hover:scale-105 hover:shadow-2xl dark:hover:shadow-white/[0.1] hover:shadow-white/[0.8] dark:bg-zinc-800 dark:border-white/[0.1]">
|
||||
<div class="text-2xl font-IconFamily">{'\uecb3'}</div>
|
||||
<div class="text-xl font-bold text-center transition-all duration-500 dark:text-white">
|
||||
@@ -45,7 +45,7 @@
|
||||
<div class="absolute top-0 flex flex-col items-center justify-center w-full text-center h-96">
|
||||
<h1 class="mt-4 text-3xl font-bold tracking-tight text-zinc-900 dark:text-zinc-100 sm:text-5xl">That doesn't exist! 😭😭😭</h1>
|
||||
<p class="mt-6 text-lg leading-7 text-zinc-600 dark:text-zinc-300">Sorry, we couldn't find the theme you're looking for. Maybe... you could create it?</p>
|
||||
<a href="https://betterseqta.gitbook.io/betterseqta-docs" class='p-2 px-3 mt-4 transition rounded-md cursor-pointer dark:text-white bg-zinc-500/10 hover:scale-105'>
|
||||
<a href="https://docs.betterseqta.org/theme-creation/" class='p-2 px-3 mt-4 transition rounded-md cursor-pointer dark:text-white bg-zinc-500/10 hover:scale-105'>
|
||||
Show me how!
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import ColourPicker from "../components/ColourPicker.svelte";
|
||||
import DisclaimerModal from "../components/DisclaimerModal.svelte";
|
||||
import CloudHeader from "@/interface/components/store/CloudHeader.svelte";
|
||||
import { settingsPopup } from "../hooks/SettingsPopup";
|
||||
|
||||
let devModeSequence = "";
|
||||
@@ -276,6 +277,18 @@
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex shrink-0 items-center justify-between gap-2 px-3 py-2.5 border-b border-zinc-200/40 dark:border-zinc-700/40"
|
||||
>
|
||||
<div class="min-w-0 flex-1">
|
||||
<h2 class="text-sm font-bold text-zinc-900 dark:text-white">BetterSEQTA Cloud</h2>
|
||||
<p class="text-xs text-zinc-500 dark:text-zinc-400">Account & sync</p>
|
||||
</div>
|
||||
<div class="shrink-0">
|
||||
<CloudHeader alwaysShowUserName />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<TabbedContainer
|
||||
bind:activeTab={settingsActiveTab}
|
||||
tabs={[
|
||||
|
||||
@@ -289,7 +289,7 @@
|
||||
|
||||
|
||||
<h1 class='text-xl font-semibold'>Theme Creator</h1>
|
||||
<a href='https://betterseqta.gitbook.io/betterseqta-docs' target='_blank' class='text-sm font-light text-zinc-500 dark:text-zinc-400'>
|
||||
<a href='https://docs.betterseqta.org/theme-creation/' target='_blank' rel='noopener noreferrer' class='text-sm font-light text-zinc-500 dark:text-zinc-400'>
|
||||
<span class='pr-0.5 no-underline font-IconFamily'>{'\ueb44'}</span>
|
||||
<span class='underline'>
|
||||
Need help? Check out the docs!
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
import type { Plugin } from "@/plugins/core/types";
|
||||
import { componentSetting, defineSettings } from "@/plugins/core/settingsHelpers";
|
||||
import {
|
||||
booleanSetting,
|
||||
componentSetting,
|
||||
defineSettings,
|
||||
} from "@/plugins/core/settingsHelpers";
|
||||
import ProfilePictureSetting from "./ProfilePictureSetting.svelte";
|
||||
import { waitForElm } from "@/seqta/utils/waitForElm";
|
||||
import { cloudAuth } from "@/seqta/utils/CloudAuth";
|
||||
import styles from "./styles.css?inline";
|
||||
import localforage from "localforage";
|
||||
|
||||
const settings = defineSettings({
|
||||
useCloudPfp: booleanSetting({
|
||||
default: false,
|
||||
title: "Use BetterSEQTA Cloud profile picture",
|
||||
description:
|
||||
"When enabled, uses the avatar from your BetterSEQTA Cloud account (sign in from the extension store). Otherwise uses the uploaded image below.",
|
||||
}),
|
||||
picture: componentSetting({
|
||||
title: "Profile Picture",
|
||||
description: "Upload or remove your custom profile image",
|
||||
@@ -17,7 +28,7 @@ const profilePicturePlugin: Plugin<typeof settings> = {
|
||||
id: "profile-picture",
|
||||
name: "Custom Profile Picture",
|
||||
description: "Use your own image in place of the profile icon",
|
||||
version: "1.1.0",
|
||||
version: "1.2.0",
|
||||
settings: settings,
|
||||
disableToggle: true,
|
||||
defaultEnabled: false,
|
||||
@@ -36,14 +47,12 @@ const profilePicturePlugin: Plugin<typeof settings> = {
|
||||
let img: HTMLImageElement | null = null;
|
||||
let currentBlobUrl: string | undefined;
|
||||
|
||||
// Setup localforage instance
|
||||
const store = localforage.createInstance({
|
||||
name: "profile-picture-store",
|
||||
storeName: "profilePicture",
|
||||
});
|
||||
|
||||
async function updateImageFromStore() {
|
||||
// Remove old image if present
|
||||
async function applyProfileImage() {
|
||||
if (img) {
|
||||
img.remove();
|
||||
img = null;
|
||||
@@ -52,6 +61,19 @@ const profilePicturePlugin: Plugin<typeof settings> = {
|
||||
URL.revokeObjectURL(currentBlobUrl);
|
||||
currentBlobUrl = undefined;
|
||||
}
|
||||
|
||||
const useCloud = api.settings.useCloudPfp;
|
||||
const pfpUrl = cloudAuth.state.user?.pfpUrl;
|
||||
|
||||
if (useCloud && pfpUrl) {
|
||||
img = document.createElement("img");
|
||||
img.className = "userInfoImg";
|
||||
img.src = pfpUrl;
|
||||
if (svg) svg.style.display = "none";
|
||||
container.appendChild(img);
|
||||
return;
|
||||
}
|
||||
|
||||
const blob = await store.getItem<Blob>("profile-picture");
|
||||
if (blob && blob instanceof Blob) {
|
||||
currentBlobUrl = URL.createObjectURL(blob);
|
||||
@@ -65,15 +87,25 @@ const profilePicturePlugin: Plugin<typeof settings> = {
|
||||
}
|
||||
}
|
||||
|
||||
// Initial load
|
||||
await updateImageFromStore();
|
||||
await applyProfileImage();
|
||||
|
||||
// Listen for profile picture updates
|
||||
const handler = () => { updateImageFromStore(); };
|
||||
window.addEventListener('profile-picture-updated', handler);
|
||||
const onLocalPictureUpdated = () => {
|
||||
void applyProfileImage();
|
||||
};
|
||||
window.addEventListener("profile-picture-updated", onLocalPictureUpdated);
|
||||
|
||||
const cloudUnsub = cloudAuth.subscribe(() => {
|
||||
void applyProfileImage();
|
||||
});
|
||||
|
||||
const useCloudUnreg = api.settings.onChange("useCloudPfp", () => {
|
||||
void applyProfileImage();
|
||||
});
|
||||
|
||||
return () => {
|
||||
window.removeEventListener("profile-picture-updated", handler);
|
||||
useCloudUnreg.unregister();
|
||||
cloudUnsub();
|
||||
window.removeEventListener("profile-picture-updated", onLocalPictureUpdated);
|
||||
if (img) img.remove();
|
||||
if (svg) svg.style.display = "";
|
||||
if (currentBlobUrl) URL.revokeObjectURL(currentBlobUrl);
|
||||
|
||||
Reference in New Issue
Block a user