nexushoratio / userscripts

Random userscripts for browsers.
GNU General Public License v3.0
2 stars 0 forks source link

`Grid` Widget #185

Open nexushoratio opened 1 year ago

nexushoratio commented 1 year ago

Having decided against w2ui, time to set forth some requirements for a new grid widget:

More features can be added as needed

nexushoratio commented 1 year ago

Using w2ui seems to work with minimal effort. At least first demo from the site works.

// @require     https://cdn.jsdelivr.net/npm/w2ui@2.0.0/w2ui-2.0.min.js
// @resource    bob https://cdn.jsdelivr.net/npm/w2ui@2.0.0/w2ui-2.0.min.css
// @grant GM.getResourceUrl

  const link = document.createElement('link');
  link.href = await GM.getResourceUrl('bob');
  link.rel = 'stylesheet';
  link.type = 'text/css';
  document.head.append(link);

  const info = new NH.widget.Info('Popup');
  info.container.style = 'width: 65%; height: 95%;';
  document.body.prepend(info.container);

  // Widget configuration
  const config = {
... w2ui demo data ...
  };

  const layout = new w2layout(config.layout);
  const sidebar = new w2sidebar(config.sidebar);
  const grid1 = new w2grid(config.grid1);
  const grid2 = new w2grid(config.grid2);
  // Initialization
  layout.render(`#${info.container.id}`);
  layout.html('left', sidebar);
  layout.html('main', grid1);
  info.open();