Skip to content

Commit

Permalink
remove bottom nav
Browse files Browse the repository at this point in the history
  • Loading branch information
breadchris committed Mar 21, 2024
1 parent dc6db1d commit 60d6fd1
Show file tree
Hide file tree
Showing 15 changed files with 778 additions and 509 deletions.
14 changes: 12 additions & 2 deletions js/extension/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import {Content, Data, Post, File} from "@/rpc/content/content_pb";
import {Content, Data, Post, File, Page} from "@/rpc/content/content_pb";

const ITEMS_PER_PAGE = 100; // Adjust as required
const ITEMS_PER_PAGE = 100;

export function pageContent(): Content {
return new Content({
tags: [],
type: {
case: 'page',
value: new Page({})
}
});
}

export function fileContent(): Content {
return new Content({
Expand Down
44 changes: 44 additions & 0 deletions js/rpc/content/content_pb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,12 @@ export class Content extends Message<Content> {
*/
value: AudioVideo;
case: "audioVideo";
} | {
/**
* @generated from field: content.Page page = 14;
*/
value: Page;
case: "page";
} | { case: undefined; value?: undefined } = { case: undefined };

constructor(data?: PartialMessage<Content>) {
Expand All @@ -1227,6 +1233,7 @@ export class Content extends Message<Content> {
{ no: 11, name: "chatgpt_conversation", kind: "message", T: Conversation, oneof: "type" },
{ no: 12, name: "browser_history", kind: "message", T: History, oneof: "type" },
{ no: 13, name: "audio_video", kind: "message", T: AudioVideo, oneof: "type" },
{ no: 14, name: "page", kind: "message", T: Page, oneof: "type" },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Content {
Expand All @@ -1246,6 +1253,43 @@ export class Content extends Message<Content> {
}
}

/**
* @generated from message content.Page
*/
export class Page extends Message<Page> {
/**
* @generated from field: string html = 1;
*/
html = "";

constructor(data?: PartialMessage<Page>) {
super();
proto3.util.initPartial(data, this);
}

static readonly runtime: typeof proto3 = proto3;
static readonly typeName = "content.Page";
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: "html", kind: "scalar", T: 9 /* ScalarType.STRING */ },
]);

static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Page {
return new Page().fromBinary(bytes, options);
}

static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Page {
return new Page().fromJson(jsonValue, options);
}

static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Page {
return new Page().fromJsonString(jsonString, options);
}

static equals(a: Page | PlainMessage<Page> | undefined, b: Page | PlainMessage<Page> | undefined): boolean {
return proto3.util.equals(Page, a, b);
}
}

/**
* @generated from message content.FileUploadResponse
*/
Expand Down
3 changes: 0 additions & 3 deletions js/site/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ import {ChatPage} from "@/chat/ChatPage";
import {VerifyPage} from "@/auth/VerifyPage";
import {Provider} from "jotai";
import {Admin} from "@/admin/Admin";
import {SourcePage} from "@/source/SourcePage";
import {AuthForm} from "@/auth/AuthForm";
import {CommandMenu} from "@/components/CommandMenu";

const AppRoutes = () => {
const commonRoutes = [{
Expand Down
Binary file modified js/site/go.wasm
Binary file not shown.
2 changes: 0 additions & 2 deletions js/site/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import React from "react";
import ReactDOM from "react-dom/client";
import 'source-map-support/register';
import {App} from "@/App";
import * as rrweb from 'rrweb';
import {HTMLEvents, RRWebRecorder} from "@/event/HTMLEvents";
import './wasm_exec';

global.React = React;
Expand Down
82 changes: 82 additions & 0 deletions js/site/source/BottomNav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import React from 'react';
import { Content } from "@/rpc/content/content_pb";

const BottomNav: React.FC<{
changeContent: (c: Content) => void,
addTag: (tag: string) => void,
onSend: () => void,
onStop: () => void,
actionRunning: boolean,
}> = ({changeContent, addTag, onSend, actionRunning, onStop}) => {
const [newContent, setNewContent] = useState(false);
const [addingTag, setAddingTag] = useState(false);
const [selectedTag, setSelectedTag] = useState<string>('');
const onAddTag = (tag: string) => {
if (tag) {
setAddingTag(false);
addTag(tag);
}
};
const onNewClose = () => {
setNewContent(false);
}

return (
<div className="btm-nav z-50">
<Modal open={newContent} onClose={onNewClose}>
<div className="flex flex-col">
<div className={"flex flex-row space-y-2"}>
<button className={"btn"} onClick={() => {
changeContent(urlContent('https://example.com', []));
setNewContent(false);
}}>url</button>
<button className={"btn"} onClick={() => {
changeContent(postContent("Don't think, write."));
setNewContent(false);
}}>
post
</button>
<button className={"btn"} onClick={() => {
changeContent(siteContent());
setNewContent(false);
}}>
<a>site</a>
</button>
<button className={"btn"} onClick={() => {
changeContent(fileContent());
setNewContent(false);
}}>
<a>file</a>
</button>
</div>
<button className={"btn"} onClick={onNewClose}>close</button>
</div>
</Modal>
<Modal open={addingTag} onClose={() => setAddingTag(false)}>
<div className={"space-y-2"}>
<FilteredTagInput
selectedTag={selectedTag}
setSelectedTag={setSelectedTag}
onAddTag={onAddTag}
/>
<button className={"btn"} onClick={() => setAddingTag(false)}>close</button>
</div>
</Modal>
<button onClick={() => setAddingTag(true)}>
<TagIcon className="h-6 w-6" />
</button>
<button onClick={() => setNewContent(true)}>
<PlusIcon className="h-6 w-6" />
</button>
{actionRunning && (
<button onClick={onStop}>
<StopIcon className="h-6 w-6" />
</button>
)}
<button onClick={onSend}>
<PaperAirplaneIcon className="h-6 w-6" />
</button>
<ContentDrawer />
</div>
)
}
19 changes: 6 additions & 13 deletions js/site/source/ContentDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const ContentDrawer: React.FC<{}> = () => {
<div className="content-drawer z-50">
<input id="my-drawer" type="checkbox" className="content-drawer-toggle" />
<div className="content-drawer-content">
<label htmlFor="my-drawer" className="content-drawer-button">
<ListBulletIcon className="h-6 w-6" />
<label htmlFor="my-drawer" className="btn content-drawer-button">
content
</label>
</div>
<div className="content-drawer-side fixed w-screen">
Expand Down Expand Up @@ -103,17 +103,10 @@ const ContentTable: React.FC<{displayContent: DisplayContent[]}> = ({displayCont
console.error('failed to delete', e)
}
}
// https://daisyui.com/components/carousel/#item4
return (
<Splide aria-label="referenced content" className={"w-full h-72"} options={{
perPage: 3,
autoWidth: true,
direction: 'ttb',
height: '80%',
}}>
{/*https://slidejs.com/extensions/grid*/}
<div className={"h-96 carousel carousel-vertical rounded-box"}>
{displayContent.filter(notEmpty).map((item, index) => (
<SplideSlide key={index}>
<div key={index} className={"carousel-item h-full"}>
<div className={`flex flex-col p-4 w-96 bg-base-200 text-base-content ${selectedContent?.id === item.content?.id ? 'bg-accent' : ''}`}
onClick={(e) => handleCheckboxChange(item.content, true)}
>
Expand All @@ -131,9 +124,9 @@ const ContentTable: React.FC<{displayContent: DisplayContent[]}> = ({displayCont
))}
</div>
</div>
</SplideSlide>
</div>
))}
</Splide>
</div>
);
}

Loading

0 comments on commit 60d6fd1

Please sign in to comment.