styled and reloadable widgets

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

styled and reloadable widgets

laurent laffont
Hi,

I tend to write my widgets like this:

MyWidget>>renderOn: html  
  self renderWidgetOn: html.

  "This add a button in my developer tool bar to reload/inspect the widget. Note: disabled when deployed and running in TestCase"
  MyIDETools 
    addButton: 'Reload my widget' action: [html root contents:[:h| self renderWidgetOn: h]];
    addButton: 'Inspect my widget' action: [self inspect]


MyWidget>>renderWidgetOn: html
    html style: self style.
    html div 
        class: 'my-widget';
        with: [html p:'bla bla bla'].


Widget>>style
  ^ '.my-widget { color: red }'
  

So:
- I can reload and inspect a widget individually 
- this widget CSS is destroyed and reloaded (no need to refresh the pages, etc....)
- I can provide a default CSS for each widget


Should I add these behaviors directly into Widget or is there something bad ?


Laurent Laffont