mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-06 03:34:40 +00:00
refactor(component): abstract component selection from svelteRenderer function
This commit is contained in:
+3
-12
@@ -35,7 +35,8 @@ import coursesicon from '@/seqta/icons/coursesIcon'
|
|||||||
import iframeCSS from '@/css/iframe.scss?raw'
|
import iframeCSS from '@/css/iframe.scss?raw'
|
||||||
import injectedCSS from '@/css/injected.scss?inline'
|
import injectedCSS from '@/css/injected.scss?inline'
|
||||||
import documentLoadCSS from '@/css/documentload.scss?inline'
|
import documentLoadCSS from '@/css/documentload.scss?inline'
|
||||||
import initSvelteInterface from './svelte-interface/main'
|
import renderSvelte from '@/svelte-interface/main'
|
||||||
|
import Settings from '@/svelte-interface/pages/settings.svelte'
|
||||||
|
|
||||||
let SettingsClicked = false
|
let SettingsClicked = false
|
||||||
export let MenuOptionsOpen = false
|
export let MenuOptionsOpen = false
|
||||||
@@ -969,20 +970,10 @@ export function addExtensionSettings() {
|
|||||||
const extensionContainer = document.querySelector('#container') as HTMLDivElement
|
const extensionContainer = document.querySelector('#container') as HTMLDivElement
|
||||||
if (extensionContainer) extensionContainer.appendChild(extensionPopup)
|
if (extensionContainer) extensionContainer.appendChild(extensionPopup)
|
||||||
|
|
||||||
/* const extensionIframe: HTMLIFrameElement = document.createElement('iframe')
|
|
||||||
extensionIframe.src = `${browser.runtime.getURL('svelte-interface/index.html')}#settings/embedded`
|
|
||||||
extensionIframe.id = 'ExtensionIframe'
|
|
||||||
extensionIframe.setAttribute('allowTransparency', 'true')
|
|
||||||
extensionIframe.setAttribute('excludeDarkCheck', 'true')
|
|
||||||
extensionIframe.style.width = '384px'
|
|
||||||
extensionIframe.style.height = '100%'
|
|
||||||
extensionIframe.style.border = 'none'
|
|
||||||
extensionPopup.appendChild(extensionIframe) */
|
|
||||||
|
|
||||||
// create shadow dom and render svelte app
|
// create shadow dom and render svelte app
|
||||||
try {
|
try {
|
||||||
const shadow = extensionPopup.attachShadow({ mode: 'open' });
|
const shadow = extensionPopup.attachShadow({ mode: 'open' });
|
||||||
initSvelteInterface(shadow);
|
renderSvelte(Settings, shadow);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,10 @@
|
|||||||
selectedBackground
|
selectedBackground
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
loadBackgrounds();
|
loadBackgrounds();
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,24 @@
|
|||||||
// @ts-expect-error - Svelte Hash Router is not typed (yet)
|
|
||||||
import { routes } from 'svelte-hash-router'
|
|
||||||
//import App from './+layout.svelte';
|
|
||||||
import Settings from './pages/settings.svelte';
|
|
||||||
import styles from './index.css?inline';
|
import styles from './index.css?inline';
|
||||||
import { mount } from 'svelte';
|
import { mount } from 'svelte';
|
||||||
|
import type { ComponentType } from 'svelte';
|
||||||
|
|
||||||
export default function initSvelteInterface(mountPoint: ShadowRoot | HTMLElement) {
|
export default function renderSvelte(
|
||||||
/* routes.set({
|
Component: ComponentType,
|
||||||
'settings': Settings,
|
mountPoint: ShadowRoot | HTMLElement,
|
||||||
'*': Settings
|
props: Record<string, any> = {}
|
||||||
}) */
|
) {
|
||||||
|
const app = mount(Component, {
|
||||||
const app = mount(Settings, {
|
|
||||||
target: mountPoint,
|
target: mountPoint,
|
||||||
props: {
|
props: {
|
||||||
standalone: false
|
standalone: false,
|
||||||
|
...props
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const style2 = document.createElement("style");
|
const style = document.createElement("style");
|
||||||
style2.setAttribute("type", "text/css");
|
style.setAttribute("type", "text/css");
|
||||||
style2.innerHTML = styles;
|
style.innerHTML = styles;
|
||||||
mountPoint.appendChild(style2);
|
mountPoint.appendChild(style);
|
||||||
|
|
||||||
return app;
|
return app;
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
browser.runtime.sendMessage({ type: 'currentTab', info: 'OpenChangelog' });
|
browser.runtime.sendMessage({ type: 'currentTab', info: 'OpenChangelog' });
|
||||||
};
|
};
|
||||||
|
|
||||||
let { standalone } = $props<{ standalone: boolean }>();
|
let { standalone = false } = $props<{ standalone?: boolean }>();
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (!standalone) return;
|
if (!standalone) return;
|
||||||
|
|||||||
Reference in New Issue
Block a user