Spaces:
Running
Running
File size: 6,245 Bytes
b2363b3 | 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 | class GeoToolbox extends HTMLElement {
constructor() {
super();
}
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
width: 280px;
background: white;
border-right: 1px solid #e5e7eb;
height: 100%;
overflow-y: auto;
}
.dark :host {
background: #1f2937;
border-right-color: #374151;
}
.header {
padding: 1rem;
border-bottom: 1px solid #e5e7eb;
}
.dark .header {
border-bottom-color: #374151;
}
h3 {
font-size: 0.875rem;
font-weight: 600;
color: #6b7280;
text-transform: uppercase;
letter-spacing: 0.05em;
margin: 0;
}
.category {
padding: 1rem;
border-bottom: 1px solid #e5e7eb;
}
.dark .category {
border-bottom-color: #374151;
}
.category-title {
font-size: 0.75rem;
font-weight: 600;
color: #9ca3af;
text-transform: uppercase;
letter-spacing: 0.05em;
margin-bottom: 0.75rem;
}
.tools-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 0.5rem;
}
.tool {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.25rem;
padding: 0.75rem;
border-radius: 0.5rem;
cursor: grab;
transition: all 0.2s;
background: #f9fafb;
border: 1px solid transparent;
}
.tool:hover {
background: #eef2ff;
border-color: #6366f1;
}
.tool:active {
cursor: grabbing;
}
.dark .tool {
background: #374151;
}
.dark .tool:hover {
background: rgba(99, 102, 241, 0.2);
}
.tool-icon {
width: 1.5rem;
height: 1.5rem;
color: #6366f1;
}
.tool-label {
font-size: 0.625rem;
font-weight: 500;
color: #4b5563;
text-align: center;
}
.dark .tool-label {
color: #d1d5db;
}
</style>
<div class="header">
<h3>🧰 Caixa de Ferramentas</h3>
</div>
<div class="category">
<div class="category-title">Campos Básicos</div>
<div class="tools-grid">
<div class="tool" draggable="true" data-type="text">
<svg class="tool-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 7V4h16v3"/><path d="M9 20h6"/><path d="M12 4v16"/></svg>
<span class="tool-label">Texto</span>
</div>
<div class="tool" draggable="true" data-type="textarea">
<svg class="tool-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 7h16"/><path d="M4 12h16"/><path d="M4 17h10"/></svg>
<span class="tool-label">Texto Longo</span>
</div>
<div class="tool" draggable="true" data-type="number">
<svg class="tool-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 17V9"/><path d="M8 17V5"/><path d="M12 17v-5"/><path d="M16 17V9"/><path d="M20 17V5"/></svg>
<span class="tool-label">Número</span>
</div>
<div class="tool" draggable="true" data-type="select">
<svg class="tool-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="m6 9 6 6 6-6"/></svg>
<span class="tool-label">Seleção</span>
</div>
</div>
</div>
<div class="category">
<div class="category-title">Campos Especiais</div>
<div class="tools-grid">
<div class="tool" draggable="true" data-type="date">
<svg class="tool-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/></svg>
<span class="tool-label">Data</span>
</div>
<div class="tool" draggable="true" data-type="photo">
<svg class="tool-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><rect x="3" y="3" width="18" height="18" rx="2" ry="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21 15 16 10 5 21"/></svg>
<span class="tool-label">Foto</span>
</div>
<div class="tool" draggable="true" data-type="map">
<svg class="tool-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="1 6 1 22 8 18 16 22 21 18 21 2 16 6 8 2 1 6"/><line x1="8" y1="2" x2="8" y2="18"/><line x1="16" y1="6" x2="16" y2="22"/></svg>
<span class="tool-label">Mapa</span>
</div>
<div class="tool" draggable="true" data-type="signature">
<svg class="tool-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 19l7-7 3 3-7 7-3-3z"/><path d="M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z"/><path d="M2 2l7.5 7.5"/><circle cx="11" cy="11" r="2"/></svg>
<span class="tool-label">Assinatura</span>
</div>
</div>
</div>
`;
// Add drag event listeners
this.shadowRoot.querySelectorAll('.tool').forEach(tool => {
tool.addEventListener('dragstart', (e) => {
e.dataTransfer.setData('fieldType', tool.dataset.type);
tool.style.opacity = '0.5';
});
tool.addEventListener('dragend', () => {
tool.style.opacity = '1';
});
});
}
}
customElements.define('geo-toolbox', GeoToolbox); |