Skip to content

Commit 224c212

Browse files
committed
Добавлен компонент WaifuRoulettePrizeItem для рендеринга призов в рулетке. Обновлено управление высотой элемента рулетки для улучшения отображения. Улучшена логика рендеринга призов с использованием нового компонента.
1 parent 8647eba commit 224c212

File tree

3 files changed

+134
-1
lines changed

3 files changed

+134
-1
lines changed

src/components/OBS_Components/WaifuAlerts/WaifuRoulette.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import animate from "@/shared/styles/animate.module.scss";
88
import { getRandomColor } from "@/shared/Utils";
99

1010
import styles2 from "../OBSCommon.module.scss";
11+
import WaifuRoulettePrizeItem from "./components/WaifuRoulettePrizeItem";
1112
import styles from "./WaifuAlerts.module.scss";
1213

1314
interface Props {
@@ -73,7 +74,7 @@ export default function WaifuRoulette({
7374
top: "50%",
7475
left: "50%",
7576
width: "4px",
76-
height: `${heightDiv.current!.offsetHeight}px`,
77+
height: `100%`,
7778
background: "orange",
7879
zIndex: 10,
7980
transform: "translate(-50%, -50%)",
@@ -93,6 +94,9 @@ export default function WaifuRoulette({
9394
prizesWithText: true,
9495
hideCenterDelimiter: true,
9596
}}
97+
prizeItemRenderFunction={prize => (
98+
<WaifuRoulettePrizeItem image={prize.image} text={prize.text} />
99+
)}
96100
onPrizeDefined={() => {
97101
setVisible(false);
98102
const div = rouletteDiv.current!;
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
.figure {
2+
position: relative;
3+
width: 190px;
4+
margin: 0;
5+
perspective: 900px;
6+
display: flex;
7+
flex-direction: column;
8+
align-items: center;
9+
justify-content: flex-start;
10+
gap: 16px;
11+
}
12+
13+
.inner {
14+
position: relative;
15+
width: 180px;
16+
height: 240px;
17+
border-radius: 18px;
18+
overflow: hidden;
19+
box-shadow: var(--site-shadow-medium);
20+
background: var(--primary-gradient);
21+
transform-style: preserve-3d;
22+
transition: transform 220ms ease, box-shadow 220ms ease;
23+
}
24+
25+
.inner::before {
26+
content: "";
27+
position: absolute;
28+
inset: 0;
29+
background: linear-gradient(
30+
135deg,
31+
rgba(255, 255, 255, 0.12),
32+
rgba(0, 0, 0, 0.18)
33+
);
34+
mix-blend-mode: soft-light;
35+
z-index: 1;
36+
}
37+
38+
.image {
39+
position: absolute;
40+
inset: 0;
41+
width: 100%;
42+
height: 100%;
43+
object-fit: fill;
44+
transform: translateZ(0);
45+
}
46+
47+
.inner:hover {
48+
transform: rotateX(6deg) rotateY(-6deg) scale3d(1.03, 1.03, 1.03);
49+
box-shadow: var(--site-shadow-heavy);
50+
}
51+
52+
.caption {
53+
pointer-events: none;
54+
padding: 6px 12px;
55+
border-radius: 999px;
56+
background-color: rgba(255, 255, 255, 0.85);
57+
color: var(--site-text-dark);
58+
font-size: 14px;
59+
font-weight: 600;
60+
letter-spacing: 0.04em;
61+
text-transform: uppercase;
62+
box-shadow: var(--site-shadow-light);
63+
transform: translateZ(45px);
64+
position: absolute;
65+
bottom: 20px;
66+
}
67+
68+
.caption span {
69+
display: block;
70+
max-width: 160px;
71+
text-align: center;
72+
white-space: nowrap;
73+
overflow: hidden;
74+
text-overflow: ellipsis;
75+
}
76+
77+
@media (max-width: 1280px) {
78+
.figure {
79+
width: 180px;
80+
margin: 0 8px;
81+
gap: 12px;
82+
}
83+
84+
.inner {
85+
width: 160px;
86+
height: 210px;
87+
}
88+
}
89+
90+
@media (hover: none) {
91+
.inner:hover {
92+
transform: none;
93+
box-shadow: var(--site-shadow-medium);
94+
}
95+
}
96+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import styles from "./WaifuRoulettePrizeItem.module.scss";
2+
3+
interface WaifuRoulettePrizeItemProps {
4+
image: string;
5+
text?: string;
6+
}
7+
8+
export default function WaifuRoulettePrizeItem({
9+
image,
10+
text,
11+
}: WaifuRoulettePrizeItemProps) {
12+
if (image) {
13+
return (
14+
<figure className={styles.figure}>
15+
<div className={styles.inner}>
16+
<img
17+
src={image}
18+
alt={text || ""}
19+
className={styles.image}
20+
loading="lazy"
21+
/>
22+
</div>
23+
{text && text.trim().length > 0 ? (
24+
<figcaption className={styles.caption}>
25+
<span>{text}</span>
26+
</figcaption>
27+
) : null}
28+
</figure>
29+
);
30+
}
31+
32+
return null;
33+
}

0 commit comments

Comments
 (0)