]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Add menu centered for backward compatibility!
authorharry <harmanmanchanda182@gmail.com>
Mon, 26 Jun 2017 20:15:13 +0000 (01:45 +0530)
committerharry <harmanmanchanda182@gmail.com>
Mon, 26 Jun 2017 20:15:13 +0000 (01:45 +0530)
scss/components/_menu.scss
test/visual/menu/menu-centered-flex.html
test/visual/menu/menu-centered-float.html [new file with mode: 0644]

index 572e3cb769e2bf7769637c52a4040da90db0c4d0..b74b7e241022815a3ca5e672921a46fea9d54a3d 100644 (file)
@@ -43,6 +43,11 @@ $menu-item-background-hover: $light-gray !default;
 /// @type Boolean
 $menu-state-back-compat: true !default;
 
+/// Backward compatibility for menu centered. If true, this duplicate `.menu-centered > .menu` with `.menu.align-center`. 
+/// But please note that `menu-centered` will be removed in upcoming versions.
+/// @type Boolean
+$menu-centered-back-compat: true !default;
+
 /// Creates the base styles for a Menu.
 @mixin menu-base {
   padding: 0;
@@ -453,6 +458,19 @@ $menu-state-back-compat: true !default;
     }
   }
 
+  @if $menu-centered-back-compat {
+    .menu-centered {
+      > .menu {
+        @if $global-flexbox {
+          display: flex;
+          justify-content: center;
+        }
+        
+        @include menu-align(center);
+      }
+    }
+  }
+
   // Prevent FOUC when using the Responsive Menu plugin
   .no-js [data-responsive-menu] ul {
     display: none;
index 7f5c85b4e73212f4b0818e3adf36ce85da41e7e9..595e83506ff96082f5de185ae5647591141e5fb6 100644 (file)
@@ -1,37 +1,73 @@
 <!doctype html>
 <!--[if IE 9]><html class="lt-ie10" lang="en" > <![endif]-->
 <html class="no-js" lang="en" dir="ltr">
-
   <head>
-    <link href="http://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css" rel="stylesheet">
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
-
-    <link href="../assets/css/foundation-float.css" rel="stylesheet" />
+    <title>All Foundation Menu Options - Flexbox</title>
+    <link href="../motion-ui/dist/motion-ui.css" rel="stylesheet" />
+    <link href="../assets/css/foundation.css" rel="stylesheet" />
+    <link href="//cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css" rel="stylesheet">
 
     <style>
+      h1 {
+        border-bottom: 1px solid #ddd;
+        margin-bottom: 2rem;
+        width: 100%;
+      }
+
+      h3 {
+        width: 100%;
+      }
 
+      .example {
+        padding: 2rem;
+        border: 1px solid #ddd;
+        width: 100%;
+      }
 
+      .example + h1 {
+        margin-top: 5rem;
+      }
+
+      .example + h3 {
+        margin-top: 3rem;
+      }
     </style>
   </head>
 
   <body>
-    <h2>Menu</h2>
-
-    <hr>
+    <div class="grid-container">
+      <div class="grid-x grid-padding-x">
+        <div class="cell">
+          <h1>Menu Centered</h1>
 
-    <p>This menu should be centered</p>
+          <h3>Centered Menu (Align Center)</h3>
+          <div class="example">
+            <ul class="menu align-center">
+              <li><a href="#">One</a></li>
+              <li><a href="#">Two</a></li>
+              <li><a href="#">Three</a></li>
+              <li><a href="#">Four</a></li>
+            </ul>
+          </div>
 
-    <div class="menu-centered">
-      <ul class="menu">
-        <li><a href="#" target="_blank">Link</a></li>
-        <li><a href="#" target="_blank">Link</a></li>
-        <li><a href="#" target="_blank">Link</a></li>
-        <li><a href="#" target="_blank">Link</a></li>
-      </ul>
+          <h3>Centered Menu (Menu Centered)</h3>
+          <div class="example">
+            <div class="menu-centered">
+              <ul class="menu">
+                <li><a href="#">One</a></li>
+                <li><a href="#">Two</a></li>
+                <li><a href="#">Three</a></li>
+                <li><a href="#">Four</a></li>
+              </ul>
+            </div>
+          </div>
+        </div>
+      </div>
     </div>
 
-    <hr>
-
     <script src="../assets/js/vendor.js"></script>
     <script src="../assets/js/foundation.js"></script>
     <script>
diff --git a/test/visual/menu/menu-centered-float.html b/test/visual/menu/menu-centered-float.html
new file mode 100644 (file)
index 0000000..ec8a254
--- /dev/null
@@ -0,0 +1,75 @@
+<!doctype html>
+<!--[if IE 9]><html class="lt-ie10" lang="en" > <![endif]-->
+<html class="no-js" lang="en" dir="ltr">
+  <head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
+    <title>All Foundation Menu Options - Flexbox</title>
+    <link href="../motion-ui/dist/motion-ui.css" rel="stylesheet" />
+    <link href="../assets/css/foundation-float.css" rel="stylesheet" />
+    <link href="//cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/foundation-icons.css" rel="stylesheet">
+
+    <style>
+      h1 {
+        border-bottom: 1px solid #ddd;
+        margin-bottom: 2rem;
+        width: 100%;
+      }
+
+      h3 {
+        width: 100%;
+      }
+
+      .example {
+        padding: 2rem;
+        border: 1px solid #ddd;
+        width: 100%;
+      }
+
+      .example + h1 {
+        margin-top: 5rem;
+      }
+
+      .example + h3 {
+        margin-top: 3rem;
+      }
+    </style>
+  </head>
+
+  <body>
+    <div class="row">
+      <div class="column">
+        <h1>Menu Centered</h1>
+
+        <h3>Centered Menu (Align Center)</h3>
+        <div class="example">
+          <ul class="menu align-center">
+            <li><a href="#">One</a></li>
+            <li><a href="#">Two</a></li>
+            <li><a href="#">Three</a></li>
+            <li><a href="#">Four</a></li>
+          </ul>
+        </div>
+
+        <h3>Centered Menu (Menu Centered)</h3>
+        <div class="example">
+          <div class="menu-centered">
+            <ul class="menu">
+              <li><a href="#">One</a></li>
+              <li><a href="#">Two</a></li>
+              <li><a href="#">Three</a></li>
+              <li><a href="#">Four</a></li>
+            </ul>
+          </div>
+        </div>
+      </div>
+    </div>
+
+    <script src="../assets/js/vendor.js"></script>
+    <script src="../assets/js/foundation.js"></script>
+    <script>
+      $(document).foundation();
+    </script>
+  </body>
+</html>