use of com.vaadin.flow.theme.AbstractTheme in project flow by vaadin.
the class BootstrapUtils method getThemeSettings.
static Map<TargetElement, List<JsonObject>> getThemeSettings(BootstrapHandler.BootstrapContext context) {
Optional<Theme> themeAnnotation = context.getPageConfigurationAnnotation(Theme.class);
if (themeAnnotation.isPresent()) {
Map<TargetElement, List<JsonObject>> themeContents = new EnumMap<>(TargetElement.class);
Class<? extends AbstractTheme> themeClass = themeAnnotation.get().value();
AbstractTheme theme = ReflectTools.createInstance(themeClass);
if (!context.isProductionMode()) {
List<JsonObject> head = Stream.of(themeClass.getAnnotationsByType(HtmlImport.class)).map(HtmlImport::value).map(url -> createImportLink(context.getUriResolver(), url)).map(BootstrapUtils::createInlineDependencyObject).collect(Collectors.toList());
themeContents.put(TargetElement.HEAD, head);
}
List<JsonObject> body = theme.getBodyInlineContents().stream().map(BootstrapUtils::createInlineDependencyObject).collect(Collectors.toList());
themeContents.put(TargetElement.BODY, body);
return themeContents;
}
return Collections.emptyMap();
}
Aggregations