Skip to content

Commit

Permalink
Import and inject global styles using vite's style.css?inline feature
Browse files Browse the repository at this point in the history
  • Loading branch information
myieye committed Oct 11, 2024
1 parent 7127e3d commit 86bad4e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 19 deletions.
1 change: 0 additions & 1 deletion frontend/viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"main": "dist-web-component/viewer.js",
"exports": {
"./component": "./dist-web-component/viewer.js",
"./style": "./dist-web-component/style.css",
"./lexbox-api": "./src/lib/services/lexbox-api.ts",
"./service-provider": "./src/lib/services/service-provider.ts"
},
Expand Down
9 changes: 4 additions & 5 deletions frontend/viewer/src/WebComponent.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { onMount } from 'svelte';
import ProjectView from './ProjectView.svelte';
import { fixBrokenNestedGlobalStyles } from './lib/utils/style-fix';
import { getSettings } from 'svelte-ux';
import css from './app.postcss?inline';
let loading = true;
Expand All @@ -11,7 +11,6 @@
onMount(() => {
const shadowRoot = document.querySelector('lexbox-svelte')?.shadowRoot;
if (!shadowRoot) throw new Error('Could not find shadow root');
fixBrokenNestedGlobalStyles(shadowRoot);
const abortController = new AbortController();
window.addEventListener('popstate', () => {
Expand Down Expand Up @@ -39,9 +38,9 @@

<svelte:options customElement={{ tag: 'lexbox-svelte' }} />

<style global lang="postcss">
@import './app.postcss';
</style>
<svelte:element this="style">
${css}
</svelte:element>

<div class="app contents" class:dark={$currentTheme.dark}>
<ProjectView {projectName} isConnected {loading} showHomeButton={false} />
Expand Down
13 changes: 0 additions & 13 deletions frontend/viewer/src/lib/utils/style-fix.ts

This file was deleted.

0 comments on commit 86bad4e

Please sign in to comment.