Commit b0ba8861 authored by timel's avatar timel Committed by Chunchi Che

feat: update style2

parent dc06b81c
.card-modal { // .card-modal {
position: fixed; // position: fixed;
display: flex; // display: flex;
left: 5%; // left: 5%;
top: 20%; // top: 20%;
border-style: groove; // border-style: groove;
border-radius: 8px; // border-radius: 8px;
width: 200px; // width: 200px;
flex-wrap: wrap; // flex-wrap: wrap;
background-color: #303030; // background-color: #303030;
padding: 1%; // padding: 1%;
--visibility: hidden; // --visibility: hidden;
visibility: var(--visibility); // visibility: var(--visibility);
--opacity: 0; // --opacity: 0;
opacity: var(--opacity); // opacity: var(--opacity);
transition:visibility 0.3s linear, opacity 0.3s linear; // transition:visibility 0.3s linear, opacity 0.3s linear;
} // }
.card-modal-container { // .card-modal-container {
display: flex; // display: flex;
flex-direction: column; // flex-direction: column;
gap: 5px; // gap: 5px;
} // }
.card-modal-name { // .card-modal-name {
font-weight: bold; // font-weight: bold;
} // }
.card-modal-attribute { // .card-modal-attribute {
font-weight: bold; // font-weight: bold;
} // }
.card-modal-atk { // .card-modal-atk {
font-weight: bold; // font-weight: bold;
} // }
.card-modal-counter { // .card-modal-counter {
font-weight: bold; // font-weight: bold;
} // }
.card-modal-effect { // .card-modal-effect {
font-weight: lighter; // font-weight: lighter;
text-align: left; // text-align: left;
max-height: 200px; // max-height: 200px;
overflow: auto; // overflow: auto;
} // }
.card-modal-btn { // .card-modal-btn {
margin: 1px 5px; // margin: 1px 5px;
font-size: 80%; // font-size: 80%;
border-color: yellow; // border-color: yellow;
} // }
...@@ -33,7 +33,7 @@ table { ...@@ -33,7 +33,7 @@ table {
body { body {
color-scheme: light dark; color-scheme: light dark;
color: rgba(255, 255, 255, 0.87); color: rgba(255, 255, 255, 0.87);
background-color: #202022; background-color: #141414;
font: 87.5%/1.5em "Open Sans", sans-serif; font: 87.5%/1.5em "Open Sans", sans-serif;
display: flex; display: flex;
margin: 0; margin: 0;
......
.card-modal-desc {
line-height: 1.6;
font-size: 15px;
font-family: var(--theme-font);
max-height: calc(100% - 237px);
overflow-y: overlay;
&:hover {
&::-webkit-scrollbar-thumb {
background: #535353;
}
}
& > div {
margin-bottom: 6px;
}
&::-webkit-scrollbar {
/*滚动条整体样式*/
width: 6px; /*高宽分别对应横竖滚动条的尺寸*/
height: 1px;
}
&::-webkit-scrollbar-thumb {
/*滚动条里面小方块*/
border-radius: 10px;
background: #5353533b;
cursor: pointer;
}
.maro-item {
display: flex;
gap: 8px;
}
}
import "./Desc.scss";
import { Fragment } from "react";
export const Desc: React.FC<{ desc?: string }> = ({ desc = "" }) => {
if (!desc) return <></>;
return (
<div className="card-modal-desc">
{/* https://125naroom.com/web/2877 */}
{/* 牛逼的丸文字css教程 */}
<RegexWrapper
text={addSpaces(desc)}
re={/(①|②|③|④|⑤|⑥|⑦|⑧|⑨|⑩):.+?(?=((①|②|③|④|⑤|⑥|⑦|⑧|⑨|⑩):|$))/gs}
Wrapper={MaroListItem}
/>
</div>
);
};
const RegexWrapper: React.FC<{
text: string;
re: RegExp;
Wrapper: React.FunctionComponent<any>;
}> = ({ text, re, Wrapper }) => {
const matches = text.match(re);
if (!matches) return <>{text}</>;
const sepRe = new RegExp(
matches?.reduce((acc, cur) => `${acc}|${cur}`) ?? ""
);
const parts = text.split(sepRe);
return (
<>
{parts.map((part, index) => (
<Fragment key={`${part}-${index}`}>
<div>{part}</div>
{index !== parts.length - 1 && <Wrapper>{matches?.[index]}</Wrapper>}
</Fragment>
))}
</>
);
};
const MaroListItem: React.FC<{ children: string }> = ({ children }) => {
return (
<div className="maro-item">
<span>{children[0]}</span>
<span>
<RegexWrapper
text={children.slice(2)}
re={/●.+?(?=(●|$))/gs}
Wrapper={CircleListItem}
/>
</span>
</div>
);
};
const CircleListItem: React.FC<{ children: string }> = ({ children }) => {
return children ? (
<div className="maro-item">
<span>{children[0]}</span>
<span>{children.slice(1)}</span>
</div>
) : (
<></>
);
};
function addSpaces(str: string): string {
const regex = /\d+/g;
return str.replace(regex, (match) => ` ${match} `);
}
@import url("https://fonts.googleapis.com/css2?family=Electrolize&display=swap");
.card-modal-root {
--theme-font: "Electrolize", sans-serif;
.ant-drawer-content-wrapper {
box-shadow: none;
}
.card-modal-drawer {
width: 90%;
left: 10%;
--height: 640px;
top: calc((100% - var(--height)) / 2);
height: var(--height);
position: relative;
border-radius: 6px;
background: #242424;
.ant-drawer-header {
padding: 10px 0;
button {
margin-right: 0;
}
.ant-drawer-header-title {
flex-direction: row-reverse;
padding-left: 24px;
}
}
}
.card-modal-container {
position: relative;
height: 100%;
}
}
.card-modal-name {
font-weight: bold;
font-size: 1.2rem;
}
.atkLine {
.title,
.number {
font-family: var(--theme-font);
}
.number {
font-size: 30px;
line-height: 36px;
}
}
.attline {
display: flex;
flex-wrap: wrap;
row-gap: 10px;
}
.card-modal-info {
justify-content: space-between;
position: relative;
height: 204px; // TODO - fix this
}
import "@/styles/card-modal.scss"; import "@/styles/card-modal.scss";
import classnames from "classnames"; import classnames from "classnames";
import React from "react"; import React, { FC } from "react";
import { useSnapshot } from "valtio"; import { useSnapshot } from "valtio";
import { fetchStrings, sendSelectIdleCmdResponse } from "@/api"; import { fetchStrings, sendSelectIdleCmdResponse } from "@/api";
...@@ -13,12 +13,21 @@ import { ...@@ -13,12 +13,21 @@ import {
extraCardTypes, extraCardTypes,
Race2StringCodeMap, Race2StringCodeMap,
Type2StringCodeMap, Type2StringCodeMap,
} from "../../../common"; } from "../../../../common";
import { EffectButton } from "./EffectButton"; import { EffectButton } from "../EffectButton";
import { Drawer, Space, Tag, Divider, Timeline, Typography } from "antd";
import { LeftOutlined } from "@ant-design/icons";
import "./index.scss";
import { YgoCard } from "@/ui/Shared";
import { Desc } from "./Desc";
const { cardModal } = messageStore; const { cardModal } = messageStore;
const NeosConfig = useConfig(); const NeosConfig = useConfig();
const CARD_WIDTH = 200; const CARD_WIDTH = 140;
const { Title, Paragraph, Text, Link } = Typography;
export const CardModal = () => { export const CardModal = () => {
const snap = useSnapshot(cardModal); const snap = useSnapshot(cardModal);
...@@ -35,9 +44,6 @@ export const CardModal = () => { ...@@ -35,9 +44,6 @@ export const CardModal = () => {
const def = meta?.data.def; const def = meta?.data.def;
const counters = snap.counters; const counters = snap.counters;
const imgUrl = meta?.id
? `${NeosConfig.cardImgUrl}/${meta.id}.jpg`
: undefined;
const nonEffectInteractivies = snap.interactivies.filter( const nonEffectInteractivies = snap.interactivies.filter(
(item) => item.desc != "发动效果" (item) => item.desc != "发动效果"
); );
...@@ -46,27 +52,43 @@ export const CardModal = () => { ...@@ -46,27 +52,43 @@ export const CardModal = () => {
); );
return ( return (
<div // TODO: 宽度要好好设置 根据屏幕宽度
className={classnames("card-modal")} <Drawer
style={ open={isOpen}
{ placement="left"
"--visibility": isOpen ? "visible" : "hidden", onClose={() => (cardModal.isOpen = false)}
"--opacity": isOpen ? 1 : 0, rootClassName="card-modal-root"
} as any className="card-modal-drawer"
} headerStyle={{}}
mask={false}
title={name}
closeIcon={<LeftOutlined />}
> >
<div className="card-modal-container"> <div className="card-modal-container">
<img src={imgUrl} width={CARD_WIDTH} /> <Space
<div className="card-modal-name">{name}</div> align="start"
<AttLine size={18}
types={extraCardTypes(types || 0)} style={{ position: "relative", display: "flex" }}
race={race} >
attribute={attribute} <YgoCard
/> code={meta?.id}
<AtkLine atk={atk} def={def} /> width={CARD_WIDTH}
<CounterLine counters={counters} /> style={{ borderRadius: 4 }}
<div className="card-modal-effect">{desc}</div> />
{nonEffectInteractivies.map((interactive, idx) => { <Space direction="vertical" className="card-modal-info">
<AtkLine atk={atk} def={def} />
<AttLine
types={extraCardTypes(types || 0)}
race={race}
attribute={attribute}
/>
{/* TODO: 只有怪兽卡需要展示攻击防御 */}
{/* <CounterLine counters={counters} /> */}
</Space>
</Space>
<Divider style={{ margin: "14px 0" }}></Divider>
<Desc desc={desc} />
{/* {nonEffectInteractivies.map((interactive, idx) => {
return ( return (
<button <button
key={idx} key={idx}
...@@ -85,9 +107,9 @@ export const CardModal = () => { ...@@ -85,9 +107,9 @@ export const CardModal = () => {
</button> </button>
); );
})} })}
<EffectButton meta={meta} effectInteractivies={effectInteractivies} /> <EffectButton meta={meta} effectInteractivies={effectInteractivies} /> */}
</div> </div>
</div> </Drawer>
); );
}; };
...@@ -98,24 +120,36 @@ const AttLine = (props: { ...@@ -98,24 +120,36 @@ const AttLine = (props: {
}) => { }) => {
const race = props.race const race = props.race
? fetchStrings("!system", Race2StringCodeMap.get(props.race) || 0) ? fetchStrings("!system", Race2StringCodeMap.get(props.race) || 0)
: "?"; : undefined;
const attribute = props.attribute const attribute = props.attribute
? fetchStrings("!system", Attribute2StringCodeMap.get(props.attribute) || 0) ? fetchStrings("!system", Attribute2StringCodeMap.get(props.attribute) || 0)
: "?"; : undefined;
const types = props.types const types = props.types
.map((t) => fetchStrings("!system", Type2StringCodeMap.get(t) || 0)) .map((t) => fetchStrings("!system", Type2StringCodeMap.get(t) || 0))
.join("|"); .join("/");
return ( return (
<div className="card-modal-attribute">{`【 ${race} / ${types} 】【 ${attribute} 】`}</div> <div className="attline">
{attribute && <Tag>{attribute}</Tag>}
{race && <Tag>{race}</Tag>}
{types && <Tag>{types}</Tag>}
</div>
); );
}; };
const AtkLine = (props: { atk?: number; def?: number }) => ( const AtkLine = (props: { atk?: number; def?: number }) => (
<div className="card-modal-atk">{`ATK/${ <Space size={10} className="atkLine" direction="vertical">
props.atk !== undefined ? props.atk : "?" <div>
} DEF/${props.def !== undefined ? props.def : "?"}`}</div> <div className="title">ATK</div>
<div className="number">{props.atk ?? "?"}</div>
</div>
<div>
<div className="title">DEF</div>
<div className="number">{props.def ?? "?"}</div>
</div>
</Space>
); );
// TODO: 未完成
const CounterLine = (props: { counters: { [type: number]: number } }) => { const CounterLine = (props: { counters: { [type: number]: number } }) => {
const counters = []; const counters = [];
for (const counterType in props.counters) { for (const counterType in props.counters) {
......
...@@ -186,7 +186,18 @@ export const NewSelectActionsModal: FC = () => { ...@@ -186,7 +186,18 @@ export const NewSelectActionsModal: FC = () => {
<Tooltip title={card.effectDesc} placement="bottom" key={j}> <Tooltip title={card.effectDesc} placement="bottom" key={j}>
<div> <div>
<CheckCard <CheckCard
cover={<YgoCard code={card.meta.id} />} cover={
<YgoCard
code={card.meta.id}
style={{
width: "100%",
height: "100%",
position: "absolute",
left: 0,
top: 0,
}}
/>
}
style={{ style={{
width: 100, width: 100,
aspectRatio: 5.9 / 8.6, aspectRatio: 5.9 / 8.6,
......
...@@ -19,7 +19,7 @@ section#mat { ...@@ -19,7 +19,7 @@ section#mat {
height: var(--block-height-m); height: var(--block-height-m);
width: var(--block-width); width: var(--block-width);
// background-color: rgba(128, 128, 128, 0.447); // background-color: rgba(128, 128, 128, 0.447);
background: radial-gradient(#262626, #303030); background: radial-gradient(#1d1d1d, #222);
// box-shadow: 0 0 0 1px purple; // box-shadow: 0 0 0 1px purple;
position: relative; position: relative;
&.extra { &.extra {
...@@ -39,8 +39,8 @@ section#mat { ...@@ -39,8 +39,8 @@ section#mat {
.triangle { .triangle {
width: 0; width: 0;
height: 0; height: 0;
--color: #444444; --color: #333;
border-width: 5px; border-width: 4px;
border-style: solid; border-style: solid;
position: absolute; position: absolute;
&:nth-of-type(1) { &:nth-of-type(1) {
......
section#mat { section#mat {
.mat-card { .mat-card {
position: absolute; position: absolute;
// left: 50%;
// top: 50%;
--card-height: 100px; --card-height: 100px;
width: auto !important;
height: var(--card-height); height: var(--card-height);
aspect-ratio: var(--card-ratio); aspect-ratio: var(--card-ratio);
transform-style: preserve-3d; transform-style: preserve-3d;
...@@ -16,9 +15,14 @@ section#mat { ...@@ -16,9 +15,14 @@ section#mat {
width: 96%; width: 96%;
transform: translateZ(calc(var(--z) * 1px + 0.1px)) transform: translateZ(calc(var(--z) * 1px + 0.1px))
rotateY(calc(var(--ry) * 1deg)); rotateY(calc(var(--ry) * 1deg));
transition: 0.2s scale;
cursor: pointer;
&:hover {
scale: 1.05;
}
.card-cover, .card-cover,
.card-back { .card-back {
width: 100%; width: 100% !important;
height: 100%; height: 100%;
position: absolute; position: absolute;
left: 0; left: 0;
......
...@@ -44,7 +44,7 @@ export const moveToHand = async (props: { card: CardType; api: SpringApi }) => { ...@@ -44,7 +44,7 @@ export const moveToHand = async (props: { card: CardType; api: SpringApi }) => {
const negativeX = Math.sin(angle) * r; const negativeX = Math.sin(angle) * r;
const negativeY = Math.cos(angle) * r + HAND_CARD_HEIGHT.value / 2; const negativeY = Math.cos(angle) * r + HAND_CARD_HEIGHT.value / 2;
const x = hand_circle_center_x + negativeX * (isMe(controller) ? 1 : -1); const x = hand_circle_center_x + negativeX * (isMe(controller) ? 1 : -1);
const y = hand_circle_center_y - negativeY + 130; // 常量 是手动调的 这里肯定有问题 有空来修 const y = hand_circle_center_y - negativeY + 140; // 常量 是手动调的 这里肯定有问题 有空来修
const _rz = (angle * 180) / Math.PI; const _rz = (angle * 180) / Math.PI;
......
...@@ -61,7 +61,7 @@ export const matConfig = { ...@@ -61,7 +61,7 @@ export const matConfig = {
unit: UNIT.PX, unit: UNIT.PX,
}, },
HAND_CARD_HEIGHT: { HAND_CARD_HEIGHT: {
value: 120, value: 140,
unit: UNIT.PX, unit: UNIT.PX,
}, },
DECK_OFFSET_X: { DECK_OFFSET_X: {
......
.skeleton-cover { .skeleton-cover {
background-color: gray; background-color: gray;
} }
.ygo-card {
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
}
...@@ -10,23 +10,30 @@ interface Props { ...@@ -10,23 +10,30 @@ interface Props {
isBack?: boolean; isBack?: boolean;
code?: number; code?: number;
style?: CSSProperties; style?: CSSProperties;
width?: number;
} }
export const YgoCard: FC<Props> = (props) => { export const YgoCard: FC<Props> = (props) => {
const { className, code: cardCode = 0, isBack = false, style } = props; const {
className,
code: cardCode = 0,
isBack = false,
width = 80,
style,
} = props;
return useMemo( return useMemo(
() => ( () => (
<> <>
{cardCode === 0 && !isBack ? ( {cardCode === 0 && !isBack ? (
<div <div
className={classNames("ygo-card", "skeleton-cover")} className={classNames("ygo-card", "skeleton-cover")}
style={style} style={{ width, ...style }}
/> />
) : ( ) : (
<img <img
className={classNames("ygo-card", className)} className={classNames("ygo-card", className)}
src={getCardImgUrl(cardCode, isBack)} src={getCardImgUrl(cardCode, isBack)}
style={style} style={{ width, ...style }}
/> />
)} )}
</> </>
......
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