1
0
Fork 0
mirror of synced 2024-09-12 23:43:09 +12:00

Add font load event to allow the header to redraw as the fonts load

This commit is contained in:
Dean 2024-05-08 09:23:30 +01:00
parent 1ffe9bda6f
commit 31fccf23a8
2 changed files with 30 additions and 11 deletions

View file

@ -104,6 +104,10 @@
} }
onMount(async () => { onMount(async () => {
document.fonts.onloadingdone = e => {
builderStore.loadFonts(e.fontfaces)
}
if (!hasSynced && application) { if (!hasSynced && application) {
try { try {
await API.syncApp(application) await API.syncApp(application)
@ -144,17 +148,21 @@
/> />
</span> </span>
<Tabs {selected} size="M"> <Tabs {selected} size="M">
{#each $layout.children as { path, title }} {#key $builderStore?.fonts}
<TourWrap stepKeys={[`builder-${title}-section`]}> <span style="display:contents">
<Tab {#each $layout.children as { path, title }}
quiet <TourWrap stepKeys={[`builder-${title}-section`]}>
selected={$isActive(path)} <Tab
on:click={topItemNavigate(path)} quiet
title={capitalise(title)} selected={$isActive(path)}
id={`builder-${title}-tab`} on:click={topItemNavigate(path)}
/> title={capitalise(title)}
</TourWrap> id={`builder-${title}-tab`}
{/each} />
</TourWrap>
{/each}
</span>
{/key}
</Tabs> </Tabs>
</div> </div>
<div class="topcenternav"> <div class="topcenternav">

View file

@ -14,6 +14,7 @@ export const INITIAL_BUILDER_STATE = {
tourKey: null, tourKey: null,
tourStepKey: null, tourStepKey: null,
hoveredComponentId: null, hoveredComponentId: null,
fonts: null,
} }
export class BuilderStore extends BudiStore { export class BuilderStore extends BudiStore {
@ -36,6 +37,16 @@ export class BuilderStore extends BudiStore {
this.websocket this.websocket
} }
loadFonts(fontFaces) {
const ff = fontFaces.map(
fontFace => `${fontFace.family}-${fontFace.weight}`
)
this.update(state => ({
...state,
fonts: [...(state.fonts || []), ...ff],
}))
}
init(app) { init(app) {
if (!app?.appId) { if (!app?.appId) {
console.error("BuilderStore: No appId supplied for websocket") console.error("BuilderStore: No appId supplied for websocket")