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

Sidebar UX #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/components/Notebook.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
export let notebook: NotebookState;
</script>

<div class="space-y-3 pt-8 pb-24 px-3">
<div class="space-y-3 pt-8 pb-24 pl-6 pr-1">
{#each [...notebook] as [id, cell] (id)}
<CellDivider
on:create={(event) => {
Expand Down
35 changes: 19 additions & 16 deletions src/components/cell/Cell.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script lang="ts">
import { createEventDispatcher } from "svelte";
import { fade } from "svelte/transition";
import FaChevronDown from "svelte-icons/fa/FaChevronDown.svelte";
import FaChevronRight from "svelte-icons/fa/FaChevronRight.svelte";
import FaTrashAlt from "svelte-icons/fa/FaTrashAlt.svelte";

Expand All @@ -12,23 +11,21 @@
const dispatch = createEventDispatcher();

export let state: CellState;

function toggleDisplayInput() {
dispatch("toggle");
}
</script>

<div class="cell" transition:fade>
<button class="sidebar" on:click={() => dispatch("toggle")}>
<div class="w-4 h-4">
{#if state.hidden}
<FaChevronRight />
{:else}
<FaChevronDown />
{/if}
<button class="sidebar" on:click={toggleDisplayInput}>
<div class="mb-3" class:rotate-90={!state.hidden}>
<FaChevronRight />
</div>
<button
class="w-4 h-4 text-gray-400 hover:text-red-600 transition-colors"
on:click={(event) => {
event.stopPropagation();
dispatch("delete");
}}
class="text-gray-400 hover:text-red-600 transition-colors"
class:hidden={state.hidden}
on:click|stopPropagation={() => dispatch("delete")}
>
<FaTrashAlt />
</button>
Expand All @@ -39,16 +36,22 @@

<style lang="postcss">
.cell {
@apply relative min-h-[32px] my-0;
@apply relative min-h-[32px] my-0 pl-0.5;
}

.cell:hover .sidebar {
@apply opacity-100;
}

.sidebar {
@apply absolute h-full left-[-2000px] w-[2000px]
flex justify-end items-start space-x-2 py-2 pr-3
left: calc(-50vw + 50% - 0.6rem);
width: calc(50vw - 50% + 0.6rem);
@apply absolute h-full
flex flex-col justify-start items-end space-y-2 p-1 pt-2 border-r-2 hover:border-gray-300
transition-all hover:bg-zinc-50 opacity-0 text-gray-400 hover:text-gray-800;
}

.sidebar > * {
@apply w-4 h-4 transition-all;
}
</style>