1
0
resumarkdown/src/lib/components/preview.svelte

74 lines
1.5 KiB
Svelte
Raw Normal View History

2024-10-12 23:47:09 -05:00
<script lang="ts">
2024-10-16 12:36:50 -05:00
import { pane } from '$lib/stores/nav.js';
import renderPreview from '$lib/render-preview';
2024-10-12 23:47:09 -05:00
2024-10-16 12:36:50 -05:00
interface Props {
mobile?: boolean;
markdown: string;
stylesheet: string;
}
2024-10-12 23:47:09 -05:00
2024-10-16 12:36:50 -05:00
let { mobile = true, markdown, stylesheet }: Props = $props();
2024-10-12 23:47:09 -05:00
2024-10-16 12:36:50 -05:00
let hidden: boolean = $derived(mobile ? $pane !== 'preview' : true);
2024-10-16 15:23:51 -05:00
let output: Promise<string> = $derived(renderPreview(markdown, stylesheet));
2024-10-12 23:47:09 -05:00
</script>
<main class:hidden class:mobile data-testid="preview-pane">
2024-10-16 15:23:51 -05:00
{#await output}
<p>processing...</p>
{:then result}
<iframe title="résumé preview" srcdoc={result}></iframe>
2024-10-25 01:10:33 -05:00
<button>download</button>
2024-10-16 15:23:51 -05:00
{:catch err}
<p style:color="red">error: {err}!</p>
{/await}
2024-10-12 23:47:09 -05:00
</main>
<style lang="less">
main {
.container();
2024-10-25 01:10:33 -05:00
display: flex;
flex-flow: column nowrap;
gap: @padding-lg-y;
2024-10-12 23:47:09 -05:00
grid-area: preview;
2024-10-25 01:10:33 -05:00
button {
.selectable();
background-color: lighten(@color-dark, 10%);
border: 1px solid @color-dark;
border-radius: @border-r-xl;
color: @color-light;
font-weight: @font-w-semibold;
padding: @padding-md;
&:focus {
background-color: lighten(@color-dark, 20%);
}
&:hover {
background-color: lighten(@color-dark, 15%);
}
}
iframe {
.container-content();
}
2024-10-12 23:47:09 -05:00
&.mobile {
grid-area: editor;
&.hidden {
display: none;
}
}
2024-10-25 01:10:33 -05:00
@media screen and (min-width: @sizes[lg]) {
gap: @padding-xl-y;
}
2024-10-12 23:47:09 -05:00
}
</style>