File size: 4,243 Bytes
509f3c2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class CustomProblemCard extends HTMLElement {
  constructor() {
    super();
    this.title = this.getAttribute('title') || 'Challenge';
    this.language = this.getAttribute('language') || 'Python';
    this.difficulty = this.getAttribute('difficulty') || 'Easy';
    this.time = this.getAttribute('time') || '15 min';
    this.description = this.getAttribute('description') || 'Description';
    this.status = this.getAttribute('status') || 'free';
  }

  connectedCallback() {
    this.attachShadow({ mode: 'open' });
    this.shadowRoot.innerHTML = `
      <style>
        :host {
          display: block;
        }
        .problem-card {
          background: rgba(31, 41, 55, 0.7);
          border: 1px solid rgba(55, 65, 81, 0.3);
          border-radius: 1rem;
          padding: 1.5rem;
          transition: all 0.3s ease;
          height: 100%;
          position: relative;
          overflow: hidden;
        }
        .problem-card::before {
          content: '';
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          height: 3px;
          background: linear-gradient(90deg, #22c55e, #d946ef);
          opacity: 0;
          transition: opacity 0.3s ease;
        }
        .problem-card:hover::before {
          opacity: 1;
        }
        .language-badge {
          display: inline-block;
          padding: 0.25rem 0.75rem;
          border-radius: 9999px;
          font-size: 0.75rem;
          font-weight: 600;
        }
        .python-badge {
          background: rgba(34, 197, 94, 0.15);
          color: #22c55e;
        }
        .sql-badge {
          background: rgba(217, 70, 239, 0.15);
          color: #d946ef;
        }
        .difficulty-badge {
          display: inline-flex;
          align-items: center;
          padding: 0.25rem 0.75rem;
          border-radius: 9999px;
          font-size: 0.75rem;
          font-weight: 600;
        }
        .difficulty-easy {
          background: rgba(34, 197, 94, 0.1);
          border: 1px solid rgba(34, 197, 94, 0.3);
          color: #22c55e;
        }
        .difficulty-medium {
          background: rgba(245, 158, 11, 0.1);
          border: 1px solid rgba(245, 158, 11, 0.3);
          color: #f59e0b;
        }
        .status-ribbon {
          position: absolute;
          top: 0;
          right: 0;
          padding: 0.25rem 1rem;
          font-size: 0.75rem;
          font-weight: 600;
          border-radius: 0.375rem 1rem 0.375rem 0.375rem;
          font-size: 0.75rem;
        }
        .status-free {
          background: rgba(34, 197, 94, 0.2);
          color: #22c55e;
        }
        .status-premium {
          background: rgba(217, 70, 239, 0.2);
          color: #d946ef;
        }
        .hover-lift:hover {
          transform: translateY(-3px);
          box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
        }
      </style>
      <div class="problem-card fade-in hover-lift">
          ${this.status !== 'free' ? 
            `<div class="status-ribbon ${this.status === 'premium' ? 'status-premium' : ''}">
            ${this.status.toUpperCase()}
          </div>` : ''}
          
          <div class="flex justify-between items-start mb-4">
            <div class="language-badge ${this.language === 'Python' ? 'python-badge' : 'sql-badge'}">
            ${this.language}
          </div>
        </div>
        
        <h3 class="text-xl font-bold mb-3">${this.title}</h3>
        
        <p class="text-gray-300 mb-6">${this.description}</p>
        
        <div class="flex justify-between items-center">
          <div class="flex items-center">
            <div class="difficulty-badge ${this.difficulty.toLowerCase() === 'easy' ? 'difficulty-easy' : 'difficulty-medium'}">
              ${this.difficulty}
            </div>
            <div class="text-gray-400 text-sm flex items-center">
              <i data-feather="clock" class="w-4 h-4 mr-1"></i>
              ${this.time}
            </div>
          </div>
        </div>
      </div>
    `;
    
    setTimeout(() => {
      if (typeof feather !== 'undefined') {
        feather.replace();
      }
    }, 100);
  }
}

customElements.define('custom-problem-card', CustomProblemCard);