cleanup, improve UI

This commit is contained in:
marlon-erler
2024-07-11 22:35:46 +02:00
parent 1bf2f4ced2
commit ba996972d4
4 changed files with 79 additions and 67 deletions
+7 -22
View File
@@ -2,7 +2,7 @@ import * as React from "bloatless-react";
import { Chat, MessageObject } from "../../Model/chatModel";
import { ObjectEntryView } from "./objectEntryView";
import { ObjectGridView } from "./objectGridView";
import { translation } from "../../translations";
export function AllObjectsView(
@@ -10,28 +10,13 @@ export function AllObjectsView(
selectedObject: React.State<MessageObject | undefined>,
isShowingObjectModal: React.State<boolean>
) {
const objectConverter: React.StateItemConverter<MessageObject> = (
messageObject
) => {
return ObjectEntryView(
chat,
messageObject,
selectedObject,
isShowingObjectModal
);
};
const content = React.createProxyState([chat.objects], () =>
chat.objects.value.size == 0 ? (
<div class="flex-column width-100 height-100 align-center justify-center secondary">
{translation.noObjects}
</div>
) : (
<div
class="grid gap padding"
style="grid-template-columns: repeat(auto-fill, minmax(350px, 1fr))"
children:prepend={[chat.objects, objectConverter]}
></div>
ObjectGridView(
chat,
chat.objects,
selectedObject,
isShowingObjectModal,
translation.noObjects
)
);
+7 -21
View File
@@ -3,6 +3,7 @@ import * as React from "bloatless-react";
import { Chat, MessageObject } from "../../Model/chatModel";
import { ObjectEntryView } from "./objectEntryView";
import { ObjectGridView } from "./objectGridView";
import { translation } from "../../translations";
export function NoteObjectsView(
@@ -10,17 +11,6 @@ export function NoteObjectsView(
selectedObject: React.State<MessageObject | undefined>,
isShowingObjectModal: React.State<boolean>
) {
const objectConverter: React.StateItemConverter<MessageObject> = (
messageObject
) => {
return ObjectEntryView(
chat,
messageObject,
selectedObject,
isShowingObjectModal
);
};
const notes = new React.ListState<MessageObject>();
chat.objects.subscribe(() => {
notes.clear();
@@ -33,16 +23,12 @@ export function NoteObjectsView(
});
const content = React.createProxyState([chat.objects], () =>
notes.value.size == 0 ? (
<div class="flex-column width-100 height-100 align-center justify-center secondary">
{translation.noNotes}
</div>
) : (
<div
class="grid gap padding"
style="grid-template-columns: repeat(auto-fill, minmax(350px, 1fr))"
children:prepend={[notes, objectConverter]}
></div>
ObjectGridView(
chat,
notes,
selectedObject,
isShowingObjectModal,
translation.noNotes
)
);
+39
View File
@@ -0,0 +1,39 @@
import * as React from "bloatless-react";
import { Chat, MessageObject } from "../../Model/chatModel";
import { ObjectEntryView } from "./objectEntryView";
import { icons } from "../../icons";
export function ObjectGridView(
chat: Chat,
messageObjects:
| React.ListState<MessageObject>
| React.MapState<MessageObject>,
selectedObject: React.State<MessageObject | undefined>,
isShowingObjectModal: React.State<boolean>,
placeholderText: string
) {
const objectConverter: React.StateItemConverter<MessageObject> = (
messageObject
) => {
return ObjectEntryView(
chat,
messageObject,
selectedObject,
isShowingObjectModal
);
};
return messageObjects.value.size == 0 ? (
<div class="flex-column width-100 height-100 align-center justify-center secondary">
{placeholderText}
</div>
) : (
<div
class="grid gap padding"
style="grid-template-columns: repeat(auto-fill, minmax(200px, 1fr))"
children:prepend={[messageObjects, objectConverter]}
></div>
);
}