Last active
          November 1, 2018 18:29 
        
      - 
      
- 
        Save mbmohib/c5e664f6457c38a0d3d434060275e6a8 to your computer and use it in GitHub Desktop. 
    Add Arrow to nested Dropdown Menu
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | /** | |
| * Find any element that has dropdown ul | |
| * and add "down arrow" to 1st level | |
| * and "right arrow" to 2nd level | |
| * | |
| * @param {*} nodeList | |
| */ | |
| const addArrowIconToDropdown = (nodeList) => { | |
| const nodeListArray = Array.prototype.slice.call(nodeList) | |
| nodeListArray.length > 0 && nodeListArray.forEach(list => { | |
| if (list.querySelector('ul')) { | |
| if (list.querySelectorAll('ul').length > 1) { | |
| list.querySelector('a').insertAdjacentHTML('beforeend', '<span uk-icon="triangle-down"></span>') | |
| } else { | |
| list.querySelector('a').insertAdjacentHTML('beforeend', '<span uk-icon="triangle-right"></span>') | |
| } | |
| } | |
| }) | |
| } | |
| export default addArrowIconToDropdown; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment