Skip to content

Commit c715322

Browse files
committed
Add tools options
1 parent 666cb7c commit c715322

File tree

6 files changed

+247
-24
lines changed

6 files changed

+247
-24
lines changed

examples/led-matrix-painter/assets/app.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,3 +980,47 @@ if (invertNotNullBtn) {
980980
} else {
981981
console.warn('[ui] invert-not-null button not found');
982982
}
983+
984+
/* Custom Select Dropdown */
985+
document.addEventListener('DOMContentLoaded', () => {
986+
const customSelect = document.querySelector('.custom-select');
987+
if (customSelect) {
988+
const trigger = customSelect.querySelector('.custom-select__trigger');
989+
const options = customSelect.querySelectorAll('.custom-option');
990+
const triggerImage = trigger.querySelector('img');
991+
992+
trigger.addEventListener('click', () => {
993+
customSelect.classList.toggle('open');
994+
});
995+
996+
options.forEach(option => {
997+
option.addEventListener('click', () => {
998+
const value = option.getAttribute('data-value');
999+
const img = option.querySelector('img');
1000+
1001+
triggerImage.src = img.src;
1002+
triggerImage.alt = img.alt;
1003+
customSelect.classList.remove('open');
1004+
1005+
// You can use the 'value' variable to handle tool changes
1006+
console.log('Selected tool:', value);
1007+
});
1008+
});
1009+
1010+
window.addEventListener('click', (e) => {
1011+
if (!customSelect.contains(e.target)) {
1012+
customSelect.classList.remove('open');
1013+
}
1014+
});
1015+
}
1016+
1017+
/* Brightness Alpha Slider */
1018+
const brightnessAlphaSlider = document.getElementById('brightness-alpha-slider');
1019+
const brightnessAlphaValue = document.getElementById('brightness-alpha-value');
1020+
1021+
if (brightnessAlphaSlider && brightnessAlphaValue) {
1022+
brightnessAlphaSlider.addEventListener('input', () => {
1023+
brightnessAlphaValue.textContent = brightnessAlphaSlider.value;
1024+
});
1025+
}
1026+
});
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading

