File size: 4,799 Bytes
19bec0f
c262010
 
 
 
 
 
 
 
 
 
 
 
 
19bec0f
 
 
c262010
 
4c7a4fd
 
 
 
c262010
 
 
 
4c7a4fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c262010
4c7a4fd
19bec0f
4c7a4fd
 
c262010
 
 
4c7a4fd
 
 
 
 
c262010
 
 
4c7a4fd
c262010
4c7a4fd
 
 
c262010
 
4c7a4fd
c262010
4c7a4fd
c262010
4c7a4fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c262010
 
4c7a4fd
 
 
 
 
 
 
 
 
 
 
 
c262010
 
 
 
 
4c7a4fd
 
 
 
 
c262010
 
 
19bec0f
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

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);