Commit 5dd65348 authored by Chunchi Che's avatar Chunchi Che

修复决斗界面中内容太多溢出屏幕的问题

parent bc7e60c7
...@@ -3,6 +3,10 @@ import { displayOptionModal } from "@/ui/Duel/Message"; ...@@ -3,6 +3,10 @@ import { displayOptionModal } from "@/ui/Duel/Message";
export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => { export default async (selectOption: ygopro.StocGameMessage.MsgSelectOption) => {
const options = selectOption.options; const options = selectOption.options;
if (options.length === 0) {
console.warn("<MsgSelectOption>options is empty.");
return;
}
await displayOptionModal( await displayOptionModal(
fetchStrings(Region.System, 556), fetchStrings(Region.System, 556),
options.map(({ code, response }) => ({ options.map(({ code, response }) => ({
......
...@@ -7,7 +7,7 @@ import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio"; ...@@ -7,7 +7,7 @@ import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio";
import { type CardMeta, Region, type ygopro } from "@/api"; import { type CardMeta, Region, type ygopro } from "@/api";
import { fetchStrings } from "@/api"; import { fetchStrings } from "@/api";
import { CardType, isMe, matStore } from "@/stores"; import { CardType, isMe, matStore } from "@/stores";
import { YgoCard } from "@/ui/Shared"; import { ScrollableArea, YgoCard } from "@/ui/Shared";
import { groupBy } from "../../utils"; import { groupBy } from "../../utils";
import { showCardModal } from "../CardModal"; import { showCardModal } from "../CardModal";
...@@ -147,6 +147,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -147,6 +147,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
selectedZone={selectedZone} selectedZone={selectedZone}
onChange={setSelectedZone as any} onChange={setSelectedZone as any}
/> />
<ScrollableArea maxHeight="50vh">
{grouped.map( {grouped.map(
(options, i) => (options, i) =>
options[0] === selectedZone && ( options[0] === selectedZone && (
...@@ -167,7 +168,11 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -167,7 +168,11 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
className={styles["check-group"]} className={styles["check-group"]}
> >
{options[1].map((card, j) => ( {options[1].map((card, j) => (
<Tooltip title={card.effectDesc} placement="bottom" key={j}> <Tooltip
title={card.effectDesc}
placement="bottom"
key={j}
>
{/* 这儿必须有一个div,不然tooltip不生效 */} {/* 这儿必须有一个div,不然tooltip不生效 */}
<div> <div>
<CheckCard <CheckCard
...@@ -194,6 +199,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -194,6 +199,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
</div> </div>
), ),
)} )}
</ScrollableArea>
<p> <p>
<span> <span>
{/* TODO: 这里的字体可以调整下 */} {/* TODO: 这里的字体可以调整下 */}
......
...@@ -16,8 +16,13 @@ export const ScrollableArea = forwardRef< ...@@ -16,8 +16,13 @@ export const ScrollableArea = forwardRef<
elementProps?: React.HTMLAttributes<HTMLElement>; elementProps?: React.HTMLAttributes<HTMLElement>;
className?: string; className?: string;
style?: React.CSSProperties; style?: React.CSSProperties;
maxHeight?: string; // 如果不指定,默认"100%"
}> }>
>(({ scrollProps = {}, elementProps, className, style, children }, ref) => { >(
(
{ scrollProps = {}, elementProps, className, style, children, maxHeight },
ref,
) => {
const { options = {}, ...rest } = scrollProps; const { options = {}, ...rest } = scrollProps;
return ( return (
...@@ -36,6 +41,7 @@ export const ScrollableArea = forwardRef< ...@@ -36,6 +41,7 @@ export const ScrollableArea = forwardRef<
defer defer
style={{ style={{
height: "100%", height: "100%",
maxHeight: maxHeight ?? "100%",
}} }}
{...rest} {...rest}
ref={ref} ref={ref}
...@@ -45,4 +51,5 @@ export const ScrollableArea = forwardRef< ...@@ -45,4 +51,5 @@ export const ScrollableArea = forwardRef<
</div> </div>
</OverlayScrollbarsComponent> </OverlayScrollbarsComponent>
); );
}); },
);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment