diff --git a/src/pages/Pokemon/components/Moves.tsx b/src/pages/Pokemon/components/Moves.tsx
index aa41975c..141ec49c 100644
--- a/src/pages/Pokemon/components/Moves.tsx
+++ b/src/pages/Pokemon/components/Moves.tsx
@@ -1,7 +1,9 @@
-import { Icon } from '@/newComponents';
-import { Accuracy, FullPokemon, LevelMap, PMMove } from '@/types/Pokemon';
+import { useState } from 'react';
import clsx from 'clsx';
+import { Accuracy, FullPokemon, LevelMap, PMMove } from '@/types/Pokemon';
+import { Icon } from '@/newComponents';
+
type Props = {
pm: FullPokemon;
};
@@ -36,9 +38,9 @@ const columns = [
href={`https://wiki.52poke.com/zh-hant/${row.nameZh}(招式)`}
target="_blank"
rel="noreferrer"
- className="ml-2 font-bold text-blue-800 underline"
+ className="whitespace-nowrap font-bold text-blue-800 underline"
>
- {row.nameZh}
+ {row.nameZh}
),
meta: 'w-2/12',
@@ -77,16 +79,22 @@ export function Moves({ pm }: Props) {
.concat(pm.moves.eggMoves as PMMove[])
.concat(pm.moves.TMs as PMMove[]);
+ const [expandedPanels, setExpandedPanels] = useState>(new Set());
+
+ const handleClick = (panelKey: string) => {
+ const updatedPanels = new Set(expandedPanels);
+ if (updatedPanels.has(panelKey)) {
+ updatedPanels.delete(panelKey);
+ } else {
+ updatedPanels.add(panelKey);
+ }
+ setExpandedPanels(updatedPanels);
+ };
+
return (
-
+
- -
+
-
{columns.map((col) => (
))}
- {allMoves.map((move) => {
- return [
- - {}}
- >
- {columns.map((col) => (
-
- {col.value(move)}
-
- ))}
-
,
- -
- {move.description}
-
,
- ].flat();
- })}
+ {allMoves
+ .map((move) => {
+ const key = `${move.pid}-${'level' in move ? move.level : move.TMPid}`;
+ const lilist = [
+ - {
+ handleClick(key);
+ }}
+ >
+ {columns.map((col) => (
+
+ {col.value(move)}
+
+ ))}
+
,
+ ];
+
+ if (expandedPanels.has(key)) {
+ lilist.push(
+ -
+ {move.description}
+
+ );
+ }
+
+ return lilist;
+ })
+ .flat()}
);