File size: 7,482 Bytes
60c16c9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
class RewardPopup extends HTMLElement {
constructor() {
super();
this.visible = false;
}
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.render();
}
render() {
this.shadowRoot.innerHTML = `
<style>
:host {
display: ${this.visible ? 'block' : 'none'};
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
backdrop-filter: blur(5px);
z-index: 100;
display: flex;
justify-content: center;
align-items: center;
opacity: ${this.visible ? 1 : 0};
transition: opacity 0.3s ease;
}
.popup {
background: rgba(20, 20, 20, 0.9);
border-radius: 16px;
border: 2px solid var(--premium-glow);
box-shadow: 0 0 30px rgba(255, 140, 0, 0.5);
width: 90%;
max-width: 500px;
padding: 30px;
text-align: center;
position: relative;
overflow: hidden;
animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn {
0% { transform: scale(0.8); opacity: 0; }
100% { transform: scale(1); opacity: 1; }
}
.popup::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255, 140, 0, 0.1) 0%, transparent 70%);
z-index: -1;
}
.title {
font-size: 28px;
font-weight: bold;
margin-bottom: 20px;
background: linear-gradient(to right, var(--premium-gold), var(--premium-glow));
-webkit-background-clip: text;
background-clip: text;
color: transparent;
text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}
.reward-details {
margin-bottom: 30px;
}
.reward-line {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
font-size: 16px;
color: rgba(255, 255, 255, 0.8);
}
.final-reward {
font-size: 36px;
font-weight: bold;
margin: 20px 0;
color: var(--premium-gold);
text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.continue-btn {
padding: 12px 30px;
border-radius: 25px;
background: linear-gradient(to right, var(--premium-gold), var(--premium-glow));
color: var(--premium-dark);
font-weight: bold;
border: none;
cursor: pointer;
transition: transform 0.2s, box-shadow 0.2s;
}
.continue-btn:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(255, 140, 0, 0.4);
}
.confetti {
position: absolute;
width: 10px;
height: 10px;
background: var(--premium-gold);
opacity: 0;
}
</style>
<div class="popup">
<h2 class="title">WIN REVEALED!</h2>
<div class="reward-details">
<div class="reward-line">
<span>Base Reward:</span>
<span id="baseReward">0 SC</span>
</div>
<div class="reward-line">
<span>Multiplier:</span>
<span id="multiplier">×0</span>
</div>
</div>
<div class="final-reward" id="finalReward">0 SC</div>
<button class="continue-btn" id="continueBtn">Continue</button>
</div>
`;
// Add event listener for continue button
if (this.shadowRoot.getElementById('continueBtn')) {
this.shadowRoot.getElementById('continueBtn').addEventListener('click', () => this.hide());
}
}
show(data) {
this.visible = true;
this.render();
// Update reward details
if (data) {
this.shadowRoot.getElementById('baseReward').textContent = `${data.baseReward} SC`;
this.shadowRoot.getElementById('multiplier').textContent = `×${data.multiplier}`;
this.shadowRoot.getElementById('finalReward').textContent = `${data.finalReward} SC`;
// Add rarity class for additional styling
const finalRewardElement = this.shadowRoot.getElementById('finalReward');
finalRewardElement.className = 'final-reward ' + data.rarity;
}
// Create confetti effect
this.createConfetti();
}
hide() {
this.visible = false;
this.render();
}
createConfetti() {
const popup = this.shadowRoot.querySelector('.popup');
for (let i = 0; i < 50; i++) {
const confetti = document.createElement('div');
confetti.className = 'confetti';
confetti.style.left = Math.random() * 100 + '%';
confetti.style.top = -10 + 'px';
confetti.style.backgroundColor = i % 2 === 0 ? 'var(--premium-gold)' : 'var(--premium-glow)';
confetti.style.transform = `rotate(${Math.random() * 360}deg)`;
popup.appendChild(confetti);
// Animate confetti
const animation = confetti.animate([
{ top: -10 + 'px', opacity: 1, transform: `rotate(${Math.random() * 360}deg)` },
{ top: 100 + 'px', opacity: 0, transform: `rotate(${Math.random() * 360}deg)` }
], {
duration: 1000 + Math.random() * 2000,
delay: Math.random() * 1000,
easing: 'cubic-bezier(0.1, 0.8, 0.9, 1)'
});
animation.onfinish = () => confetti.remove();
}
}
}
customElements.define('reward-popup', RewardPopup); |