examples/led-matrix-painter/assets/index.html

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,44 @@
3737
<div class="left-sidebar">
3838
<div class="tools-box">
3939
<h3 class="box-title">Tools</h3>
40+
<div class="tool-controls">
41+
<div class="custom-select-wrapper">
42+
<div class="custom-select">
43+
<div class="custom-select__trigger">
44+
<svg width="16" height="16" viewBox="0 0 32 32" class="tool-icon" style="vertical-align: middle;">
45+
<path d="M27.3302 3.68976C24.2702 3.61975 19.9002 6.40973 14.3702 11.9697C12.4701 13.8798 11.0802 15.4898 10.6601 15.9797C8.11016 16.1898 6.09027 18.3298 6.09027 20.9298C6.09027 22.9598 5.20013 24.8597 3.65021 26.1498C3.35016 26.4097 3.22016 26.8098 3.33026 27.1898C3.44012 27.5698 3.76019 27.8497 4.15021 27.9097C4.73017 27.9898 5.32025 28.0397 5.90021 28.0397C7.52021 28.0397 9.11017 27.7197 10.5903 27.1097C12.0702 26.4998 13.4301 25.5997 14.5803 24.4498C15.4301 23.6097 15.9301 22.5198 16.0202 21.3398C16.2201 21.1697 16.6102 20.8298 17.1302 20.3698C17.8802 19.6998 18.9002 18.7498 20.0302 17.6298C25.5903 12.0997 28.3802 7.73975 28.3102 4.66974C28.3002 4.12976 27.8702 3.69977 27.3302 3.68976ZM13.1701 23.0397C11.3802 24.8298 8.97014 25.8798 6.47014 26.0198C7.51018 24.5498 8.09026 22.7798 8.09026 20.9298C8.09026 19.2897 9.4301 17.9598 11.0702 17.9598C11.8501 17.9598 12.6202 18.2798 13.1701 18.8298C13.7301 19.3898 14.0402 20.1398 14.0402 20.9298C14.0402 21.7298 13.7301 22.4697 13.1701 23.0397ZM15.6601 18.9998C15.4101 18.4097 15.0502 17.8698 14.5903 17.4097C14.1302 16.9598 13.5903 16.5997 12.9902 16.3497C13.5402 15.7397 14.3002 14.9097 15.2001 13.9797C15.7201 14.3798 16.2302 14.8098 16.7101 15.2897C17.1901 15.7698 17.6202 16.2798 18.0202 16.7997C17.0903 17.6898 16.2702 18.4498 15.6601 18.9998ZM19.4501 15.3798C19.0502 14.8597 18.6001 14.3597 18.1202 13.8798C17.6402 13.3998 17.1402 12.9498 16.6202 12.5497C20.5402 8.72973 23.8501 6.40973 26.1701 5.82977C25.5903 8.14978 23.2702 11.4598 19.4501 15.3798Z"/>
46+
</svg>
47+
<svg width="7" height="4" viewBox="0 0 7 4" class="dropdown-arrow" xmlns="http://www.w3.org/2000/svg">
48+
<path d="M3.50205 4.00205C3.43624 4.00243 3.37101 3.98981 3.31009 3.96493C3.24917 3.94005 3.19377 3.90339 3.14705 3.85705L0.147046 0.857046C0.0528938 0.762894 0 0.635196 0 0.502046C0 0.368895 0.0528938 0.241197 0.147046 0.147046C0.241197 0.0528938 0.368895 0 0.502046 0C0.635196 0 0.762894 0.0528938 0.857046 0.147046L3.50205 2.79705L6.14705 0.147046C6.2412 0.0528938 6.36889 0 6.50205 0C6.6352 0 6.76289 0.0528938 6.85705 0.147046C6.9512 0.241197 7.00409 0.368895 7.00409 0.502046C7.00409 0.635196 6.9512 0.762894 6.85705 0.857046L3.85705 3.85705C3.81033 3.90339 3.75492 3.94005 3.694 3.96493C3.63308 3.98981 3.56785 4.00243 3.50205 4.00205Z" fill="#008184"/>
49+
</svg>
50+
</div>
51+
<div class="custom-options">
52+
<div class="custom-option" data-value="brush">
53+
<svg width="16" height="16" viewBox="0 0 32 32" class="tool-icon" style="vertical-align: middle;">
54+
<path d="M27.3302 3.68976C24.2702 3.61975 19.9002 6.40973 14.3702 11.9697C12.4701 13.8798 11.0802 15.4898 10.6601 15.9797C8.11016 16.1898 6.09027 18.3298 6.09027 20.9298C6.09027 22.9598 5.20013 24.8597 3.65021 26.1498C3.35016 26.4097 3.22016 26.8098 3.33026 27.1898C3.44012 27.5698 3.76019 27.8497 4.15021 27.9097C4.73017 27.9898 5.32025 28.0397 5.90021 28.0397C7.52021 28.0397 9.11017 27.7197 10.5903 27.1097C12.0702 26.4998 13.4301 25.5997 14.5803 24.4498C15.4301 23.6097 15.9301 22.5198 16.0202 21.3398C16.2201 21.1697 16.6102 20.8298 17.1302 20.3698C17.8802 19.6998 18.9002 18.7498 20.0302 17.6298C25.5903 12.0997 28.3802 7.73975 28.3102 4.66974C28.3002 4.12976 27.8702 3.69977 27.3302 3.68976ZM13.1701 23.0397C11.3802 24.8298 8.97014 25.8798 6.47014 26.0198C7.51018 24.5498 8.09026 22.7798 8.09026 20.9298C8.09026 19.2897 9.4301 17.9598 11.0702 17.9598C11.8501 17.9598 12.6202 18.2798 13.1701 18.8298C13.7301 19.3898 14.0402 20.1398 14.0402 20.9298C14.0402 21.7298 13.7301 22.4697 13.1701 23.0397ZM15.6601 18.9998C15.4101 18.4097 15.0502 17.8698 14.5903 17.4097C14.1302 16.9598 13.5903 16.5997 12.9902 16.3497C13.5402 15.7397 14.3002 14.9097 15.2001 13.9797C15.7201 14.3798 16.2302 14.8098 16.7101 15.2897C17.1901 15.7698 17.6202 16.2798 18.0202 16.7997C17.0903 17.6898 16.2702 18.4498 15.6601 18.9998ZM19.4501 15.3798C19.0502 14.8597 18.6001 14.3597 18.1202 13.8798C17.6402 13.3998 17.1402 12.9498 16.6202 12.5497C20.5402 8.72973 23.8501 6.40973 26.1701 5.82977C25.5903 8.14978 23.2702 11.4598 19.4501 15.3798Z"/>
55+
</svg>
56+
</div>
57+
<div class="custom-option" data-value="eraser">
58+
<svg width="16" height="16" viewBox="0 0 32 32" class="tool-icon" style="vertical-align: middle;">
59+
<path d="M25,5 L7,23 L9,25 L27,7 L25,5 Z M5,25 L7,23 L9,25 L7,27 L5,25 Z"/>
60+
</svg>
61+
</div>
62+
</div>
63+
</div>
64+
</div>
65+
66+
<div class="slider-container" style="flex-grow: 1; margin-left: 8px;">
67+
<div style="display: flex; justify-content: space-between;">
68+
<label for="brightness-alpha-slider" class="alpha-label">Brightness (Alpha)</label>
69+
<span id="brightness-alpha-value" class="alpha-label">7</span>
70+
</div>
71+
<div style="display: flex; align-items: center; gap: 8px;">
72+
<span class="slider-limit-label">0</span>
73+
<input type="range" id="brightness-alpha-slider" min="0" max="7" value="7" style="flex-grow: 1;">
74+
<span class="slider-limit-label">7</span>
75+
</div>
76+
</div>
77+
</div>
4078
</div>
4179
<div class="transform-box">
4280
<h3 class="box-title">Transform</h3>
@@ -63,12 +101,6 @@ <h3 class="box-title" id="frame-title">Frame 1</h3>
63101
<section class="maincol">
64102
<div id="grid" class="grid"></div>
65103
<div id="export-tools">
66-
<button id="play-animation">Play Animation</button>
67-
</div>
68-
<!-- floating brightness slider -->
69-
<div id="cell-slider">
70-
<input id="brightness-slider" type="range" min="0" max="7" value="7" />
71-
<div id="brightness-value">7</div>
72104
</div>
73105
</section>
74106
</div>
@@ -84,6 +116,7 @@ <h3 class="box-title">Project code preview</h3>
84116
<div class="sidebar-header">
85117
<h3 style="margin:0;font-size:0.9rem;color:#666">Frames (auto-saved)</h3>
86118
<button id="new-frame" title="Create new frame">+</button>
119+
<button id="play-animation">Play Animation</button>
87120
</div>
88121
<div>
89122
<label><input type="radio" name="mode" value="frames" checked> Frames</label>
@@ -103,4 +136,4 @@ <h3 style="margin:0;font-size:0.9rem;color:#666">Frames (auto-saved)</h3>
103136
</div>
104137
<script src="app.js"></script>
105138
</body>
106-
</html>
139+
</html>

