Skip to content

Commit

Permalink
added module notes
Browse files Browse the repository at this point in the history
  • Loading branch information
DerGoogler committed Jul 30, 2024
1 parent 399a4ff commit 7bb2bdd
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
32 changes: 31 additions & 1 deletion Website/src/activitys/ModuleViewActivity/tabs/OverviewTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,35 @@ import { Build } from "@Native/Build";
import { os } from "@Native/Os";
import { useFetch } from "@Hooks/useFetch";

const colorHandler = (color?: ModuleNoteColors) => {
switch (color) {
case "green":
case "success":
return "success";

case "info":
case "blue":
return "info";

case "warning":
case "yellow":
return "warning";

case "error":
case "red":
return "error";

default:
return "info";
}
};

const OverviewTab = () => {
const { strings } = useStrings();
const { context, extra } = useActivity<Module>();
const { settings } = useSettings();
const { modules } = useRepos();
const { id, name, description, versions, minApi, track } = extra;
const { id, name, description, versions, minApi, note, track } = extra;

const { icon, screenshots, require, readme: moduleReadme, categories } = useModuleInfo(extra);

Expand All @@ -55,6 +78,13 @@ const OverviewTab = () => {
return (
<>
<Stack direction="column" justifyContent="center" alignItems="flex-start" spacing={1}>
{note && (
<Alert sx={{ width: "100%" }} severity={colorHandler(note.color)}>
{note.title && <AlertTitle>{note.title}</AlertTitle>}
{note.message}
</Alert>
)}

{isLowQuality && (
<Alert sx={{ width: "100%" }} severity="warning">
<AlertTitle>{strings("low_quality_module")}</AlertTitle>
Expand Down
8 changes: 8 additions & 0 deletions Website/src/typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ declare global {
description: string;
}

export type ModuleNoteColors = "success" | "green" | "info" | "blue" | "warning" | "yellow" | "error" | "red";
export interface ModuleNote {
title?: string;
message?: string;
color?: ModuleNoteColors;
}

export interface Module extends BaseModule {
updateJson?: string;
added: number;
Expand All @@ -185,6 +192,7 @@ declare global {
categories?: string[];
stars?: number;
readme?: string;
note?: ModuleNote;

/**
* Non-user definable
Expand Down

0 comments on commit 7bb2bdd

Please sign in to comment.