Commit 88119219 authored by timel's avatar timel

refactor: 5%

parent 361c3398
.checkcard-container { .checkcard-container {
position: relative; position: relative;
// padding-left: 10px;
// &::after {
// position: absolute;
// width: 3px;
// height: 100%;
// content: "";
// z-index: 1;
// left: 0;
// top: 0;
// background-color: rgb(0, 54, 189);
// }
.btns { .btns {
width: 100%; width: 100%;
top: 50%; top: 50%;
...@@ -43,3 +32,25 @@ ...@@ -43,3 +32,25 @@
} }
} }
} }
.check-group {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 10px;
}
.check-card {
width: 100px;
aspect-ratio: var(--card-ratio);
margin-inline-end: 0;
margin-block-end: 0;
flex-shrink: 0;
}
.card {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
import "./index.scss";
import { CheckCard } from "@ant-design/pro-components"; import { CheckCard } from "@ant-design/pro-components";
import { Button, Card, Segmented, Space, Tooltip } from "antd"; import { Button, Card, Segmented, Space, Tooltip } from "antd";
import { CSSProperties, useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio"; import { INTERNAL_Snapshot as Snapshot, useSnapshot } from "valtio";
import type { CardMeta, ygopro } from "@/api"; import type { CardMeta, ygopro } from "@/api";
...@@ -13,26 +11,7 @@ import { YgoCard } from "@/ui/Shared"; ...@@ -13,26 +11,7 @@ import { YgoCard } from "@/ui/Shared";
import { groupBy } from "../../utils"; import { groupBy } from "../../utils";
import { showCardModal } from "../CardModal"; import { showCardModal } from "../CardModal";
import { NeosModal } from "../NeosModal"; import { NeosModal } from "../NeosModal";
import styles from "./index.module.scss";
const YgoCardStyle = {
width: "100%",
height: "100%",
position: "absolute",
left: 0,
top: 0,
};
const CheckCardStyle = {
width: 100,
aspectRatio: 5.9 / 8.6,
marginInlineEnd: 0,
marginBlockEnd: 0,
flexShrink: 0,
};
const CheckGroupStyle = {
display: "grid",
gridTemplateColumns: "repeat(5, 1fr)",
gap: 10,
};
export interface SelectCardsModalProps { export interface SelectCardsModalProps {
isOpen: boolean; isOpen: boolean;
...@@ -148,11 +127,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -148,11 +127,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
</> </>
} }
> >
<div className="check-container"> <Space direction="vertical" style={{ width: "100%", overflow: "hidden" }}>
<Space
direction="vertical"
style={{ width: "100%", overflow: "hidden" }}
>
<Selector <Selector
zoneOptions={zoneOptions} zoneOptions={zoneOptions}
selectedZone={selectedZone} selectedZone={selectedZone}
...@@ -161,31 +136,27 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -161,31 +136,27 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
{grouped.map( {grouped.map(
(options, i) => (options, i) =>
options[0] === selectedZone && ( options[0] === selectedZone && (
<div className="checkcard-container" key={i}> <div className={styles["checkcard-container"]} key={i}>
<CheckCard.Group <CheckCard.Group
onChange={(res) => { onChange={(res) => {
setResult((isMultiple ? res : [res]) as any); setResult((isMultiple ? res : [res]) as any);
}} }}
// TODO 考虑如何设置默认值,比如只有一个的,就直接选中 // TODO 考虑如何设置默认值,比如只有一个的,就直接选中
multiple={isMultiple} multiple={isMultiple}
style={CheckGroupStyle} className={styles["check-group"]}
> >
{options[1].map((card, j) => ( {options[1].map((card, j) => (
<Tooltip <Tooltip title={card.effectDesc} placement="bottom" key={j}>
title={card.effectDesc}
placement="bottom"
key={j}
>
{/* 这儿必须有一个div,不然tooltip不生效 */} {/* 这儿必须有一个div,不然tooltip不生效 */}
<div> <div>
<CheckCard <CheckCard
cover={ cover={
<YgoCard <YgoCard
code={card.meta.id} code={card.meta.id}
style={YgoCardStyle as CSSProperties} className={styles.card}
/> />
} }
style={CheckCardStyle} className={styles["check-card"]}
value={card} value={card}
onClick={() => { onClick={() => {
showCardModal(card); showCardModal(card);
...@@ -204,7 +175,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -204,7 +175,7 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
{selecteds.length > 0 ? fetchStrings("!system", 212) : ""} {selecteds.length > 0 ? fetchStrings("!system", 212) : ""}
</span> </span>
</p> </p>
<div style={CheckGroupStyle}> <div className={styles["check-group"]}>
{selecteds.map((card, i) => ( {selecteds.map((card, i) => (
<Tooltip <Tooltip
title={card.effectDesc} title={card.effectDesc}
...@@ -214,12 +185,9 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -214,12 +185,9 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
<div> <div>
<Card <Card
cover={ cover={
<YgoCard <YgoCard code={card.meta.id} className={styles.card} />
code={card.meta.id}
style={YgoCardStyle as CSSProperties}
/>
} }
style={CheckCardStyle} className={styles["check-card"]}
onClick={() => { onClick={() => {
showCardModal(card); showCardModal(card);
}} }}
...@@ -229,7 +197,6 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({ ...@@ -229,7 +197,6 @@ export const SelectCardsModal: React.FC<SelectCardsModalProps> = ({
))} ))}
</div> </div>
</Space> </Space>
</div>
</NeosModal> </NeosModal>
); );
}; };
......
...@@ -19,7 +19,7 @@ export const YgoCard: React.FC<Props> = (props) => { ...@@ -19,7 +19,7 @@ export const YgoCard: React.FC<Props> = (props) => {
className, className,
code = 0, code = 0,
isBack = false, isBack = false,
width = 80, width,
style, style,
onClick = () => {}, onClick = () => {},
} = props; } = props;
......
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