remotestorage / remotestorage-widget

⬡ Connect widget for remoteStorage.js
https://remotestorage.io
28 stars 16 forks source link

Added a detach function #122

Closed Silver-Golden closed 2 years ago

Silver-Golden commented 3 years ago

I am working on a react SPA and want to only show the widget when certain pages are rendered.

To do this I added a detach option to hide the widget when its not supposed to be visible.

Silver-Golden commented 3 years ago

6a16e88 is to pair with https://github.com/remotestorage/remotestorage.js/pull/1237 to preserve the local data when disconnected. Default behaviour remains unchanged

raucao commented 3 years ago

Thanks for your PR!

Just a heads-up: It will be difficult to merge the various different changes when they're all in one PR, but split up over a lot of commits. Cherry-picking self-contained commits is OK, but sorting through a lot of related ones is difficult and time-consuming. So it would be ideal if you could split up unrelated changes into separate pull requests. (git cherry-pick is your friend for creating those branches from commits on master in your own repo as well.)

raucao commented 3 years ago

One thing I was wondering is why you need to use JavaScript to detach the widget while not showing it, and then having it do all the init work again when you do. One easy solution to only showing the widget on specific pages/views is to use simple CSS for that. Consider this example from the Inspektor app, which only shows the widget when disconnected:

#remotestorage-widget {
  display: none;
}

.connect #remotestorage-widget {
  display: block;
}

That app is using a class name on the body element, but you can also attach the widget to specific elements in your HTML for example (making it easier to use other selectors around it).

raucao commented 3 years ago

@Silver-Golden Did you see my replies by any chance?

raucao commented 2 years ago

Closing due to inactivity.