From c53dbde8ad398706a0982335e2d724131e462b56 Mon Sep 17 00:00:00 2001 From: redonkulus Date: Fri, 15 May 2020 19:49:15 -0700 Subject: [PATCH] fix #799 - Vertical Menu with Submenus not working --- site/src/pages/menus/index.js | 429 +++++++++++++++++----------------- 1 file changed, 213 insertions(+), 216 deletions(-) diff --git a/site/src/pages/menus/index.js b/site/src/pages/menus/index.js index 4195a2a..da5fc46 100644 --- a/site/src/pages/menus/index.js +++ b/site/src/pages/menus/index.js @@ -1,5 +1,5 @@ import Link from '@docusaurus/Link'; -import React from 'react'; +import React, { useEffect } from 'react'; import Layout from '../../theme/Layout'; import Header from '../../../components/Header'; import Example from '../../../components/Example'; @@ -8,238 +8,235 @@ import { handleClick } from '../../../lib/utils'; const title = 'Menus'; const description = 'Simple CSS for menus.'; +let menuLoaded = false; function Menus() { - return ( - -
+ + // load external menu js dynamically + useEffect(() => { + if (!menuLoaded) { + const script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = '/js/menus.js'; + document.head.appendChild(script); + menuLoaded = true; + } + }); -
- + return ( + +
-

- Menus are vertical by default. Minimal default styling and low-specificity - selectors make them easy to customize. By default, menu items take up - 100% of the width of their container, so you may want to limit the menu - width or set the menu to display:inline-block. -

+
+ - -