UI Behaviour & Interactivity - dormouseroared/dom-inspector-plus GitHub Wiki
Onwards we go, Captain Nigel β here's Chapter 8 of the DOM Inspector Plus engineering guide: diving into UI Behavior & Interactivity. This chapter lays out how users interact with the overlay, how the interface responds, and how we might enhance accessibility and usability over time.
The Inspector Plus overlay isnβt just passiveβit invites user input. From editing visible properties to copying output, each interaction is crafted to be immediate, persistent, and non-disruptive.
At the base of each overlay are three buttons:
<button>Edit input</button>
<button>Reset</button>
<button>Copy</button>
These are created dynamically with inline styling. Here's what each does:
-
Purpose: Customize which properties are shown for a tag (e.g.
input
,button
) -
Trigger:
prompt()
dialog showing the current list (comma-separated) -
Flow:
- User enters new property list
- The input string is split on commas
- New list is saved in
localStorage
-
inspect(lastEl)
is called to re-render the overlay
btn.onclick = () => {
const current = config[tagName] || [];
const updated = prompt("Edit properties", current.join(","));
if (updated !== null) {
localStorage.setItem(key, JSON.stringify(updated.split(",")));
inspect(lastEl);
}
};
- Purpose: Revert a tag's property list to default
-
Effect:
- Removes the config from
localStorage
- Calls
inspect(lastEl)
to refresh
- Removes the config from
btn.onclick = () => {
localStorage.removeItem(`inspector-plus-config:${tagName}`);
inspect(lastEl);
};
-
Purpose: Export readable overlay contents as plain text
-
Logic: Builds text content in the format:
input value: hello β local checked: true β attribute
-
Uses the
navigator.clipboard.writeText()
API -
Alerts user on success or failure
btn.onclick = () => {
copyToClipboard(outputString);
};
Any time an edit or reset occurs:
-
inspect(lastEl)
is called - The current element is reprocessed and re-rendered
- Ensures consistent UX and instant feedback
This approach avoids overlays becoming stale or misaligned with the target element.
Inspector Plus uses basic semantic HTML (<div>
, <button>
, <a>
) and avoids custom widgets. But future improvements might include:
- ARIA labels on action buttons
- Keyboard navigation through property rows
- Focus management when overlay appears
- Tab traps or toggle to dismiss overlay via
Esc
These ideas could level up the experience:
Feature | Description |
---|---|
π§ Toggle overlay | Activate/deactivate inspector on demand |
π¨ Theme modes | Light/dark/retro styles |
π Layout options | Compact/dense vs. expanded line spacing |
π Close button | Optional βXβ to dismiss overlay manually |
π Hover preview | On hover, show brief property summary |
In the next chapter, we can look at Chapter 9: Integration into Other Projects β how to embed Inspector Plus into other codebases, reuse it modularly, or even ship it as a debug-only tool in production environments.
Want me to carry straight on with that one? Youβre blazing through this like a dev in flow state π»β‘