use of com.vaadin.flow.theme.Theme in project flow by vaadin.
the class WebComponentUI method assignThemeVariant.
private void assignThemeVariant() {
WebComponentConfigurationRegistry registry = getConfigurationRegistry();
Optional<Theme> theme = registry.getEmbeddedApplicationAnnotation(Theme.class);
if (!theme.isPresent() || theme.get().themeClass().equals(AbstractTheme.class)) {
return;
}
AbstractTheme themeInstance = Instantiator.get(this).getOrCreate(theme.get().themeClass());
ThemeDefinition definition = new ThemeDefinition(theme.get());
Map<String, String> attributes = themeInstance.getHtmlAttributes(definition.getVariant());
registry.getConfigurations().forEach(config -> addAttributes(config.getTag(), attributes));
}
use of com.vaadin.flow.theme.Theme 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