Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/add homebrew description #422

Merged
merged 2 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/api-calls/homebrew/_homebrewCollection.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface BaseHomebrewCollectionDocument {
type: PackageTypes;
id: string;
title: string;
description?: string;
editors: string[];
viewers?: string[];
creator: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -131,6 +132,15 @@ export function AboutSection(props: AboutSectionProps) {
/>
</Grid>
)}
{(!!details.description || isEditor) && (
<Grid item xs={12}>
<Description
expansionId={id}
description={details.description ?? ""}
isEditor={isEditor}
/>
</Grid>
)}
{details.type === PackageTypes.Expansion && (
<Grid item xs={12}>
<Typography variant="overline">Expansion For</Typography>
Expand Down
37 changes: 37 additions & 0 deletions src/pages/Homebrew/HomebrewEditorPage/AboutSection/Description.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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";

export interface DescriptionProps {
expansionId: string;
description?: string;
isEditor?: boolean;
}

export function Description(props: DescriptionProps) {
const { expansionId, description, isEditor } = props;
const updateDetails = useStore((store) => store.homebrew.updateExpansion);

const [localDescription, setLocalDescription] = useState(description ?? "");

const handleSave = () => {
updateDetails(expansionId, { description: localDescription });
};

return (
<Box maxWidth={(theme) => theme.breakpoints.values.md}>
{isEditor ? (
<MarkdownEditor
label={"Description"}
content={localDescription ?? ""}
onChange={(value) => setLocalDescription(value)}
onBlur={handleSave}
/>
) : (
<MarkdownRenderer markdown={description ?? ""} />
)}
</Box>
);
}
4 changes: 3 additions & 1 deletion src/types/World.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ export type TRUTH_IDS = (typeof truthIds)[number];

export interface World {
name: string;
truths?: { [key: string]: Truth };
newTruths?: Record<string, NewTruth>;
ownerIds: string[];
worldDescription?: Uint8Array;
// Deprecated, use newTruths instead
truths?: { [key: string]: Truth };
}

// Deprecated
export interface Truth {
customTruth?: TruthOptionClassic;
selectedSubItemId?: string | null;
Expand Down
Loading