Skip to content
Snippets Groups Projects
Commit ac38136b authored by David Smadja's avatar David Smadja
Browse files

rename billHTML to pjlHTMl

parent babae150
No related branches found
No related tags found
No related merge requests found
<script lang="ts">
import BillSummary from "$lib/components/BillSummary.svelte"
interface Props {
billHTML: string | undefined
pjlHTML: string | undefined
}
let container: HTMLDivElement | undefined = $state()
let { billHTML }: Props = $props()
let { pjlHTML }: Props = $props()
let resizeObserver: ResizeObserver
const baseWidth = 800
......@@ -50,12 +50,12 @@
}
$effect(() => {
if (!container || !billHTML) return
if (!container || !pjlHTML) return
if (!container.shadowRoot) {
const shadow = container.attachShadow({ mode: "open" })
const processedHTML = billHTML.replace(
const processedHTML = pjlHTML.replace(
/<img([^>]*)width="([^"]+)"([^>]*)>/g,
(match, before, width, after) => {
return `<img ${before} width="${width}" data-original-width="${width}" ${after}>`
......@@ -112,13 +112,13 @@
})
} else {
const wrapper = container.shadowRoot!.querySelector(".content-wrapper")
if (wrapper) wrapper.innerHTML = billHTML
if (wrapper) wrapper.innerHTML = pjlHTML
}
return () => resizeObserver?.disconnect()
})
</script>
<div class="flex h-full w-full flex-col">
<BillSummary {billHTML} {container} />
<BillSummary {pjlHTML} {container} />
<div bind:this={container} class="flex-1 overflow-auto"></div>
</div>
<script lang="ts">
interface Props {
billHTML: string | undefined
pjlHTML: string | undefined
container: HTMLDivElement | undefined
}
let { billHTML, container }: Props = $props()
let { pjlHTML, container }: Props = $props()
let summaryItems = $state<{ id: string; text: string; level: number }[]>([])
let summaryIsOpen = $state(false)
......@@ -72,8 +72,8 @@
}
$effect(() => {
if (!billHTML) return
summaryItems = extractAnchors(billHTML)
if (!pjlHTML) return
summaryItems = extractAnchors(pjlHTML)
})
$effect(() => {
if (!container) return
......
......@@ -14,7 +14,7 @@
let articleJson: LegiArticle | undefined = $state(undefined)
let lawArticle = $derived(page.url.searchParams.get("lawArticle") || "")
let billHTML = $state(data.billHTML)
let pjlHTML = $state(data.pjlHTML)
$effect(() => {
if (lawArticle) {
......@@ -34,7 +34,9 @@
<svelte:window bind:innerWidth={screenWidth} />
<div class="fixed flex min-h-full w-full flex-row overflow-hidden">
<div class="h-screen w-1/2 overflow-y-auto"><Bill {billHTML}></Bill></div>
<div class="h-screen w-1/2 overflow-y-auto">
<Bill {pjlHTML}></Bill>
</div>
<div class="h-screen w-1/2 overflow-y-auto bg-blue-100">
{#if isFetchingArticle}
Article en cours de récupération...
......
......@@ -3,7 +3,7 @@ import type { PageLoad } from "./$types"
export const load: PageLoad = async ({
fetch,
params,
}): Promise<{ billHTML: string | undefined }> => {
}): Promise<{ pjlHTML: string | undefined }> => {
const pjl = params.pjl
if (pjl !== undefined) {
......@@ -16,11 +16,11 @@ export const load: PageLoad = async ({
})
if (!res.ok) {
console.error(`Error ${res.status} while retrieving bill content.}`)
return { billHTML: undefined }
return { pjlHTML: undefined }
} else {
const billHTML = await res.text()
return { billHTML }
const pjlHTML = await res.text()
return { pjlHTML: pjlHTML }
}
}
return { billHTML: undefined }
return { pjlHTML: undefined }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment