From fa2f13a9a46a1759061547f9e65e057e90a2ffa5 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Mon, 25 Jun 2018 10:19:23 +0300 Subject: [PATCH] Add material theme support to Flow. --- flow-theme-integrations/material/pom.xml | 24 +++++++ .../vaadin/flow/theme/material/Material.java | 69 +++++++++++++++++++ flow-theme-integrations/pom.xml | 1 + 3 files changed, 94 insertions(+) create mode 100644 flow-theme-integrations/material/pom.xml create mode 100644 flow-theme-integrations/material/src/main/java/com/vaadin/flow/theme/material/Material.java diff --git a/flow-theme-integrations/material/pom.xml b/flow-theme-integrations/material/pom.xml new file mode 100644 index 00000000000..79403a86c34 --- /dev/null +++ b/flow-theme-integrations/material/pom.xml @@ -0,0 +1,24 @@ + + + 4.0.0 + + com.vaadin + flow-theme-integrations + 1.0-SNAPSHOT + + + vaadin-material-theme + Material theme for Flow + Package with Material dependencies and setting for use with Flow + + jar + + + + org.webjars.bowergithub.vaadin + vaadin-material-styles + 0.4.0 + + + diff --git a/flow-theme-integrations/material/src/main/java/com/vaadin/flow/theme/material/Material.java b/flow-theme-integrations/material/src/main/java/com/vaadin/flow/theme/material/Material.java new file mode 100644 index 00000000000..5494f6907f2 --- /dev/null +++ b/flow-theme-integrations/material/src/main/java/com/vaadin/flow/theme/material/Material.java @@ -0,0 +1,69 @@ +/* + * Copyright 2000-2017 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.flow.theme.material; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.slf4j.LoggerFactory; + +import com.vaadin.flow.component.dependency.HtmlImport; +import com.vaadin.flow.theme.AbstractTheme; + +/** + * Material component theme class implementation. + */ +@HtmlImport("frontend://bower_components/vaadin-material-styles/color.html") +@HtmlImport("frontend://bower_components/vaadin-material-styles/typography.html") +public class Material implements AbstractTheme { + public static final String LIGHT = "light"; + public static final String DARK = "dark"; + + @Override + public String getBaseUrl() { + return "src/"; + } + + @Override + public String getThemeUrl() { + return "theme/material/"; + } + + @Override + public List getHeaderInlineContents() { + return Collections.singletonList("\n" + + " \n" + + ""); + } + + @Override + public Map getBodyAttributes(String variant) { + switch (variant) { + case LIGHT: + return Collections.singletonMap("theme", LIGHT); + case DARK: + return Collections.singletonMap("theme", DARK); + default: + if (!variant.isEmpty()) { + LoggerFactory.getLogger(getClass().getName()).warn( + "Material theme variant not recognized: '{0}'. Using no variant.", + variant); + } + return Collections.emptyMap(); + } + } +} diff --git a/flow-theme-integrations/pom.xml b/flow-theme-integrations/pom.xml index e1cda77e30e..2f073981c4c 100644 --- a/flow-theme-integrations/pom.xml +++ b/flow-theme-integrations/pom.xml @@ -15,6 +15,7 @@ lumo + material