Notification message for add/remove mod
Also changed how scrolling resets on pagination. And tweaked pagination styling.
This commit is contained in:
parent
10bc093300
commit
2bd5227287
@ -60,7 +60,7 @@ const CellList: React.FC<Props> = ({ cells }) => {
|
|||||||
forcePage={page}
|
forcePage={page}
|
||||||
onPageChange={(event) => {
|
onPageChange={(event) => {
|
||||||
setPage(event.selected);
|
setPage(event.selected);
|
||||||
document.getElementById("sidebar")?.scrollTo(0, 0);
|
document.getElementById("exterior-cells")?.scrollIntoView();
|
||||||
}}
|
}}
|
||||||
pageRangeDisplayed={3}
|
pageRangeDisplayed={3}
|
||||||
marginPagesDisplayed={2}
|
marginPagesDisplayed={2}
|
||||||
@ -76,7 +76,7 @@ const CellList: React.FC<Props> = ({ cells }) => {
|
|||||||
return (
|
return (
|
||||||
filteredCells && (
|
filteredCells && (
|
||||||
<>
|
<>
|
||||||
<h2>Exterior Cells ({filteredCells.length})</h2>
|
<h2 id="exterior-cells">Exterior Cells ({filteredCells.length})</h2>
|
||||||
<div className={styles.filters}>
|
<div className={styles.filters}>
|
||||||
<hr />
|
<hr />
|
||||||
<div className={styles["filter-row"]}>
|
<div className={styles["filter-row"]}>
|
||||||
|
@ -30,7 +30,9 @@ const FetchedPluginsList: React.FC<Props> = ({ selectedCell }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{plugins.length > 0 && <h2>Added Plugins ({plugins.length})</h2>}
|
{plugins.length > 0 && (
|
||||||
|
<h2 id="added-plugins">Added Plugins ({plugins.length})</h2>
|
||||||
|
)}
|
||||||
{!selectedCell && plugins.length > 0 && (
|
{!selectedCell && plugins.length > 0 && (
|
||||||
<div className={styles.buttons}>
|
<div className={styles.buttons}>
|
||||||
<button onClick={() => dispatch(enableAllFetchedPlugins())}>
|
<button onClick={() => dispatch(enableAllFetchedPlugins())}>
|
||||||
|
@ -98,6 +98,8 @@ const ModData: React.FC<Props> = ({
|
|||||||
onSelectFile,
|
onSelectFile,
|
||||||
onSelectPlugin,
|
onSelectPlugin,
|
||||||
}) => {
|
}) => {
|
||||||
|
const [showAddRemovePluginNotification, setShowAddRemovePluginNotification] =
|
||||||
|
useState<boolean>(false);
|
||||||
const { data: modData, error: modError } = useSWRImmutable(
|
const { data: modData, error: modError } = useSWRImmutable(
|
||||||
`https://mods.modmapper.com/${selectedMod}.json`,
|
`https://mods.modmapper.com/${selectedMod}.json`,
|
||||||
(_) => jsonFetcher<Mod>(_)
|
(_) => jsonFetcher<Mod>(_)
|
||||||
@ -286,23 +288,37 @@ const ModData: React.FC<Props> = ({
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
{pluginData ? (
|
{pluginData ? (
|
||||||
|
<>
|
||||||
<div className={styles["plugin-actions"]}>
|
<div className={styles["plugin-actions"]}>
|
||||||
<Link href={`/?plugin=${pluginData.hash}`}>
|
<Link href={`/?plugin=${pluginData.hash}`}>
|
||||||
<a className={styles["plugin-link"]}>View plugin</a>
|
<a className={styles["plugin-link"]}>View plugin</a>
|
||||||
</Link>
|
</Link>
|
||||||
<button
|
<button
|
||||||
className={styles.button}
|
className={styles.button}
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
fetchedPlugin
|
if (fetchedPlugin) {
|
||||||
? dispatch(removeFetchedPlugin(pluginData.hash))
|
dispatch(removeFetchedPlugin(pluginData.hash));
|
||||||
: dispatch(
|
} else {
|
||||||
|
dispatch(
|
||||||
updateFetchedPlugin({ ...pluginData, enabled: true })
|
updateFetchedPlugin({ ...pluginData, enabled: true })
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
setShowAddRemovePluginNotification(true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{Boolean(fetchedPlugin) ? "Remove plugin" : "Add plugin"}
|
{Boolean(fetchedPlugin) ? "Remove plugin" : "Add plugin"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{showAddRemovePluginNotification && (
|
||||||
|
<span>
|
||||||
|
Plugin {Boolean(fetchedPlugin) ? "added" : "removed"}.{" "}
|
||||||
|
<Link href="/#added-plugins">
|
||||||
|
<a>View list</a>
|
||||||
|
</Link>
|
||||||
|
.
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
) : (
|
) : (
|
||||||
<div className={styles.spacer} />
|
<div className={styles.spacer} />
|
||||||
)}
|
)}
|
||||||
|
@ -120,7 +120,7 @@ const ModList: React.FC<Props> = ({ mods, files, counts }) => {
|
|||||||
forcePage={page}
|
forcePage={page}
|
||||||
onPageChange={(event) => {
|
onPageChange={(event) => {
|
||||||
setPage(event.selected);
|
setPage(event.selected);
|
||||||
document.getElementById("sidebar")?.scrollTo(0, 0);
|
document.getElementById("nexus-mods")?.scrollIntoView();
|
||||||
}}
|
}}
|
||||||
pageRangeDisplayed={3}
|
pageRangeDisplayed={3}
|
||||||
marginPagesDisplayed={2}
|
marginPagesDisplayed={2}
|
||||||
@ -136,7 +136,7 @@ const ModList: React.FC<Props> = ({ mods, files, counts }) => {
|
|||||||
return (
|
return (
|
||||||
mods && (
|
mods && (
|
||||||
<>
|
<>
|
||||||
<h2>Nexus Mods ({modsWithCounts.length})</h2>
|
<h2 id="nexus-mods">Nexus Mods ({modsWithCounts.length})</h2>
|
||||||
<div className={styles.filters}>
|
<div className={styles.filters}>
|
||||||
<hr />
|
<hr />
|
||||||
<div className={styles["filter-row"]}>
|
<div className={styles["filter-row"]}>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import useSWRImmutable from "swr/immutable";
|
import useSWRImmutable from "swr/immutable";
|
||||||
|
|
||||||
import { useAppDispatch, useAppSelector } from "../lib/hooks";
|
import { useAppDispatch, useAppSelector } from "../lib/hooks";
|
||||||
@ -15,6 +15,7 @@ import type { CellCoord } from "./ModData";
|
|||||||
import PluginData, { Plugin as PluginProps } from "./PluginData";
|
import PluginData, { Plugin as PluginProps } from "./PluginData";
|
||||||
import styles from "../styles/PluginDetail.module.css";
|
import styles from "../styles/PluginDetail.module.css";
|
||||||
import { jsonFetcher } from "../lib/api";
|
import { jsonFetcher } from "../lib/api";
|
||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
const buildPluginProps = (
|
const buildPluginProps = (
|
||||||
data?: PluginsByHashWithMods | null,
|
data?: PluginsByHashWithMods | null,
|
||||||
@ -48,6 +49,9 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const PluginDetail: React.FC<Props> = ({ hash, counts }) => {
|
const PluginDetail: React.FC<Props> = ({ hash, counts }) => {
|
||||||
|
const [showAddRemovePluginNotification, setShowAddRemovePluginNotification] =
|
||||||
|
useState<boolean>(false);
|
||||||
|
|
||||||
const { data, error } = useSWRImmutable(
|
const { data, error } = useSWRImmutable(
|
||||||
`https://plugins.modmapper.com/${hash}.json`,
|
`https://plugins.modmapper.com/${hash}.json`,
|
||||||
(_) => jsonFetcher<PluginsByHashWithMods>(_)
|
(_) => jsonFetcher<PluginsByHashWithMods>(_)
|
||||||
@ -84,16 +88,30 @@ const PluginDetail: React.FC<Props> = ({ hash, counts }) => {
|
|||||||
counts={counts}
|
counts={counts}
|
||||||
/>
|
/>
|
||||||
{data && (
|
{data && (
|
||||||
|
<>
|
||||||
<button
|
<button
|
||||||
className={styles.button}
|
className={styles.button}
|
||||||
onClick={() =>
|
onClick={() => {
|
||||||
fetchedPlugin
|
if (fetchedPlugin) {
|
||||||
? dispatch(removeFetchedPlugin(data.hash))
|
dispatch(removeFetchedPlugin(data.hash));
|
||||||
: dispatch(updateFetchedPlugin({ ...data, enabled: true }))
|
} else {
|
||||||
|
dispatch(updateFetchedPlugin({ ...data, enabled: true }));
|
||||||
}
|
}
|
||||||
|
setShowAddRemovePluginNotification(true);
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{Boolean(fetchedPlugin) ? "Remove plugin" : "Add plugin"}
|
{Boolean(fetchedPlugin) ? "Remove plugin" : "Add plugin"}
|
||||||
</button>
|
</button>
|
||||||
|
{showAddRemovePluginNotification && (
|
||||||
|
<span>
|
||||||
|
Plugin {Boolean(fetchedPlugin) ? "added" : "removed"}.{" "}
|
||||||
|
<Link href="/#added-plugins">
|
||||||
|
<a>View list</a>
|
||||||
|
</Link>
|
||||||
|
.
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{data && <ModList mods={data.mods} files={data.files} counts={counts} />}
|
{data && <ModList mods={data.mods} files={data.files} counts={counts} />}
|
||||||
{parsedPlugin?.parseError && (
|
{parsedPlugin?.parseError && (
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: center;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination li {
|
.pagination li {
|
||||||
|
@ -115,7 +115,7 @@
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
justify-content: center;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pagination li {
|
.pagination li {
|
||||||
|
Loading…
Reference in New Issue
Block a user