-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhelper.js
More file actions
72 lines (61 loc) · 2.53 KB
/
helper.js
File metadata and controls
72 lines (61 loc) · 2.53 KB
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
export function addAlphaToColor(hex, alpha) {
if (!hex.startsWith('#')) return hex;
const v = hex.slice(1);
const r = parseInt(v.slice(0,2),16);
const g = parseInt(v.slice(2,4),16);
const b = parseInt(v.slice(4,6),16);
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
}
export function getRandomColorPair() {
const colors = [
{ bg: '#3b82f6', text: '#ffffff' },
{ bg: '#ef4444', text: '#ffffff' },
{ bg: '#10b981', text: '#ffffff' },
{ bg: '#f59e0b', text: '#000000' }
];
return colors[Math.floor(Math.random() * colors.length)];
}
var isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0;
console.log(isMac)
if (!isMac) {
document.querySelector('#titlebar').style.backgroundColor = 'black';
document.querySelector('#state-details').style.left = '48px';
document.querySelector('#version').style.left = '12px';
document.querySelector('#state-details').style.backgroundColor = 'white';
document.querySelector('#version').style.color = 'white';
}
document.querySelector('.slide-state-btn').addEventListener('click', () => {
document.querySelector('#slide-state-container').classList.toggle('hidden');
})
document.querySelector('#slide-state-close-btn').addEventListener('click', () => {
document.querySelector('#state-details-container').classList.toggle('hidden');
})
class DrawingControls {
constructor() {
this.toggleBtn = document.getElementById('toggleControls');
this.container = document.getElementById('controlsContainer');
this.isExpanded = true;
this.toggleBtn.addEventListener('click', () => this.toggle());
// Restore previous state
const savedState = localStorage.getItem('drawingControlsState');
if (savedState === 'false') {
this.toggle(false);
}
}
toggle(force) {
this.isExpanded = force !== undefined ? force : !this.isExpanded;
this.container.classList.toggle('hidden', !this.isExpanded);
this.toggleBtn.setAttribute('aria-expanded', this.isExpanded);
localStorage.setItem('drawingControlsState', this.isExpanded);
}
}
// Initialize when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
window.drawingControls = new DrawingControls();
});
export function updateStrokeColor() {
const strokeColor = document.querySelector('#color')
const strokeColorValue = document.getAttribute('data-value')
const strokeColorText = document.querySelector('#color-text')
strokeColorText.textContent = strokeColorValue
}