File size: 7,540 Bytes
19e5d94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
class CustomSidebar extends HTMLElement {
    connectedCallback() {
        this.attachShadow({ mode: 'open' });
        this.shadowRoot.innerHTML = `
            <style>
                .sidebar {
                    background: white;
                    border-radius: 12px;
                    padding: 1.5rem;
                    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
                }
                
                .sidebar-section {
                    margin-bottom: 2rem;
                }
                
                .sidebar-title {
                    font-size: 1.125rem;
                    font-weight: 600;
                    color: #1f2937;
                    margin-bottom: 1rem;
                    display: flex;
                    align-items: center;
                }
                
                .sidebar-title i {
                    margin-right: 0.5rem;
                }
                
                .element-btn {
                    display: flex;
                    align-items: center;
                    width: 100%;
                    padding: 0.75rem 1rem;
                    border: 1px solid #e5e7eb;
                    border-radius: 8px;
                    margin-bottom: 0.5rem;
                    cursor: pointer;
                    transition: all 0.2s ease;
                    background: white;
                }
                
                .element-btn:hover {
                    background: #f3f4f6;
                    border-color: #3B82F6;
                }
                
                .element-btn i {
                    margin-right: 0.5rem;
                }
                
                .slide-thumbnail {
                    width: 100%;
                    aspect-ratio: 16/9;
                    background: #f8fafc;
                    border: 2px dashed #cbd5e1;
                    border-radius: 8px;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    margin-bottom: 0.75rem;
                    cursor: pointer;
                    transition: all 0.2s ease;
                }
                
                .slide-thumbnail:hover {
                    border-color: #3B82F6;
                    background: #eff6ff;
                }
                
                .slide-thumbnail.active {
                    border-color: #1E40AF;
                    background: #dbeafe;
                }
            </style>
            <div class="sidebar">
                <div class="sidebar-section">
                    <h3 class="sidebar-title">
                        <i data-feather="plus"></i>
                        Add Elements
                    </h3>
                    <button class="element-btn" data-type="text">
                        <i data-feather="type"></i>
                        Text Box
                    </button>
                    <button class="element-btn" data-type="image">
                        <i data-feather="image"></i>
                        Image
                    </button>
                    <button class="element-btn" data-type="shape">
                        <i data-feather="square"></i>
                        Shape
                    </button>
                    <button class="element-btn" data-type="chart">
                        <i data-feather="bar-chart-2"></i>
                        Chart
                    </button>
                </div>
                
                <div class="sidebar-section">
                    <h3 class="sidebar-title">
                        <i data-feather="layers"></i>
                        Slides
                    </h3>
                    <div class="slide-thumbnail active">
                        <i data-feather="file-text" class="text-gray-400"></i>
                    </div>
                    <div class="slide-thumbnail">
                        <i data-feather="file-text" class="text-gray-400"></i>
                    </div>
                    <div class="slide-thumbnail">
                        <i data-feather="file-text" class="text-gray-400"></i>
                    </div>
                </div>
                
                <div class="sidebar-section">
                    <h3 class="sidebar-title">
                        <i data-feather="settings"></i>
                        Properties
                    </h3>
                    <div class="property-control">
                        <label class="block text-sm text-gray-600 mb-1">Font Size</label>
                        <input type="range" min="8" max="72" value="16" class="w-full">
                    </div>
                </div>
            </div>
        `;
        
        // Add event listeners for element buttons
        setTimeout(() => {
            const buttons = this.shadowRoot.querySelectorAll('.element-btn');
            buttons.forEach(button => {
                button.addEventListener('click', () => {
                    const type = button.getAttribute('data-type');
                    this.addElement(type);
                });
            }, 100);
        });
    }
    
    addElement(type) {
        const canvasContainer = document.getElementById('canvasContainer');
        let newElement;
        
        switch(type) {
            case 'text':
                newElement = document.createElement('div');
                newElement.className = 'editable-element';
                newElement.setAttribute('contenteditable', 'true');
                newElement.style.position = 'absolute';
                newElement.style.left = '100px';
                newElement.style.top = '100px';
                newElement.style.padding = '10px';
                newElement.style.background = 'white';
                newElement.style.border = '1px solid #e5e7eb';
                newElement.style.borderRadius = '6px';
                newElement.style.minWidth = '200px';
                newElement.style.minHeight = '40px';
                newElement.style.zIndex = '1000';
                newElement.textContent = 'Double click to edit text';
                break;
                
            case 'image':
                newElement = document.createElement('div');
                newElement.className = 'editable-element';
                newElement.style.position = 'absolute';
                newElement.style.left = '150px';
                newElement.style.top = '150px';
                newElement.style.width = '200px';
                newElement.style.height = '150px';
                newElement.style.background = '#f3f4f6';
                newElement.style.border = '2px dashed #d1d5db';
                newElement.style.borderRadius = '6px';
                newElement.style.display = 'flex';
                newElement.style.alignItems = 'center';
                newElement.style.justifyContent = 'center';
                newElement.innerHTML = `
                    <i data-feather="image" class="text-gray-400"></i>
                    <span class="ml-2 text-gray-500">Add Image</span>
                `;
                break;
                
            case 'chart':
                newElement = document.createElement('div');
                newElement.className = 'editable-element';
                newElement.style.position = 'absolute';
                newElement.style.left = '200px';
                newElement.style.top = '200px';
                newElement.style.width = '300