com.vaadin.flow.server.frontend.

Class ThemeUtils

java.lang.Object
com.vaadin.flow.server.frontend.ThemeUtils
public class ThemeUtils extends Object

Helpers related to theme handling.

For internal use only. May be renamed or removed in a future release.

  • Method Details

    • getThemeName

      public static Optional<String> getThemeName(VaadinContext context)

      Gets the custom theme name if the custom theme is used in the project.

      Should be only used in the development mode.

      Parameters:

      context - the vaadin context

      Returns:

      custom theme name or empty optional if no theme is used

    • getThemeAnnotation

      public static Optional<Theme> getThemeAnnotation(VaadinContext context)

      Gets the theme annotation for the project.

      Parameters:

      context - the Vaadin context

      Returns:

      the theme annotation or an empty optional

    • getThemeJson

      public static Optional<elemental.json.JsonObject> getThemeJson(String themeName, AbstractConfiguration config)
    • getThemeResourceFromPrecompiledProductionBundle

      public static URL getThemeResourceFromPrecompiledProductionBundle(String themeAssetPath)

      Gets the URL of the theme resource located in the pre-compiled production bundle JAR or in the external packaged theme JAR.

      Parameters:

      themeAssetPath - theme resource path relative to 'themes' folder, e.g. 'my-theme/styles.css'

      Returns:

      URL to theme resource if the resource was found, null otherwise

    • getThemeJson

      public static Optional<elemental.json.JsonObject> getThemeJson(String themeName, File frontendFolder)
    • getParentThemeName

      public static Optional<String> getParentThemeName(elemental.json.JsonObject themeJson)
    • getActiveThemes

      public static List<String> getActiveThemes(VaadinContext context)

      Gets the active themes in parent to child order, starting from the application theme.

      Parameters:

      context - the vaadin context

      Returns:

      a list of active themes, in parent to child order

    • getThemeFolder

      public static File getThemeFolder(File frontendFolder, String themeName) throws IllegalArgumentException

      Finds the folder for the given theme.

      Assumes the folder exists and throws an exception if it does not.

      Parameters:

      frontendFolder - the project frontend folder

      themeName - the theme name

      Returns:

      the folder for the theme, containing styles.css

      Throws:

      IllegalArgumentException - if the theme folder was not found

    • getThemeFilePath

      public static String getThemeFilePath(String themeName, String fileName)