blenderskool / untab

πŸ” A productivity tool to boost your browser workflow!
https://getuntab.now.sh
MIT License
345 stars 27 forks source link

Plugins UI πŸŽ‰ #65

Closed blenderskool closed 3 years ago

blenderskool commented 3 years ago

Why Plugins UI?

Plugins in UnTab were just about providing results for the search index, and executing appropriate logic when a result was selected. While this served many use-cases, it started to feel like plugins needed more control over how they render the results and the other actions they'd support for each result. Thus, some UI-level control for the plugins seemed like the way to go.

How does this PR add the feature?

With UnTab Plugins UI, each plugin can now specify what they want to render for each result the plugin provides by simply defining it as a Svelte component :orange_heart:! With the power of Svelte components, these pieces of UI can have their own state, styles, and logic making plugins even more flexible. These Svelte components are only bundled with the content script bundle and are not a part of the background script bundle(as the UI part is irrelevant in the background script).

Another important piece of UI is interactivity. Interactivity is what allows buttons rendered in the UI to perform some action. This has been made possible through a basic event system where the UI calls an event with an appropriate name and arguments, and UnTab delegates this call to the handler specified in the plugins definition in the background script.

Example of how it works

Here's an example of how the new plugin UI works in the tabs search plugin. The plugin provides actions to pin/unpin tabs and close the tabs.

https://user-images.githubusercontent.com/21107799/118397502-ee452280-b671-11eb-90ee-030a42c67444.mp4

What if the plugin level UI becomes inconsistent over time?

Now that each plugin can specify its own CSS for the UI, there might be cases when styles of different plugins are inconsistent causing a bad UX overall. Also, the UI might start to get cluttered with buttons and text even more if it's not controlled. To control these problems, the following guidelines should be followed:

Other changes in this PR