fix: add GridStackLayout showcase view (#7)
CI / build-and-test (pull_request) Successful in 1m13s
CI / build-and-test (pull_request) Successful in 1m13s
Adds a /gridstack route demonstrating GridStackLayout: four default widgets (line/bar/pie chart cards plus a usage hint), buttons to add and remove widgets at runtime, a reset-layout button and a layout-change status line. Layout is persisted per browser via the existing localStorage support. The view gets its own SideNavItem in MainLayout and full de/en/es translations. Fixes an infinite recursion in GridStackLayout.add(Component): a single-argument add(item) resolves to that overload rather than the varargs one, so its delegation to add(item) called itself. It now appends through the element API and passes a GridStackItem through unwrapped. Adds the first test sources (browserless UI tests) covering the view's widget count and the add/remove buttons. Closes #7 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PYAcKoXKPN3rJ7nBroKZkc
This commit is contained in:
@@ -106,10 +106,17 @@ public class GridStackLayout extends Component implements HasSize, HasStyle {
|
||||
}
|
||||
}
|
||||
|
||||
/** Convenience overload: wraps a plain component in a default-sized {@link GridStackItem}. */
|
||||
/** Convenience overload: wraps a plain component in a default-sized
|
||||
* {@link GridStackItem} (an item passed in directly is added as is).
|
||||
* <p>
|
||||
* Appends through the element API rather than calling {@code add(item)}:
|
||||
* a single-argument call resolves to this overload, not the varargs one,
|
||||
* so delegating would recurse into itself. */
|
||||
public GridStackItem add(Component content) {
|
||||
GridStackItem item = new GridStackItem(content);
|
||||
add(item);
|
||||
GridStackItem item = content instanceof GridStackItem existing
|
||||
? existing
|
||||
: new GridStackItem(content);
|
||||
getElement().appendChild(item.getElement());
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user