From b9cae81fce2448658059889ad2845b5b34faa2ec Mon Sep 17 00:00:00 2001 From: Scott Benton Date: Tue, 14 May 2024 00:03:22 -0400 Subject: [PATCH 1/2] feat(homebrew): Added description to homebrew --- .../homebrew/_homebrewCollection.type.ts | 1 + .../AboutSection/AboutSection.tsx | 7 +++++ .../AboutSection/Description.tsx | 31 +++++++++++++++++++ src/types/World.type.ts | 4 ++- 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/pages/Homebrew/HomebrewEditorPage/AboutSection/Description.tsx diff --git a/src/api-calls/homebrew/_homebrewCollection.type.ts b/src/api-calls/homebrew/_homebrewCollection.type.ts index a98f1675..82b1d92a 100644 --- a/src/api-calls/homebrew/_homebrewCollection.type.ts +++ b/src/api-calls/homebrew/_homebrewCollection.type.ts @@ -6,6 +6,7 @@ export interface BaseHomebrewCollectionDocument { type: PackageTypes; id: string; title: string; + description?: string; editors: string[]; viewers?: string[]; creator: string; diff --git a/src/pages/Homebrew/HomebrewEditorPage/AboutSection/AboutSection.tsx b/src/pages/Homebrew/HomebrewEditorPage/AboutSection/AboutSection.tsx index 70c26d97..ba38175e 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/AboutSection/AboutSection.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/AboutSection/AboutSection.tsx @@ -23,6 +23,7 @@ import { arrayRemove } from "firebase/firestore"; import { removeSelfAsEditor } from "api-calls/homebrew/editorFunction/removeSelfAsEditor"; import { useNavigate } from "react-router-dom"; import { BASE_ROUTES, basePaths } from "routes"; +import { Description } from "./Description"; export interface AboutSectionProps { id: string; @@ -131,6 +132,12 @@ export function AboutSection(props: AboutSectionProps) { /> )} + + + {details.type === PackageTypes.Expansion && ( Expansion For diff --git a/src/pages/Homebrew/HomebrewEditorPage/AboutSection/Description.tsx b/src/pages/Homebrew/HomebrewEditorPage/AboutSection/Description.tsx new file mode 100644 index 00000000..17aa346d --- /dev/null +++ b/src/pages/Homebrew/HomebrewEditorPage/AboutSection/Description.tsx @@ -0,0 +1,31 @@ +import { Box } from "@mui/material"; +import { MarkdownEditor } from "components/shared/RichTextEditor/MarkdownEditor"; +import { useState } from "react"; +import { useStore } from "stores/store"; + +export interface DescriptionProps { + expansionId: string; + description?: string; +} + +export function Description(props: DescriptionProps) { + const { expansionId, description } = props; + const updateDetails = useStore((store) => store.homebrew.updateExpansion); + + const [localDescription, setLocalDescription] = useState(description ?? ""); + + const handleSave = () => { + updateDetails(expansionId, { description: localDescription }); + }; + + return ( + theme.breakpoints.values.md}> + setLocalDescription(value)} + onBlur={handleSave} + /> + + ); +} diff --git a/src/types/World.type.ts b/src/types/World.type.ts index 6da6ad02..ad47b9a3 100644 --- a/src/types/World.type.ts +++ b/src/types/World.type.ts @@ -5,12 +5,14 @@ export type TRUTH_IDS = (typeof truthIds)[number]; export interface World { name: string; - truths?: { [key: string]: Truth }; newTruths?: Record; ownerIds: string[]; worldDescription?: Uint8Array; + // Deprecated, use newTruths instead + truths?: { [key: string]: Truth }; } +// Deprecated export interface Truth { customTruth?: TruthOptionClassic; selectedSubItemId?: string | null; From e4a26b66d230dfb1a117fd84e4b3afa9a5c23812 Mon Sep 17 00:00:00 2001 From: Scott Benton Date: Tue, 14 May 2024 00:09:35 -0400 Subject: [PATCH 2/2] feat(homebrew): Added description to homebrew --- .../AboutSection/AboutSection.tsx | 15 ++++++++------ .../AboutSection/Description.tsx | 20 ++++++++++++------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/pages/Homebrew/HomebrewEditorPage/AboutSection/AboutSection.tsx b/src/pages/Homebrew/HomebrewEditorPage/AboutSection/AboutSection.tsx index ba38175e..87e174fa 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/AboutSection/AboutSection.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/AboutSection/AboutSection.tsx @@ -132,12 +132,15 @@ export function AboutSection(props: AboutSectionProps) { /> )} - - - + {(!!details.description || isEditor) && ( + + + + )} {details.type === PackageTypes.Expansion && ( Expansion For diff --git a/src/pages/Homebrew/HomebrewEditorPage/AboutSection/Description.tsx b/src/pages/Homebrew/HomebrewEditorPage/AboutSection/Description.tsx index 17aa346d..9664887a 100644 --- a/src/pages/Homebrew/HomebrewEditorPage/AboutSection/Description.tsx +++ b/src/pages/Homebrew/HomebrewEditorPage/AboutSection/Description.tsx @@ -1,4 +1,5 @@ import { Box } from "@mui/material"; +import { MarkdownRenderer } from "components/shared/MarkdownRenderer"; import { MarkdownEditor } from "components/shared/RichTextEditor/MarkdownEditor"; import { useState } from "react"; import { useStore } from "stores/store"; @@ -6,10 +7,11 @@ import { useStore } from "stores/store"; export interface DescriptionProps { expansionId: string; description?: string; + isEditor?: boolean; } export function Description(props: DescriptionProps) { - const { expansionId, description } = props; + const { expansionId, description, isEditor } = props; const updateDetails = useStore((store) => store.homebrew.updateExpansion); const [localDescription, setLocalDescription] = useState(description ?? ""); @@ -20,12 +22,16 @@ export function Description(props: DescriptionProps) { return ( theme.breakpoints.values.md}> - setLocalDescription(value)} - onBlur={handleSave} - /> + {isEditor ? ( + setLocalDescription(value)} + onBlur={handleSave} + /> + ) : ( + + )} ); }