Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added a collapsable modal pane hide button #97

Closed
Closed
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
33 changes: 28 additions & 5 deletions src/components/navigation/ModalPane.svelte
Original file line number Diff line number Diff line change
@@ -1,32 +1,48 @@
<script>
import { fly } from 'svelte/transition';
import { FontAwesomeIcon } from '@fortawesome/svelte-fontawesome';
import { faX } from '@fortawesome/free-solid-svg-icons';
import { faX, faChevronDown, faChevronUp } from '@fortawesome/free-solid-svg-icons';
import { keybinding } from '$lib/keybinding';
import { createEventDispatcher } from 'svelte';
import { pushState } from '$app/navigation';

const dispatch = createEventDispatcher();
let collapsed = false;

function closePane() {
pushState('/');
dispatch('close');
}

function toggleCollapse() {
collapsed = !collapsed;
}
</script>

<div
class="modal-pane pointer-events-auto h-full rounded-b-none px-4"
class="modal-pane transition-height px-4 rounded-b-none pointer-events-auto"
class:collapsed
in:fly={{ y: 200, duration: 500 }}
out:fly={{ y: 200, duration: 500 }}
>
<div class="py-1 text-right">
<div class="flex items-center justify-end py-3">
{#key collapsed}
<button
type="button"
on:click={toggleCollapse}
class="collapse-button dark:text-white text-lg font-black text-black"
>
<FontAwesomeIcon icon={collapsed ? faChevronDown : faChevronUp} />
<span class="sr-only">{collapsed ? 'Expand' : 'Collapse'}</span>
</button>
{/key}
<button
type="button"
on:click={closePane}
use:keybinding={{ code: 'Escape' }}
class="close-button"
>
<FontAwesomeIcon icon={faX} class="font-black text-black dark:text-white" />
<FontAwesomeIcon icon={faX} class="dark:text-white font-black text-black" />
<span class="sr-only">Close</span>
</button>
</div>
Expand All @@ -37,7 +53,14 @@
</div>

<style lang="postcss">
.close-button {
.modal-pane {
@apply h-full rounded-b-none;
}
.modal-pane.collapsed {
@apply h-16 rounded-b-lg;
overflow: hidden;
}
.close-button, .collapse-button {
@apply rounded px-4 py-2;
@apply transition duration-300 ease-in-out hover:bg-neutral-200 dark:hover:bg-neutral-200/50;
}
Expand Down
Loading