Skip to content

Commit 033994d

Browse files
committed
fix: better styling for component filters
1 parent d464f4c commit 033994d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/core/web/toolbar.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ 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;display:none;">
12+
`<div id="react-scan-checkbox-list" style="position:fixed;bottom:3px;left:3px;min-width:200px;max-width:400px;height:200px;background:rgba(0,0,0,0.5);padding:8px;border:1px solid rgba(255,255,255,0.4);border-radius:6px;box-shadow:0 2px 8px rgba(0,0,0,0.15);z-index:2147483647;font-family:${MONO_FONT};overflow-y:auto;resize:horizontal;display:none;">
13+
<div style="font-weight:400;margin-bottom:8px;color:white;border-bottom:1px solid rgba(255,255,255,0.4);padding-bottom:4px; font-size:14px;">Component Filters</div>
1314
</div>`,
1415
) as HTMLDivElement;
1516

@@ -26,7 +27,6 @@ export const createToolbar = () => {
2627
`<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>`
2728
) as HTMLButtonElement;
2829

29-
3030
const updateVisibility = () => {
3131
const overlay = document.getElementById('react-scan-overlay');
3232
if (!overlay) return;
@@ -84,16 +84,30 @@ export const renderCheckbox = () => {
8484
const checkboxContainer = document.getElementById('react-scan-checkbox-list');
8585
if (!checkboxContainer) return;
8686

87-
checkboxContainer.innerHTML = '';
87+
checkboxContainer.innerHTML = `
88+
<div style="font-weight:600;margin-bottom:8px;color:white;border-bottom:1px solid rgba(255,255,255,0.4);padding-bottom:4px;">Component Filters</div>
89+
`;
8890

8991
for (const [name, { count, time }] of Object.entries(getReport())) {
9092
const label = createElement(
91-
`<label style="display:block;"><input type="checkbox" value="${name}"> ${name} (✖︎${count}, ${time.toFixed(2)}ms)</label>`,
93+
`<label style="display:flex;align-items:center;padding:4px 0;border-radius:4px;cursor:pointer;transition:background 0.2s;margin:2px 0;color:white;font-size:13px;">
94+
<input type="checkbox" value="${name}" style="margin-right:8px;">
95+
<div style="flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">${name}</div>
96+
<div style="margin-left:8px;color:rgba(255,255,255,0.7);white-space:nowrap;">✖︎${count} · ${time.toFixed(1)}ms</div>
97+
</label>`,
9298
) as HTMLLabelElement;
9399

94100
const checkbox = label.querySelector('input')!;
95101
checkbox.checked = ReactScanInternals.componentNameAllowList.has(name);
96102

103+
label.addEventListener('mouseenter', () => {
104+
label.style.background = 'rgba(255,255,255,0.1)';
105+
});
106+
107+
label.addEventListener('mouseleave', () => {
108+
label.style.background = 'transparent';
109+
});
110+
97111
checkbox.addEventListener('change', () => {
98112
if (checkbox.checked)
99113
ReactScanInternals.componentNameAllowList.add(name);

0 commit comments

Comments
 (0)