Skip to content

Commit

Permalink
wip: Navigation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
areknawo committed Feb 2, 2024
1 parent 2108ce2 commit f81ff27
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 225 deletions.
6 changes: 2 additions & 4 deletions apps/web/src/context/command-palette/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const CommandPalette: Component<CommandPaletteProps> = (props) => {

content += partOfContent;
setAnswer(marked.parse(content, { gfm: true, headerIds: false, mangle: false }));
scrollableContainerRef()?.scrollTo(0, scrollableContainerRef()?.scrollHeight || 0);
},
onclose() {
setLoading(false);
Expand Down Expand Up @@ -540,10 +541,7 @@ const CommandPalette: Component<CommandPaletteProps> = (props) => {
)}
color="base"
>
<div
class="flex flex-col w-full prose whitespace-pre-wrap"
innerHTML={answer()}
/>
<div class="flex flex-col w-full prose prose-editor" innerHTML={answer()} />
<Show when={!loading()}>
<IconButton
color="contrast"
Expand Down
6 changes: 2 additions & 4 deletions apps/web/src/context/content/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { ContentLoader, createContentLoader } from "./loader";
import { createContext, createResource, ParentComponent, useContext } from "solid-js";
import { createEffect, on, onCleanup } from "solid-js";
import { createStore, reconcile } from "solid-js/store";
import { useLocation, useNavigate, useParams } from "@solidjs/router";
import { useClient, useLocalStorage, App, useAuthenticatedUserData } from "#context";
import { useParams } from "@solidjs/router";
import { useClient, useLocalStorage, App } from "#context";

interface ContentLevel {
groups: string[];
Expand Down Expand Up @@ -37,8 +37,6 @@ const ContentDataContext = createContext<ContentDataContextData>();
const ContentDataProvider: ParentComponent = (props) => {
const client = useClient();
const params = useParams();
const location = useLocation();
const navigate = useNavigate();
const { storage, setStorage } = useLocalStorage();
const [variants, setVariants] = createStore<Record<string, App.Variant | undefined>>({});
const [contentLevels, setContentLevels] = createStore<Record<string, ContentLevel | undefined>>(
Expand Down
18 changes: 14 additions & 4 deletions apps/web/src/context/content/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ interface ContentActionsInput {
setContentLevels: SetStoreFunction<Record<string, ContentLevel | undefined>>;
}
interface ContentLoader {
loadContentLevel(contentGroupId?: string, preload?: boolean): Promise<void>;
loadContentLevel(
contentGroupId?: string,
options?: {
preload?: boolean;
loadMore?: boolean;
}
): Promise<void>;
}

const createContentLoader = ({
Expand All @@ -29,17 +35,21 @@ const createContentLoader = ({
setContentLevels
}: ContentActionsInput): ContentLoader => {
const client = useClient();
const loadContentLevel: ContentLoader["loadContentLevel"] = async (contentGroupId, preload) => {
const loadContentLevel: ContentLoader["loadContentLevel"] = async (
contentGroupId,
{ preload, loadMore } = {}
) => {
const existingLevel = contentLevels[contentGroupId || ""];

if (existingLevel && existingLevel.moreToLoad) {
if (existingLevel && existingLevel.moreToLoad && loadMore !== false) {
if (contentGroupId) {
setContentLevels(contentGroupId, "loading", true);

const level = {
groups: [...existingLevel.groups],
pieces: [...existingLevel.pieces],
moreToLoad: false
moreToLoad: false,
loading: false
};
const lastPieceId = existingLevel.pieces.at(-1);
const lastPiece = contentPieces[lastPieceId || ""];
Expand Down
194 changes: 0 additions & 194 deletions apps/web/src/context/content/opened-piece.tsx

This file was deleted.

8 changes: 4 additions & 4 deletions apps/web/src/layout/bottom-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const BottomMenu: Component = () => {
const { variants, setActiveVariantId, activeVariantId } = useContentData();
const { workspace } = useAuthenticatedUserData();
const { open, registerCommand } = useCommandPalette();
const VariantCommand: Component<{ selected: boolean; variant: App.Variant }> = (props) => {
const VariantCommand: Component<{ selected?: boolean; variant: App.Variant }> = (props) => {
return (
<Card
class={clsx(
Expand All @@ -113,7 +113,7 @@ const BottomMenu: Component = () => {
</Card>
);
};
const selectVariantCommand = {
const selectVariantCommand: Command = {
category: "workspace",
icon: mdiCards,
name: "Select Variant",
Expand All @@ -130,7 +130,7 @@ const BottomMenu: Component = () => {
action: () => {
setActiveVariantId(variant.id);
}
};
} as Command;
})
.filter(Boolean),
{
Expand All @@ -151,7 +151,7 @@ const BottomMenu: Component = () => {
registerCommand(selectVariantCommand);

return (
<div class="w-full flex m-0 bg-gray-50 dark:bg-gray-900 h-6 border-t-2 border-gray-200 dark:border-gray-700 box-content z-20">
<div class="w-full flex m-0 bg-gray-50 dark:bg-gray-900 h-6 box-content z-20">
<Show when={workspace()}>
<IconButton
path={mdiHexagonSlice6}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/layout/secured-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const SecuredLayout: ParentComponent = (props) => {
<CommandPaletteProvider>
<ContentDataProvider>
<div class="flex flex-col h-full w-full">
<div class="flex-1 flex flex-col-reverse md:flex-row h-[calc(100%-1.5rem)]">
<div class="flex-1 flex flex-col-reverse md:flex-row h-[calc(100%-1.5rem)] border-b-2 border-gray-200 dark:border-gray-700 ">
<Show
when={!storage().zenMode}
fallback={
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,9 @@ kbd {
&::-webkit-scrollbar-thumb {
@apply rounded-xl bg-gray-200 dark:bg-gray-900 border-6 border-solid border-gray-100 dark:border-gray-800;
}
&::-webkit-scrollbar-corner {
@apply bg-gray-100 dark:bg-gray-800;
}
}

.narrow-prose {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const ContentGroupColumn: Component<ContentGroupColumnProps> = (props) => {
scrollShadowController.processScrollState();
})
);
contentLoader.loadContentLevel(props.contentGroup.id);
contentLoader.loadContentLevel(props.contentGroup.id, { loadMore: false });

return (
<div
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/views/dashboard/table/content-piece-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
mdiTrashCan
} from "@mdi/js";
import clsx from "clsx";
import { Component, For, Show, createMemo, createSignal } from "solid-js";
import { Component, For, Show, createEffect, createMemo, createSignal } from "solid-js";
import {
IconButton,
Dropdown,
Expand Down Expand Up @@ -202,7 +202,7 @@ const ContentPieceGroup: Component<ContentPieceGroupProps> = (props) => {
return activeDraggableContentPieceId() ? "unset" : "0px";
};

contentLoader.loadContentLevel(props.contentGroup.id);
contentLoader.loadContentLevel(props.contentGroup.id, { loadMore: false });

return (
<div
Expand Down
Loading

0 comments on commit f81ff27

Please sign in to comment.