File size: 4,920 Bytes
2dff984
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class CustomFileCard extends HTMLElement {
    static get observedAttributes() {
        return ['status'];
    }
    
    constructor() {
        super();
        this.attachShadow({ mode: 'open' });
    }
    
    connectedCallback() {
        this.render();
    }
    
    attributeChangedCallback(name, oldValue, newValue) {
        if (name === 'status') {
            this.render();
        }
    }
    
    render() {
        const name = this.getAttribute('name') || 'Untitled';
        const status = this.getAttribute('status') || 'pending';
        
        let statusText, statusColor, icon;
        
        switch(status) {
            case 'pending':
                statusText = 'Analyzing...';
                statusColor = 'bg-yellow-500';
                icon = 'clock';
                break;
            case 'safe':
                statusText = 'Secure';
                statusColor = 'bg-green-500';
                icon = 'check-circle';
                break;
            case 'vulnerable':
                statusText = 'Vulnerable';
                statusColor = 'bg-red-500';
                icon = 'alert-triangle';
                break;
            case 'error':
                statusText = 'Error';
                statusColor = 'bg-gray-500';
                icon = 'x-circle';
                break;
            default:
                statusText = 'Unknown';
                statusColor = 'bg-gray-500';
                icon = 'help-circle';
        }
        
        this.shadowRoot.innerHTML = `
            <style>
                .card {
                    background-color: white;
                    border-radius: 0.75rem;
                    overflow: hidden;
                    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
                    transition: all 0.3s ease;
                }
                .card:hover {
                    transform: translateY(-2px);
                    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
                }
                .card-header {
                    padding: 1.5rem;
                    border-bottom: 1px solid #e5e7eb;
                }
                .card-title {
                    font-size: 1.25rem;
                    font-weight: 600;
                    color: #1f2937;
                    margin-bottom: 0.5rem;
                    white-space: nowrap;
                    overflow: hidden;
                    text-overflow: ellipsis;
                }
                .card-body {
                    padding: 1.5rem;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                }
                .status {
                    display: inline-flex;
                    align-items: center;
                    padding: 0.25rem 0.75rem;
                    border-radius: 9999px;
                    font-size: 0.875rem;
                    font-weight: 500;
                    color: white;
                }
                .icon {
                    width: 3rem;
                    height: 3rem;
                    margin-bottom: 1rem;
                }
                .progress-bar {
                    width: 100%;
                    height: 0.5rem;
                    background-color: #e5e7eb;
                    border-radius: 0.25rem;
                    overflow: hidden;
                    margin-top: 1rem;
                }
                .progress {
                    height: 100%;
                    background-color: #3b82f6;
                    width: ${status === 'pending' ? '50%' : '100%'};
                    animation: ${status === 'pending' ? 'pulse 2s infinite' : 'none'};
                }
                @keyframes pulse {
                    0% { opacity: 0.6; }
                    50% { opacity: 1; }
                    100% { opacity: 0.6; }
                }
            </style>
            
            <div class="card">
                <div class="card-header">
                    <h3 class="card-title">${name}</h3>
                    <div class="status ${statusColor}">
                        <i data-feather="${icon}" class="mr-1" width="14" height="14"></i>
                        ${statusText}
                    </div>
                </div>
                <div class="card-body">
                    <i data-feather="${icon === 'clock' ? 'code' : icon}" class="icon" width="48" height="48"></i>
                    <div class="progress-bar">
                        <div class="progress"></div>
                    </div>
                </div>
            </div>
        `;
        
        // Replace feather icons
        if (this.shadowRoot.querySelector('[data-feather]')) {
            feather.replace();
        }
    }
}

customElements.define('custom-file-card', CustomFileCard);