Defkhan5960's picture
try to use same desing for clouds in the attaching media!
4c7a4fd verified
class CloudElement extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
const text = this.getAttribute('text') || '';
const percentage = this.getAttribute('percentage') || '0';
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
position: absolute;
transform: translate(-50%, -50%);
}
.cloud-container {
position: relative;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: transform 0.3s ease;
}
.cloud-container:hover {
transform: translate(-50%, -50%) scale(1.05);
}
.cloud-body {
position: relative;
background: linear-gradient(145deg, #ffffff, #f0f9ff);
border-radius: 50%;
box-shadow:
0 8px 32px rgba(31, 38, 135, 0.15),
inset 0 4px 12px rgba(255, 255, 255, 0.8),
inset 0 -4px 8px rgba(200, 220, 255, 0.3);
display: flex;
align-items: center;
justify-content: center;
backdrop-filter: blur(2px);
border: 1px solid rgba(255, 255, 255, 0.5);
}
.cloud-text-container {
position: relative;
z-index: 3;
text-align: center;
padding: 15px;
max-width: 80%;
}
.cloud-text {
font-weight: 600;
color: #2d3748;
text-shadow: 0 1px 2px rgba(255, 255, 255, 0.8);
font-size: 14px;
line-height: 1.3;
}
.cloud-percentage {
font-size: 12px;
display: block;
margin-top: 6px;
color: #4a5568;
font-weight: 500;
}
.cloud-fluff {
position: absolute;
background: linear-gradient(145deg, #ffffff, #f8fbff);
border-radius: 50%;
box-shadow:
inset 0 2px 8px rgba(200, 220, 255, 0.4),
inset 0 -2px 6px rgba(255, 255, 255, 0.9);
border: 1px solid rgba(255, 255, 255, 0.6);
}
.fluff-1 {
width: 70%;
height: 70%;
top: -20%;
left: 15%;
}
.fluff-2 {
width: 60%;
height: 60%;
bottom: -15%;
right: 10%;
}
.fluff-3 {
width: 50%;
height: 50%;
top: 10%;
left: -10%;
}
.fluff-4 {
width: 45%;
height: 45%;
bottom: 15%;
right: -8%;
}
</style>
<div class="cloud-container">
<div class="cloud-body">
<div class="cloud-fluff fluff-1"></div>
<div class="cloud-fluff fluff-2"></div>
<div class="cloud-fluff fluff-3"></div>
<div class="cloud-fluff fluff-4"></div>
<div class="cloud-text-container">
<div class="cloud-text">
${text}
<span class="cloud-percentage">${percentage}%</span>
</div>
</div>
</div>
</div>
`;
// Set cloud size based on percentage
const cloudBody = this.shadowRoot.querySelector('.cloud-body');
const baseSize = 120;
const size = baseSize * (0.7 + (parseInt(percentage) / 150));
cloudBody.style.width = `${size}px`;
cloudBody.style.height = `${size * 0.7}px`;
}
}
customElements.define('custom-cloud', CloudElement);