hasComponentAttribute(self::ON_HOVER_ATTRIBUTE)) { $hover = strtolower($attributes->getValueAndRemove(self::ON_HOVER_ATTRIBUTE)); $hoverAnimations = preg_split("/\s/", $hover); $comboDataHoverClasses = ""; $snippetManager = PluginUtility::getSnippetManager(); foreach ($hoverAnimations as $hover) { if (in_array($hover, self::HOVER_ANIMATIONS)) { $snippetManager ->attachRemoteCssStyleSheet( self::ON_HOVER_SNIPPET_ID, "https://cdnjs.cloudflare.com/ajax/libs/hover.css/2.3.1/css/hover-min.css", "sha512-csw0Ma4oXCAgd/d4nTcpoEoz4nYvvnk21a8VA2h2dzhPAvjbUIK6V3si7/g/HehwdunqqW18RwCJKpD7rL67Xg==" ) ->setCritical(false); $attributes->addClassName("hvr-$hover"); } else { /** * The combo hover effect */ if (in_array($hover, ["float", "grow"])) { $hover = "combo-" . $hover; } /** * Shadow translation between animation name * and class */ switch ($hover) { case "shadow": $hover = Shadow::getDefaultClass(); break; case "shadow-md": $hover = Shadow::MEDIUM_ELEVATION_CLASS; break; case "shadow-lg": $hover = "shadow"; break; case "shadow-xl": $hover = "shadow-lg"; break; } /** * Add it to the list of class */ $comboDataHoverClasses .= " " . $hover; } } if (!empty($comboDataHoverClasses)) { // Grow, float and easing are in the css $snippetManager ->attachCssInternalStyleSheet(self::ON_HOVER_SNIPPET_ID) ->setCritical(false); // Smooth Transition in and out of hover $attributes->addClassName(self::COMBO_HOVER_EASING_CLASS); $attributes->addOutputAttributeValue("data-hover-class", trim($comboDataHoverClasses)); // The javascript that manage the hover effect by adding the class in the data-hover class $snippetManager->attachJavascriptFromComponentId(self::ON_HOVER_SNIPPET_ID); } } } }