/** * Returns the specified body size content for the target route chain that * was navigated to, specified with {@link BodySize} on the {@link Route} * annotated class or the {@link ParentLayout} of the route. * * @param context * the bootstrap context * @return the content value string for body size style element */ static String getBodySizeContent( BootstrapHandler.BootstrapContext context) { Optional<BodySize> bodySize = context .getPageConfigurationAnnotation(BodySize.class); // Set full size by default if @BodySize is not used String height = bodySize.map(BodySize::height).orElse("100vh"); String width = bodySize.map(BodySize::width).orElse("100vw"); StringBuilder bodyString = new StringBuilder(); bodyString.append("body {"); if (!height.isEmpty()) { bodyString.append("height:").append(height).append(";"); } if (!width.isEmpty()) { bodyString.append("width:").append(width).append(";"); } bodyString.append("margin:0;"); bodyString.append("}"); return bodyString.toString(); }
/** * Returns the specified viewport content for the target route chain that * was navigated to, specified with {@link Viewport} on the {@link Route} * annotated class or the {@link ParentLayout} of the route. * * @param context * the bootstrap context * @return the content value string for viewport meta tag */ static Optional<String> getViewportContent( BootstrapHandler.BootstrapContext context) { return context.getPageConfigurationAnnotation(Viewport.class) .map(Viewport::value); }