Skip to content

Commit d464f4c

Browse files
committed
fix: select button better
1 parent ee60b60 commit d464f4c

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

src/core/web/toolbar.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const createToolbar = () => {
99

1010
// Create a scrollable and resizable div containing checkboxes
1111
const checkboxContainer = createElement(
12-
`<div id="react-scan-checkbox-list" style="position:fixed;bottom:3px;left:3px;min-width:140px;height:150px;background:#fff;padding:2px 4px;border:1px solid #ccc;border-radius:4px;z-index:2147483647;font-family:${MONO_FONT};overflow-y:auto;resize:horizontal;">
12+
`<div id="react-scan-checkbox-list" style="position:fixed;bottom:3px;left:3px;min-width:140px;height:150px;background:#fff;padding:2px 4px;border:1px solid #ccc;border-radius:4px;z-index:2147483647;font-family:${MONO_FONT};overflow-y:auto;resize:horizontal;display:none;">
1313
</div>`,
1414
) as HTMLDivElement;
1515

@@ -20,11 +20,19 @@ export const createToolbar = () => {
2020
'localStorage' in globalThis &&
2121
localStorage.getItem('react-scan-hidden') === 'true';
2222

23+
let isCheckboxContainerHidden = true;
24+
25+
const toggleButton = createElement(
26+
`<button style="margin-left:8px;background:rgba(255,255,255,0.2);border:1px solid rgba(255,255,255,0.4);color:white;cursor:pointer;padding:3px 6px;border-radius:4px;font-size:16px;transition:all 0.2s;" title="Toggle component list">☰</button>`
27+
) as HTMLButtonElement;
28+
29+
2330
const updateVisibility = () => {
2431
const overlay = document.getElementById('react-scan-overlay');
2532
if (!overlay) return;
2633
overlay.style.display = isHidden ? 'none' : 'block';
2734
status.textContent = isHidden ? 'start ►' : 'stop ⏹';
35+
status.appendChild(toggleButton);
2836
ReactScanInternals.isPaused = isHidden;
2937
if (ReactScanInternals.isPaused) {
3038
ReactScanInternals.activeOutlines = [];
@@ -37,18 +45,30 @@ export const createToolbar = () => {
3745

3846
updateVisibility();
3947

40-
status.addEventListener('click', () => {
48+
status.addEventListener('click', (e) => {
49+
if (e.target === toggleButton) return;
4150
isHidden = !isHidden;
4251
updateVisibility();
4352
});
4453

54+
toggleButton.addEventListener('click', () => {
55+
isCheckboxContainerHidden = !isCheckboxContainerHidden;
56+
checkboxContainer.style.display = isCheckboxContainerHidden ? 'none' : 'block';
57+
renderCheckbox();
58+
});
59+
4560
status.addEventListener('mouseenter', () => {
46-
status.textContent = isHidden ? 'start ►' : 'stop ⏹';
61+
if (status.textContent !== '☰') {
62+
status.textContent = isHidden ? 'start ►' : 'stop ⏹';
63+
status.appendChild(toggleButton);
64+
}
4765
status.style.backgroundColor = 'rgba(0,0,0,1)';
66+
toggleButton.style.backgroundColor = 'rgba(255,255,255,0.3)';
4867
});
4968

5069
status.addEventListener('mouseleave', () => {
5170
status.style.backgroundColor = 'rgba(0,0,0,0.5)';
71+
toggleButton.style.backgroundColor = 'rgba(255,255,255,0.2)';
5272
});
5373

5474
const prevElement = document.getElementById('react-scan-toolbar');

0 commit comments

Comments
 (0)