Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions src/components/Popup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
open: boolean
heading: string
text: string
expanded: boolean
}

export const popup_state = $state<PopupState>({
id: '',
open: false,
heading: '',
text: ''
text: '',
expanded: false
})

export function show_popup(data: Omit<PopupState, 'open'>) {
export function show_popup(data: Omit<PopupState, 'open' | 'expanded'>) {
popup_state.open = true
popup_state.id = data.id
popup_state.heading = data.heading
popup_state.text = data.text
popup_state.expanded = false
}

export function close_popup() {
Expand All @@ -29,7 +32,7 @@
<script lang="ts">
import { afterNavigate } from '$app/navigation'

import { faXmark } from '@fortawesome/free-solid-svg-icons'
import { faExpand, faXmark } from '@fortawesome/free-solid-svg-icons'
import Fa from 'svelte-fa'

afterNavigate(() => {
Expand All @@ -50,6 +53,10 @@
}

let popup = $state<HTMLElement | null>(null)

function toggle_expanded() {
popup_state.expanded = !popup_state.expanded
}
</script>

<svelte:document onkeydown={handle_keydown} />
Expand All @@ -60,10 +67,23 @@ In theory, it is better to use a <dialog> here, but Safari makes many
problems, Firefox does not display the native animation, and there is
an issue when clicking two proofs in a row. So it's a <div> then.
-->
<div class="popup" class:open={popup_state.open} bind:this={popup}>
<div
class="popup"
class:open={popup_state.open}
class:expanded={popup_state.expanded}
bind:this={popup}
>
<div class="content">
<header>
<h3>{popup_state.heading}</h3>

<button
onclick={toggle_expanded}
aria-label={popup_state.expanded ? 'collapse' : 'expand'}
>
<Fa icon={faExpand} />
</button>

<button onclick={close_popup} aria-label="close popup">
<Fa icon={faXmark} />
</button>
Expand Down Expand Up @@ -111,7 +131,12 @@ an issue when clicking two proofs in a row. So it's a <div> then.
visibility 0s;
}

.content {
.popup.expanded {
max-height: unset;
height: 100dvh;
}

.popup .content {
max-width: 800px;
margin: 0 auto;

Expand All @@ -121,14 +146,15 @@ an issue when clicking two proofs in a row. So it's a <div> then.
}
}

header {
.popup header {
margin-block: 0rem 1rem;
display: flex;
justify-content: space-between;
align-items: center;

h3 {
margin: 0;
margin-right: auto;
}

button {
Expand Down