Open KestasVenslauskas opened 1 year ago
Just to confirm your request.
Currently you can do this:
import 'package:flutter/material.dart';
import 'sample_button.dart';
// Declare a root container that I can use on my stories
class MyRootContainer extends StatelessWidget {
final Widget child;
MyRootContainer({required this.child});
@override
Widget build(BuildContext context) {
return Container(color: Colors.red, height: 200, child: child);
}
}
// Stories can now use MyRootContainer
Widget primary() =>
MyRootContainer(child: Button('Button', ButtonStyles.primary));
Widget secondary() =>
MyRootContainer(child: Button('Button', ButtonStyles.secondary));
Widget disabled() =>
MyRootContainer(child: Button('Button', ButtonStyles.disabled));
However, you would like to do something like this:
// Annotate a function which Monarch will use as the root container of all stories
@MonarchRootContainer()
Widget getMyRootContainer(Widget child) =>
Container(color: Colors.red, height: 200, child: child);
// Monarch will preview stories inside the root container
Widget primary() => Button('Button', ButtonStyles.primary);
Widget secondary() => Button('Button', ButtonStyles.secondary);
Widget disabled() => Button('Button', ButtonStyles.disabled);
@fertrig Yes exactly
Maybe we could have a single config point to create a default wrapper for all of the stories. Or maybe in a deeper level for a whole MonarchApp wrapping.