feat: editor sidebar can resize and hidden now by ACTCD · Pull Request #844 · quoid/userscripts · GitHub
Skip to content
Merged
77 changes: 74 additions & 3 deletions src/ext/extension-page/App.svelte
23 changes: 21 additions & 2 deletions src/ext/extension-page/Components/Editor/Editor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import iconDownload from "@shared/img/icon-download.svg?raw";
import iconTrash from "@shared/img/icon-trash.svg?raw";
import iconSync from "@shared/img/icon-sync.svg?raw";
import iconSidebar from "@shared/img/icon-sidebar.svg?raw";

export let sidebarHidden;
export let sidebarSwitch;

// the data the populates editor elements
let canUpdate;
Expand Down Expand Up @@ -167,13 +171,22 @@
<div class="editor__empty">No Item Selected</div>
{/if}
<div class="editor__header">
{#if sidebarHidden}
<div class="sidebar-switch">
<IconButton
icon={iconSidebar}
on:click={sidebarSwitch}
title="Show sidebar"
/>
</div>
{/if}
<div class="editor__header__content">
<div>
<Tag {type} />
<div class="editor__title truncate">{name}</div>
</div>
<div class="editor__status">
<div>
<div class="truncate">
{#if $v4state.includes("saving")}
Saving...
{:else if $v4state.includes("trashing")}
Expand Down Expand Up @@ -233,6 +246,7 @@
flex-grow: 1;
overflow: hidden;
position: relative;
width: calc(100svw - var(--sidebar-width));
Comment thread
ACTCD marked this conversation as resolved.
}

.info {
Expand Down Expand Up @@ -260,7 +274,12 @@
align-items: center;
display: flex;
flex-shrink: 0;
padding: 1rem 0.5rem 1rem 1.5rem;
padding: 1rem;
gap: 1rem;
}

.sidebar-switch {
scale: 1.5;
}

.editor__header__content {
Expand Down
33 changes: 22 additions & 11 deletions src/ext/extension-page/Components/Sidebar/Sidebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
import Loader from "@shared/Components/Loader.svelte";
import iconPlus from "@shared/img/icon-plus.svg?raw";
import iconSettings from "@shared/img/icon-settings.svg?raw";
import iconSidebar from "@shared/img/icon-sidebar.svg?raw";
import {
cmChanged,
cmGetInstance,
cmSetSavedCode,
cmSetSessionCode,
} from "../Editor/CodeMirror.svelte";

export let sidebarSwitch;

// disable buttons accordingly
$: disabled = !$v4state.includes("ready");

Expand All @@ -30,6 +33,8 @@
$: if (list.find((a) => a.active)) {
const active = list.find((a) => a.active);
scrollToEl(active.filename);
} else {
activate(list[0]);
}

/**
Expand Down Expand Up @@ -204,11 +209,17 @@
</script>

<div
class="sidebar {!$settings['editor_list_descriptions']
? 'sidebar--compact'
: ''}"
class="sidebar"
class:sidebar--compact={!$settings["editor_list_descriptions"]}
>
<div class="sidebar__header">
<div class="sidebar-switch">
<IconButton
icon={iconSidebar}
on:click={sidebarSwitch}
title="Hide sidebar"
/>
</div>
<div class="sidebar__filter"><SidebarFilter /></div>
<IconButton
warnDot={!$settings["global_active"]}
Expand All @@ -217,7 +228,7 @@
title="Open settings"
{disabled}
/>
<Dropdown icon={iconPlus} title="New item" {disabled}>
<Dropdown icon={iconPlus} title="New item" {disabled} right>
<button on:click={() => newItem("js")}>New JS</button>
<button on:click={() => newItem("css")}>New CSS</button>
<button on:click={newRemote}>New Remote</button>
Expand Down Expand Up @@ -250,27 +261,27 @@
border-right: 1px solid var(--border-color);
display: flex;
flex-direction: column;
flex: 0 0 23rem;
max-width: 23rem;
width: var(--sidebar-width);
min-width: var(--sidebar-min-width);
position: relative;
}

.sidebar-switch {
scale: 1.5;
}

.sidebar__header {
align-items: center;
display: flex;
flex-shrink: 0;
flex-wrap: wrap;
padding: 1rem;
gap: 0.5rem;
}

.sidebar__filter {
flex-grow: 1;
}

:global(.sidebar__filter + button) {
margin: 0 0.5rem;
}

.sidebar__count {
backdrop-filter: blur(3px);
-webkit-backdrop-filter: blur(3px);
Expand Down
5 changes: 4 additions & 1 deletion src/ext/extension-page/Components/Sidebar/SidebarItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
<Toggle checked={!data.disabled} on:click={toggleClick} />
</div>
{#if description}
<div class="item__description" title={showTitle ? data.description : null}>
<div
class="item__description truncate"
title={showTitle ? data.description : null}
>
{description}
</div>
{/if}
Expand Down
1 change: 1 addition & 0 deletions src/shared/Components/IconButton.svelte
1 change: 1 addition & 0 deletions src/shared/img/icon-sidebar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.