2023-10-24 21:41:04 +02:00
|
|
|
<script lang="ts">
|
2023-11-09 16:30:26 +01:00
|
|
|
import nmd from "nano-markdown"
|
|
|
|
import { createEventDispatcher } from "svelte"
|
|
|
|
import WalkthroughStep from "./WalkthroughStep.svelte"
|
|
|
|
import FromHtml from "../Base/FromHtml.svelte"
|
2023-10-24 21:41:04 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Markdown
|
|
|
|
*/
|
2023-11-09 16:30:26 +01:00
|
|
|
export let pages: string[]
|
2023-10-24 21:41:04 +02:00
|
|
|
|
2023-11-09 16:30:26 +01:00
|
|
|
let currentPage: number = 0
|
2023-10-24 21:41:04 +02:00
|
|
|
|
2023-11-09 16:30:26 +01:00
|
|
|
const dispatch = createEventDispatcher<{ done }>()
|
2023-10-24 21:41:04 +02:00
|
|
|
|
|
|
|
function step(incr: number) {
|
|
|
|
if (incr > 0 && currentPage + 1 === pages.length) {
|
2023-11-09 16:30:26 +01:00
|
|
|
dispatch("done")
|
2023-10-24 21:41:04 +02:00
|
|
|
currentPage = 0
|
|
|
|
return
|
|
|
|
}
|
2023-11-09 16:30:26 +01:00
|
|
|
currentPage = Math.min(Math.max(0, currentPage + incr), pages.length)
|
2023-10-24 21:41:04 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2023-11-09 16:30:26 +01:00
|
|
|
<WalkthroughStep
|
|
|
|
on:back={() => step(-1)}
|
|
|
|
on:next={() => step(1)}
|
|
|
|
isFirst={currentPage === 0}
|
|
|
|
islast={currentPage + 1 === pages.length}
|
2023-11-17 01:59:41 +01:00
|
|
|
totalPages={pages.length}
|
|
|
|
pageNumber={currentPage}
|
2023-11-09 16:30:26 +01:00
|
|
|
>
|
2023-10-24 21:41:04 +02:00
|
|
|
<FromHtml src={nmd(pages[currentPage])} />
|
|
|
|
</WalkthroughStep>
|