|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>PatternFly Element | pfe-dropdown Demo</title> |
| 6 | + |
| 7 | + <noscript> |
| 8 | + <link |
| 9 | + href="../../pfelement/pfelement-noscript.min.css" |
| 10 | + rel="stylesheet" |
| 11 | + /> |
| 12 | + </noscript> |
| 13 | + |
| 14 | + <!-- uncomment the es5-adapter if you're using the umd version --> |
| 15 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.2.10/custom-elements-es5-adapter.js"></script> |
| 16 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/2.2.10/webcomponents-bundle.js"></script> |
| 17 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.5/require.min.js"></script> |
| 18 | + <script> |
| 19 | + require(["../dist/pfe-dropdown.umd.js"]); |
| 20 | + </script> |
| 21 | + </head> |
| 22 | + <style> |
| 23 | + body { |
| 24 | + font-family: "Red Hat Text", Overpass, Helvetica, sans-serif; |
| 25 | + position: relative; |
| 26 | + } |
| 27 | + </style> |
| 28 | + |
| 29 | + <body unresolved> |
| 30 | + <h1><pfe-dropdown></h1> |
| 31 | + |
| 32 | + <h2>Expandable dropdown</h2> |
| 33 | + |
| 34 | + <pfe-dropdown pfe-label="Dropdown"> |
| 35 | + <pfe-dropdown-item pfe-item-type="link"> |
| 36 | + <a href="https://bit.ly/3b9wvWg">Link 1</a> |
| 37 | + </pfe-dropdown-item> |
| 38 | + <pfe-dropdown-item pfe-item-type="link"> |
| 39 | + <a href="https://bit.ly/3b9wvWg">Link 2</a> |
| 40 | + </pfe-dropdown-item> |
| 41 | + <pfe-dropdown-item pfe-item-type="link" is_disabled> |
| 42 | + <a href="https://bit.ly/3b9wvWg">Link 3</a> |
| 43 | + </pfe-dropdown-item> |
| 44 | + <pfe-dropdown-item pfe-item-type="separator"></pfe-dropdown-item> |
| 45 | + <pfe-dropdown-item pfe-item-type="action"> |
| 46 | + <button>Action 1</button> |
| 47 | + </pfe-dropdown-item> |
| 48 | + <pfe-dropdown-item pfe-item-type="action" is_disabled> |
| 49 | + <button>Action 2</button> |
| 50 | + </pfe-dropdown-item> |
| 51 | + <pfe-dropdown-item pfe-item-type="link"> |
| 52 | + <a href="https://bit.ly/3b9wvWg">Link 4</a> |
| 53 | + </pfe-dropdown-item> |
| 54 | + </pfe-dropdown> |
| 55 | + <p id="example-dropdown-1">Selected Action: <span id="example-action-1"></span></p> |
| 56 | + |
| 57 | + <h2>Dropdown with custom dropdown options</h2> |
| 58 | + <pfe-dropdown pfe-label="Dropdown" id="dropdown-with-custom-options"> |
| 59 | + </pfe-dropdown> |
| 60 | + <p id="example-dropdown-2">Selected Action: <span id="example-action-2"></span></p> |
| 61 | + |
| 62 | + <h2>Disabled dropdown</h2> |
| 63 | + |
| 64 | + <pfe-dropdown pfe-label="Disabled" is_disabled> |
| 65 | + <pfe-dropdown-item pfe-item-type="link"> |
| 66 | + <a href="https://bit.ly/3b9wvWg">Link 1</a> |
| 67 | + </pfe-dropdown-item> |
| 68 | + <pfe-dropdown-item pfe-item-type="link"> |
| 69 | + <a href="https://bit.ly/3b9wvWg">Link 2</a> |
| 70 | + </pfe-dropdown-item> |
| 71 | + <pfe-dropdown-item pfe-item-type="link" is_disabled> |
| 72 | + <a href="https://bit.ly/3b9wvWg">Link 2</a> |
| 73 | + </pfe-dropdown-item> |
| 74 | + <pfe-dropdown-item pfe-item-type="separator"></pfe-dropdown-item> |
| 75 | + <pfe-dropdown-item pfe-item-type="action"> |
| 76 | + <button>Action 1</button> |
| 77 | + </pfe-dropdown-item> |
| 78 | + </pfe-dropdown> |
| 79 | + |
| 80 | + <h2>Expandable dropdown with all disabled options</h2> |
| 81 | + |
| 82 | + <pfe-dropdown pfe-label="Dropdown"> |
| 83 | + <pfe-dropdown-item pfe-item-type="link" is_disabled> |
| 84 | + <a href="https://bit.ly/3b9wvWg">Link 1</a> |
| 85 | + </pfe-dropdown-item> |
| 86 | + <pfe-dropdown-item pfe-item-type="link" is_disabled> |
| 87 | + <a href="https://bit.ly/3b9wvWg">Link 2</a> |
| 88 | + </pfe-dropdown-item> |
| 89 | + <pfe-dropdown-item pfe-item-type="link" is_disabled> |
| 90 | + <a href="https://bit.ly/3b9wvWg">Link 3</a> |
| 91 | + </pfe-dropdown-item> |
| 92 | + </pfe-dropdown> |
| 93 | + |
| 94 | + <script> |
| 95 | + let dropdown = document.querySelector("pfe-dropdown"); |
| 96 | + document.querySelector("#example-dropdown-1").style.display = "none"; |
| 97 | + dropdown.addEventListener("pfe-dropdown:change", function(event) { |
| 98 | + document.querySelector("#example-action-1").textContent = |
| 99 | + event.detail.action; |
| 100 | + document.querySelector("#example-dropdown-1").style.display = "block"; |
| 101 | + }); |
| 102 | + |
| 103 | + let dropdownWithCustomOptions = document.querySelector("#dropdown-with-custom-options"); |
| 104 | + customElements.whenDefined("pfe-dropdown").then(function() { |
| 105 | + // Default Options |
| 106 | + dropdownWithCustomOptions.pfeDropdownOptions = [ |
| 107 | + { href: "https://bit.ly/3b9wvWg", text: "Link 1", type: "link", is_disabled: false }, |
| 108 | + { href: "https://bit.ly/3b9wvWg", text: "Link 2", type: "link", is_disabled: false }, |
| 109 | + { href: "https://bit.ly/3b9wvWg", text: "Link 3", type: "link", is_disabled: true }, |
| 110 | + { type: "separator" }, |
| 111 | + { text: "Action 1", type: "action", is_disabled: false }, |
| 112 | + { text: "Action 2", type: "action", is_disabled: true } |
| 113 | + ]; |
| 114 | + // Options passed via addDropdownOptions() method |
| 115 | + dropdownWithCustomOptions.addDropdownOptions( |
| 116 | + [ |
| 117 | + { href: "https://bit.ly/3b9wvWg", text: "Link 4", type: "link", is_disabled: false } |
| 118 | + ] |
| 119 | + ); |
| 120 | + }); |
| 121 | + document.querySelector("#example-dropdown-2").style.display = "none"; |
| 122 | + dropdownWithCustomOptions.addEventListener("pfe-dropdown:change", function(event) { |
| 123 | + document.querySelector("#example-action-2").textContent = |
| 124 | + event.detail.action; |
| 125 | + document.querySelector("#example-dropdown-2").style.display = "block"; |
| 126 | + }); |
| 127 | + </script> |
| 128 | + </body> |
| 129 | +</html> |
0 commit comments