Skip to content

Commit

Permalink
Fix/Performance: Toolbars use main css loading pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
GiovanH committed Mar 23, 2024
1 parent b998372 commit 4d2b4c2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 25 deletions.
4 changes: 2 additions & 2 deletions src/components/AppMenu/TabBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<AddressBar/>
<!-- Toolbars go here -->
<component v-for="(__, componentkey) in browserToolbars"
:is="componentkey" :key="componentkey" class="toolbar"/>
:is="componentkey" :key="componentkey" :data-component="componentkey" class="toolbar"/>
<div class="lineBreak"/>
</template>

Expand Down Expand Up @@ -50,7 +50,7 @@
<template v-if="!$localData.settings.showAddressBar">
<!-- Toolbars go here too (compact layout) -->
<component v-for="(__, componentkey) in browserToolbars"
:is="componentkey" :key="componentkey" class="toolbar"/>
:is="componentkey" :key="componentkey" :data-component="componentkey" class="toolbar"/>
</template>
<div />
</div>
Expand Down
23 changes: 0 additions & 23 deletions src/components/CustomContent/ModBrowserToolbarMixin.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const MediaEmbed = () => import('@/components/UIElements/MediaEmbed.vue')
const SpoilerBox = () => import('@/components/UIElements/SpoilerBox.vue')
const StoryPageLink = () => import('@/components/UIElements/StoryPageLink.vue')
const Sass = require('sass')
const GlobalComponents = {
NavBanner,
FlashCredit,
Expand All @@ -16,30 +14,9 @@ const GlobalComponents = {
StoryPageLink
}
var instances = 0
export default {
created(){
// this.$logger.info("MBP created")
this.$options.components = Object.assign(this.$options.components, GlobalComponents)
},
mounted() {
// this.$logger.info("MBP mounted")
instances += 1
if (this.$options.scss) {
this.$el.setAttribute('data-instance', instances)
const style = document.createElement("style")
style.id = `browsertoolbar-style-${instances}`
style.rel = "stylesheet"
style.innerHTML = Sass.renderSync({
data: `#tabBar .toolbar[data-instance='${instances}'] {\n${this.$options.scss}\n}`,
sourceComments: true
}).css.toString()
// this.$logger.info("MBP injected style")
this.$el.appendChild(style)
}
}
}
</script>
11 changes: 11 additions & 0 deletions src/mods.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,6 +901,17 @@ function getMainMixin(){
addScssStyle(style_id, sass_body)
}
})

const modToolbars = js.browserToolbars || {}
Object.entries(modToolbars).forEach((t, i) => {
const [componentTag, {component}] = t
// N.B. Unlike pages (which have URLs) toolbars are js-id namespaced.
if (component.scss) {
const style_id = `browsertoolbar-style-${js._id}-${componentTag}`
const sass_body = `#tabBar [data-component='${js._id}-${componentTag}'] {\n${component.scss}\n}`
addScssStyle(style_id, sass_body)
}
})
} catch (e) {
onModLoadFail([js._id], e)
}
Expand Down

0 comments on commit 4d2b4c2

Please sign in to comment.