examples/led-matrix-painter/assets/style.css

Lines changed: 154 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ input:checked + .slider:before {
230230
font-weight: 700;
231231
line-height: 170%;
232232
letter-spacing: 1.2px;
233+
margin-bottom: 8px;
233234
}
234235

235236
.controls-section-left {
@@ -319,11 +320,22 @@ input:checked + .slider:before {
319320
/*
320321
* Responsive design
321322
*/
322-
@media (max-width: 768px) {
323+
@media (max-width: 1024px) {
323324
.main-content {
324325
flex-direction: column;
325326
}
326327

328+
.left-sidebar {
329+
max-width: 100%; /* Allow left-sidebar to take full width */
330+
flex-direction: row; /* Arrange children side-by-side */
331+
flex-wrap: wrap; /* Allow children to wrap */
332+
}
333+
334+
.tools-box, .transform-box {
335+
flex: 1; /* Allow boxes to grow and shrink */
336+
min-width: 250px; /* Ensure a minimum width for the boxes */
337+
}
338+
327339
.arduino-text {
328340
font-size: 14px;
329341
}
@@ -332,29 +344,13 @@ input:checked + .slider:before {
332344
padding: 15px;
333345
}
334346

335-
.controls-section-left {
336-
min-width: 330px;
337-
}
338-
339347
.arduino-logo {
340348
height: 16px;
341349
width: auto;
342350
}
343351

344352
}
345353

346-
@media (max-width: 1024px) and (min-width: 769px) {
347-
.controls-section-left {
348-
min-width: 490px;
349-
}
350-
}
351-
352-
@media (max-width: 480px) {
353-
.controls-section-left {
354-
min-width: 170px;
355-
}
356-
}
357-
358354
/* Specific styles for LED Matrix Painter components */
359355

360356
/* Grid and cells */
@@ -519,3 +515,144 @@ input {
519515
background-color: #7F8C8D;
520516
vertical-align: middle; /* To vertically align with other elements in the header */
521517
}
518+
519+
.tool-controls {
520+
display: flex;
521+
align-items: center;
522+
}
523+
524+
/* Custom Select */
525+
.custom-select-wrapper {
526+
position: relative;
527+
display: inline-block;
528+
user-select: none;
529+
width: 48px;
530+
}
531+
532+
.custom-select {
533+
position: relative;
534+
width: 100%;
535+
}
536+
537+
.custom-select__trigger {
538+
position: relative;
539+
display: flex;
540+
align-items: center;
541+
gap: 8px;
542+
padding: 12px 8px;
543+
border-radius: 8px;
544+
background: rgba(0, 129, 132, 0.2);
545+
cursor: pointer;
546+
}
547+
548+
.custom-select.open .custom-options {
549+
display: block;
550+
}
551+
552+
.custom-options {
553+
position: absolute;
554+
top: 100%;
555+
left: 0;
556+
right: 0;
557+
display: none;
558+
box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); /* Subtle shadow instead of border */
559+
border-radius: 0 0 8px 8px;
560+
background: #fff;
561+
z-index: 2;
562+
}
563+
564+
.custom-option {
565+
display: flex;
566+
align-items: center;
567+
gap: 8px;
568+
padding: 12px 8px; /* Adjusted padding */
569+
cursor: pointer;
570+
}
571+
572+
.custom-option:hover {
573+
background-color: rgba(0, 129, 132, 0.08);
574+
}
575+
576+
.dropdown-arrow {
577+
position: absolute;
578+
top: 50%;
579+
right: 10px;
580+
transform: translateY(-50%);
581+
transition: transform 0.2s ease-in-out;
582+
}
583+
584+
.custom-select.open .dropdown-arrow {
585+
transform: translateY(-50%) rotate(180deg);
586+
}
587+
588+
.alpha-label {
589+
font-family: "Open Sans";
590+
font-size: 10px;
591+
font-style: normal;
592+
font-weight: 600;
593+
line-height: 160%; /* 16px */
594+
letter-spacing: 0.1px;
595+
}
596+
597+
.slider-limit-label {
598+
font-size: 10px;
599+
font-style: normal;
600+
font-weight: 600;
601+
}
602+
603+
.tool-icon {
604+
fill: #008184;
605+
}
606+
607+
#brightness-alpha-slider {
608+
-webkit-appearance: none;
609+
width: 100%;
610+
height: 6px;
611+
background: #008184 !important;
612+
outline: none;
613+
-webkit-transition: .2s;
614+
transition: opacity .2s;
615+
border-radius: 30px;
616+
}
617+
618+
/* Mouse-over effects */
619+
#brightness-alpha-slider:hover {
620+
opacity: 1; /* Fully shown on mouse-over */
621+
}
622+
623+
/* The slider thumb (webKit) */
624+
#brightness-alpha-slider::-webkit-slider-thumb {
625+
-webkit-appearance: none; /* Hides the default slider thumb */
626+
appearance: none;
627+
width: 16px; /* Set a specific slider handle width */
628+
height: 16px; /* Slider handle height */
629+
border-radius: 50%; /* Make it a circle */
630+
background: #008184 !important; /* Green background */
631+
cursor: pointer; /* Cursor on hover */
632+
margin-top: -4px; /* Adjust this to center the thumb vertically on the track */
633+
}
634+
635+
/* The slider thumb (Firefox) */
636+
#brightness-alpha-slider::-moz-range-thumb {
637+
width: 16px; /* Set a specific slider handle width */
638+
height: 16px; /* Slider handle height */
639+
border-radius: 50%; /* Make it a circle */
640+
background: #008184 !important; /* Green background */
641+
cursor: pointer; /* Cursor on hover */
642+
}
643+
644+
/* The slider track (webKit) */
645+
#brightness-alpha-slider::-webkit-slider-runnable-track {
646+
width: 100%;
647+
height: 8px;
648+
background: #008184 !important; /* Green background */
649+
border-radius: 4px;
650+
}
651+
652+
/* The slider track (Firefox) */
653+
#brightness-alpha-slider::-moz-range-track {
654+
width: 100%;
655+
height: 8px;
656+
background: #008184 !important; /* Green background */
657+
border-radius: 4px;
658+
}

0 commit comments

Comments
 (0)