feat: navigation for image and entities instead of a modal
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import { A, Navigate, Route, Router } from "@solidjs/router";
|
import { A, Navigate, Route, Router, useNavigate } from "@solidjs/router";
|
||||||
import type { PluginListener } from "@tauri-apps/api/core";
|
import type { PluginListener } from "@tauri-apps/api/core";
|
||||||
import { listen } from "@tauri-apps/api/event";
|
import { listen } from "@tauri-apps/api/event";
|
||||||
import { readFile } from "@tauri-apps/plugin-fs";
|
import { readFile } from "@tauri-apps/plugin-fs";
|
||||||
@ -23,7 +23,13 @@ import { sendImageFile } from "./network";
|
|||||||
import { Image } from "./Image";
|
import { Image } from "./Image";
|
||||||
import { WithEntityDialog } from "./WithEntityDialog";
|
import { WithEntityDialog } from "./WithEntityDialog";
|
||||||
import { Gallery } from "./gallery";
|
import { Gallery } from "./gallery";
|
||||||
import { IconHome, IconPhoto, IconSearch } from "@tabler/icons-solidjs";
|
import {
|
||||||
|
IconArrowLeft,
|
||||||
|
IconHome,
|
||||||
|
IconPhoto,
|
||||||
|
IconSearch,
|
||||||
|
} from "@tabler/icons-solidjs";
|
||||||
|
import { Entity } from "./Entity";
|
||||||
|
|
||||||
const currentPlatform = platform();
|
const currentPlatform = platform();
|
||||||
console.log("Current Platform: ", currentPlatform);
|
console.log("Current Platform: ", currentPlatform);
|
||||||
@ -35,8 +41,14 @@ const AppWrapper: Component<ParentProps> = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const WithDock: Component<ParentProps> = (props) => {
|
const WithDock: Component<ParentProps> = (props) => {
|
||||||
|
const nav = useNavigate();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="w-full flex flex-col items-center">
|
<div class="w-full flex flex-col items-center">
|
||||||
|
{/* TODO: this should only show up when NOT on the home page. */}
|
||||||
|
<div class="cursor-pointer" onClick={() => nav(-1)}>
|
||||||
|
<IconArrowLeft />
|
||||||
|
</div>
|
||||||
{props.children}
|
{props.children}
|
||||||
<div class="w-full mt-auto h-16 bg-white flex justify-between m-4 rounded-xl">
|
<div class="w-full mt-auto h-16 bg-white flex justify-between m-4 rounded-xl">
|
||||||
<A href="/" class="w-full flex justify-center items-center">
|
<A href="/" class="w-full flex justify-center items-center">
|
||||||
@ -110,6 +122,7 @@ export const App = () => {
|
|||||||
<Route path="/" component={WithEntityDialog}>
|
<Route path="/" component={WithEntityDialog}>
|
||||||
<Route path="/" component={Search} />
|
<Route path="/" component={Search} />
|
||||||
<Route path="/image/:imageId" component={Image} />
|
<Route path="/image/:imageId" component={Image} />
|
||||||
|
<Route path="/entity/:entityId" component={Entity} />
|
||||||
<Route path="/gallery/:entity" component={Gallery} />
|
<Route path="/gallery/:entity" component={Gallery} />
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/settings" component={Settings} />
|
<Route path="/settings" component={Settings} />
|
||||||
|
28
frontend/src/Entity.tsx
Normal file
28
frontend/src/Entity.tsx
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import { useParams } from "@solidjs/router";
|
||||||
|
import { Component, For, Show } from "solid-js";
|
||||||
|
import { ConcreteItemModal } from "./components/item-modal/ItemModal";
|
||||||
|
import { useSearchImageContext } from "./contexts/SearchImageContext";
|
||||||
|
|
||||||
|
export const Entity: Component = () => {
|
||||||
|
const params = useParams<{ entityId: string }>();
|
||||||
|
|
||||||
|
const { images } = useSearchImageContext();
|
||||||
|
|
||||||
|
const entity = () => images().find((i) => i.data.ID === params.entityId);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Show
|
||||||
|
when={entity()}
|
||||||
|
fallback={<>Sorry, this entity could not be found</>}
|
||||||
|
>
|
||||||
|
{(e) => (
|
||||||
|
<div>
|
||||||
|
<ConcreteItemModal item={e()} />
|
||||||
|
<For each={e().data.Images}>{(imageId) => <p>{imageId}</p>}</For>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Show>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -4,92 +4,89 @@ import { Show, type Component } from "solid-js";
|
|||||||
import SolidjsMarkdown from "solidjs-markdown";
|
import SolidjsMarkdown from "solidjs-markdown";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
item: UserImage;
|
item: UserImage;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const NullableParagraph: Component<{
|
const NullableParagraph: Component<{
|
||||||
item: string | null;
|
item: string | null;
|
||||||
itemTitle: string;
|
itemTitle: string;
|
||||||
}> = (props) => {
|
}> = (props) => {
|
||||||
return (
|
return (
|
||||||
<Show when={props.item}>
|
<Show when={props.item}>
|
||||||
{(item) => (
|
{(item) => (
|
||||||
<>
|
<>
|
||||||
<p class="font-semibold text-xl">{props.itemTitle}</p>
|
<p class="font-semibold text-xl">{props.itemTitle}</p>
|
||||||
<p class="text-md">{item()}</p>
|
<p class="text-md">{item()}</p>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Show>
|
</Show>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ConcreteItemModal: Component<Pick<Props, "item">> = (props) => {
|
export const ConcreteItemModal: Component<Pick<Props, "item">> = (props) => {
|
||||||
switch (props.item.type) {
|
switch (props.item.type) {
|
||||||
case "note":
|
case "note":
|
||||||
return (
|
return (
|
||||||
<SolidjsMarkdown>
|
<SolidjsMarkdown>
|
||||||
{props.item.data.Content.slice(
|
{props.item.data.Content.slice(
|
||||||
"```markdown".length,
|
"```markdown".length,
|
||||||
props.item.data.Content.length - "```".length,
|
props.item.data.Content.length - "```".length,
|
||||||
)}
|
)}
|
||||||
</SolidjsMarkdown>
|
</SolidjsMarkdown>
|
||||||
);
|
);
|
||||||
case "location":
|
case "location":
|
||||||
return (
|
return (
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<p class="font-semibold text-xl">Address</p>
|
<p class="font-semibold text-xl">Address</p>
|
||||||
<p class="text-md">{props.item.data.Address}</p>
|
<p class="text-md">{props.item.data.Address}</p>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case "event":
|
case "event":
|
||||||
return (
|
return (
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<p class="font-semibold text-xl">Event</p>
|
<p class="font-semibold text-xl">Event</p>
|
||||||
<p class="text-md">{props.item.data.Name}</p>
|
<p class="text-md">{props.item.data.Name}</p>
|
||||||
|
|
||||||
<NullableParagraph
|
<NullableParagraph
|
||||||
itemTitle="Start Time"
|
itemTitle="Start Time"
|
||||||
item={props.item.data.StartDateTime}
|
item={props.item.data.StartDateTime}
|
||||||
/>
|
/>
|
||||||
<NullableParagraph
|
<NullableParagraph
|
||||||
itemTitle="End Time"
|
itemTitle="End Time"
|
||||||
item={props.item.data.EndDateTime}
|
item={props.item.data.EndDateTime}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
case "contact":
|
case "contact":
|
||||||
return (
|
return (
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<p class="font-semibold text-xl">Contact</p>
|
<p class="font-semibold text-xl">Contact</p>
|
||||||
<p class="text-md">{props.item.data.Name}</p>
|
<p class="text-md">{props.item.data.Name}</p>
|
||||||
|
|
||||||
<NullableParagraph
|
<NullableParagraph itemTitle="Email" item={props.item.data.Email} />
|
||||||
itemTitle="Email"
|
|
||||||
item={props.item.data.Email}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<NullableParagraph
|
<NullableParagraph
|
||||||
itemTitle="Phone Number"
|
itemTitle="Phone Number"
|
||||||
item={props.item.data.PhoneNumber}
|
item={props.item.data.PhoneNumber}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ItemModal: Component<Props> = (props) => {
|
export const ItemModal: Component<Props> = (props) => {
|
||||||
return (
|
return (
|
||||||
<div class="fixed z-10 inset-2 rounded-2xl p-4 bg-white border border-neutral-300">
|
<div class="fixed z-10 inset-2 rounded-2xl p-4 bg-white border border-neutral-300">
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<h1 class="text-2xl font-bold">{props.item.data.Name}</h1>
|
<h1 class="text-2xl font-bold">{props.item.data.Name}</h1>
|
||||||
<button type="button" onClick={props.onClose}>
|
<button type="button" onClick={props.onClose}>
|
||||||
<IconX size={24} class="text-neutral-500" />
|
<IconX size={24} class="text-neutral-500" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-2 mb-2">
|
<div class="flex flex-col gap-2 mb-2">
|
||||||
<ConcreteItemModal item={props.item} />
|
<ConcreteItemModal item={props.item} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import { A } from "@solidjs/router";
|
||||||
import type { UserImage } from "../../network";
|
import type { UserImage } from "../../network";
|
||||||
import { SearchCardContact } from "./SearchCardContact";
|
import { SearchCardContact } from "./SearchCardContact";
|
||||||
import { SearchCardEvent } from "./SearchCardEvent";
|
import { SearchCardEvent } from "./SearchCardEvent";
|
||||||
@ -23,8 +24,11 @@ const UnwrappedSearchCard = (props: { item: UserImage }) => {
|
|||||||
|
|
||||||
export const SearchCard = (props: { item: UserImage }) => {
|
export const SearchCard = (props: { item: UserImage }) => {
|
||||||
return (
|
return (
|
||||||
<div class="h-[144px] border relative col-span-3 border-neutral-200 cursor-pointer overflow-hidden rounded-xl">
|
<A
|
||||||
|
href={`/entity/${props.item.data.ID}`}
|
||||||
|
class="h-[144px] border relative col-span-3 border-neutral-200 cursor-pointer overflow-hidden rounded-xl"
|
||||||
|
>
|
||||||
<UnwrappedSearchCard item={props.item} />
|
<UnwrappedSearchCard item={props.item} />
|
||||||
</div>
|
</A>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user