Skip to content

Commit

Permalink
feat: Explorer panel (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
areknawo committed Oct 27, 2023
1 parent aa6a0c5 commit 0916e1f
Show file tree
Hide file tree
Showing 11 changed files with 666 additions and 68 deletions.
4 changes: 3 additions & 1 deletion apps/web/src/layout/side-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { SettingsView } from "#views/settings";
import { ExtensionsView } from "#views/extensions";
import { GettingStartedView } from "#views/getting-started";
import { GitView } from "#views/git";
import { ExplorerView } from "#views/explorer";

const sidePanelViews: Record<string, Component<Record<string, any>>> = {
contentPiece: ContentPieceView,
Expand All @@ -31,7 +32,8 @@ const sidePanelViews: Record<string, Component<Record<string, any>>> = {
</Show>
);
},
default: GettingStartedView
default: GettingStartedView,
explorer: ExplorerView
};
const SidePanel: Component = () => {
const { storage, setStorage } = useLocalStorage();
Expand Down
12 changes: 11 additions & 1 deletion apps/web/src/layout/sidebar-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
mdiHelpCircle,
mdiPuzzle,
mdiMicrosoftXboxControllerMenu,
mdiGit
mdiGit,
mdiFileMultiple
} from "@mdi/js";
import { Accessor, Component, For, Show, createEffect, createSignal, on } from "solid-js";
import { Link, useLocation, useNavigate } from "@solidjs/router";
Expand Down Expand Up @@ -91,6 +92,15 @@ const useMenuItems = (): Accessor<Array<MenuItem | null>> => {
}
},
null,
{
icon: mdiFileMultiple,
label: "Explorer",
inMenu: true,
active: () => storage().sidePanelView === "explorer",
onClick: () => {
setSidePanelView("explorer");
}
},
hostConfig.githubApp && {
icon: mdiGit,
label: "Source control",
Expand Down
18 changes: 0 additions & 18 deletions apps/web/src/layout/toolbar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { UserList } from "./user-list";
import { Breadcrumb } from "./breadcrumb";
import {
mdiAppleKeyboardCommand,
mdiBookOpenBlankVariant,
Expand Down Expand Up @@ -313,22 +312,11 @@ const toolbarViews: Record<string, Component<Record<string, any>>> = {
const { storage, setStorage } = useLocalStorage();
const { setOpened, registerCommand } = useCommandPalette();
const [provider] = createSharedSignal("provider");
const [activeDraggableGroup] = createSharedSignal("activeDraggableGroup");
const [activeDraggablePiece] = createSharedSignal("activeDraggablePiece");
const [viewSelectorOpened, setViewSelectorOpened] = createSignal(false);
const view = (): string => storage().dashboardView || "kanban";
const setView = (view: string): void => {
setStorage((storage) => ({ ...storage, dashboardView: view }));
};
const ancestor = (): App.ContentGroup | null => {
return storage().dashboardViewAncestor || null;
};
const setAncestor = (ancestor: App.ContentGroup | null): void => {
setStorage((storage) => ({
...storage,
dashboardViewAncestor: ancestor || undefined
}));
};

createEffect(() => {
if (view() === "list") {
Expand Down Expand Up @@ -391,12 +379,6 @@ const toolbarViews: Record<string, Component<Record<string, any>>> = {
/>
</div>
</Dropdown>
<Breadcrumb
ancestor={ancestor()}
activeDraggableGroup={activeDraggableGroup()}
activeDraggablePiece={activeDraggablePiece()}
setAncestor={setAncestor}
/>
<div class="flex-1" />
<Show when={provider()}>
<UserList provider={provider()!} />
Expand Down
8 changes: 0 additions & 8 deletions apps/web/src/views/content-piece/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,6 @@ const ContentPieceView: Component = () => {
activeSection={activeSection()}
setActiveSection={setActiveSection}
/>
<ContentPieceDescription
descriptionExists={typeof contentPiece()?.description === "string"}
initialDescription={descriptionInitialValue()}
editable={editable()}
setDescription={(description) => {
handleChange({ description });
}}
/>
</div>
</Card>
</Show>
Expand Down
55 changes: 44 additions & 11 deletions apps/web/src/views/content-piece/metadata.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { DetailsSection, CustomDataSection, ExtensionsSection, VariantsSection } from "./sections";
import { ContentPieceDescription } from "./description";
import { mdiMenu } from "@mdi/js";
import { Component, createSignal, For, Switch, Match } from "solid-js";
import { Component, createSignal, For, Switch, Match, onMount } from "solid-js";
import { App, useHostConfig } from "#context";
import { Dropdown, IconButton, Heading } from "#components/primitives";
import { createRef } from "#lib/utils";

interface ContentPieceMetadataSection {
label: string;
Expand All @@ -26,6 +28,21 @@ interface ContentPieceMetadataProps {
const ContentPieceMetadata: Component<ContentPieceMetadataProps> = (props) => {
const hostConfig = useHostConfig();
const [menuOpened, setMenuOpened] = createSignal(false);
const [scrollableSectionRef, setScrollableSectionRef] = createRef<HTMLDivElement | null>(null);

onMount(() => {
const scrollableSection = scrollableSectionRef();

if (!scrollableSection) return;

scrollableSection.addEventListener("scroll", (event) => {
const sectionIndex = Math.round(
(scrollableSection.scrollLeft / scrollableSection.scrollWidth) * 4
);

props.setActiveSection(props.sections[sectionIndex]);
});
});

return (
<>
Expand Down Expand Up @@ -58,6 +75,11 @@ const ContentPieceMetadata: Component<ContentPieceMetadataProps> = (props) => {
path={section.icon}
onClick={() => {
props.setActiveSection(section);
scrollableSectionRef()?.scrollTo({
behavior: "smooth",
left:
scrollableSectionRef()!.scrollWidth * (props.sections.indexOf(section) / 4)
});
setMenuOpened(false);
}}
></IconButton>
Expand All @@ -66,8 +88,11 @@ const ContentPieceMetadata: Component<ContentPieceMetadataProps> = (props) => {
</For>
</div>
</Dropdown>
<Switch>
<Match when={props.activeSection.id === "details"}>
<div
class="flex w-full gap-1 overflow-auto scrollbar-hidden snap-mandatory snap-x"
ref={setScrollableSectionRef}
>
<div class="min-w-full snap-center">
<DetailsSection
filename={props.contentPiece.filename || ""}
slug={props.contentPiece.slug}
Expand Down Expand Up @@ -95,17 +120,25 @@ const ContentPieceMetadata: Component<ContentPieceMetadataProps> = (props) => {
props.setContentPiece({ members });
}}
/>
</Match>
<Match when={props.activeSection.id === "custom-data"}>
<ContentPieceDescription
descriptionExists={typeof props.contentPiece?.description === "string"}
initialDescription={props.contentPiece.description || ""}
editable={props.editable}
setDescription={(description) => {
props.setContentPiece({ description });
}}
/>
</div>
<div class="min-w-full snap-center">
<CustomDataSection
editable={props.editable}
customData={props.contentPiece.customData}
setCustomData={(customData) => {
props.setContentPiece({ customData });
}}
/>
</Match>
<Match when={props.activeSection.id === "extensions" && hostConfig.extensions}>
</div>
<div class="min-w-full snap-center">
<ExtensionsSection
contentPiece={props.contentPiece}
setCustomData={(customData) => {
Expand All @@ -114,14 +147,14 @@ const ContentPieceMetadata: Component<ContentPieceMetadataProps> = (props) => {
});
}}
/>
</Match>
<Match when={props.activeSection.id === "variants"}>
</div>
<div class="min-w-full snap-center">
<VariantsSection
activeVariant={props.activeVariant}
setActiveVariant={props.setActiveVariant}
/>
</Match>
</Switch>
</div>
</div>
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import {
mdiFilePlus,
mdiFileLock,
mdiFileLockOpen,
mdiFolder,
mdiFolderLock,
mdiFolderOpen,
mdiFolderPlus,
mdiIdentifier,
Expand Down Expand Up @@ -249,7 +247,7 @@ const ContentGroupColumn: Component<ContentGroupColumnProps> = (props) => {
}}
>
<div
class="flex flex-1 justify-center items-center overflow-hidden rounded-lg"
class="flex flex-1 justify-center items-center overflow-hidden"
data-content-group-id={props.contentGroup.id}
onDragOver={(event) => event.preventDefault()}
onDragEnter={(event) => {
Expand Down Expand Up @@ -297,32 +295,6 @@ const ContentGroupColumn: Component<ContentGroupColumnProps> = (props) => {
}
}}
>
<div class="h-8 w-8 relative group mr-1">
<IconButton
path={props.contentGroup.locked ? mdiFolderLock : mdiFolder}
variant="text"
class={clsx(
"m-0 absolute top-0 left-0 @hover:group-hover:opacity-0",
highlight() && "!opacity-0"
)}
hover={false}
onClick={() => {
setAncestor(props.contentGroup);
}}
/>
<IconButton
path={mdiFolderOpen}
variant="text"
class={clsx(
"m-0 absolute top-0 left-0 opacity-0 @hover:group-hover:opacity-100",
highlight() && "!opacity-100"
)}
color={highlight() ? "primary" : "base"}
onClick={() => {
setAncestor(props.contentGroup);
}}
/>
</div>
<MiniEditor
class={clsx(
"inline-flex flex-1 overflow-x-auto content-group-name scrollbar-hidden hover:cursor-text whitespace-nowrap-children",
Expand Down
Loading

0 comments on commit 0916e1f

Please sign in to comment.