askrobots / dbbasic-web-native
Public
100+ copy-paste UI components in plain HTML and CSS: no dependencies, no build step.
danq9
Add canonical.html v1.0 - The single source of truth for usability standards
fb6e650
1 year ago
History
semantic-menu.html · 7.5 KB · 160 lines
| 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta charset="UTF-8"> |
| 5 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 6 | <title>semantic-menu - Semantic Components</title> |
| 7 | <script src="../semantic-components.js"></script> |
| 8 | <link rel="stylesheet" href="component-docs.css"> |
| 9 | </head> |
| 10 | <body> |
| 11 | <div class="container"> |
| 12 | <!-- Header --> |
| 13 | <div class="header"> |
| 14 | <h1 class="component-name"><semantic-menu></h1> |
| 15 | <p class="tagline">Context menus and dropdowns with smart positioning</p> |
| 16 | <div class="quick-example"> |
| 17 | <semantic-action id="menu-btn">Options ▼</semantic-action> |
| 18 | <semantic-menu anchor="#menu-btn" open> |
| 19 | <menu-item action="edit">✏️ Edit</menu-item> |
| 20 | <menu-item action="copy">📋 Copy</menu-item> |
| 21 | <menu-divider></menu-divider> |
| 22 | <menu-item action="delete" intent="destructive">🗑️ Delete</menu-item> |
| 23 | </semantic-menu> |
| 24 | </div> |
| 25 | </div> |
| 26 | |
| 27 | <!-- Overview --> |
| 28 | <section class="section"> |
| 29 | <h2 class="section-title">Overview</h2> |
| 30 | <p class="section-description">The semantic-menu component displays dropdown/context menus with automatic positioning relative to an anchor element. Menus close on outside click or Escape key.</p> |
| 31 | </section> |
| 32 | |
| 33 | <!-- Examples --> |
| 34 | <section class="section"> |
| 35 | <h2 class="section-title">Examples</h2> |
| 36 | <div class="grid"> |
| 37 | |
| 38 | <div class="example"> |
| 39 | <div class="example-label">Dropdown Menu</div> |
| 40 | <div class="example-demo"> |
| 41 | <semantic-action id="menu-btn">Options ▼</semantic-action> |
| 42 | <semantic-menu anchor="#menu-btn" open> |
| 43 | <menu-item action="edit">✏️ Edit</menu-item> |
| 44 | <menu-item action="copy">📋 Copy</menu-item> |
| 45 | <menu-divider></menu-divider> |
| 46 | <menu-item action="delete" intent="destructive">🗑️ Delete</menu-item> |
| 47 | </semantic-menu> |
| 48 | </div> |
| 49 | <div class="example-code"><semantic-action id="menu-btn">Options ▼</semantic-action> |
| 50 | <semantic-menu anchor="#menu-btn" open> |
| 51 | <menu-item action="edit">✏️ Edit</menu-item> |
| 52 | <menu-item action="copy">📋 Copy</menu-item> |
| 53 | <menu-divider></menu-divider> |
| 54 | <menu-item action="delete" intent="destructive">🗑️ Delete</menu-item> |
| 55 | </semantic-menu></div> |
| 56 | <div class="example-notes">Use for: Action menus, context menus, dropdowns<br>Visual: Floating panel with shadow<br>Interaction: Click outside or Escape to close</div> |
| 57 | </div> |
| 58 | </div> |
| 59 | </section> |
| 60 | |
| 61 | <!-- Interactive States --> |
| 62 | <section class="section"> |
| 63 | <h2 class="section-title">Interactive States</h2> |
| 64 | <div class="state-showcase"> |
| 65 | |
| 66 | <div class="state-box"> |
| 67 | <div class="state-label">Closed State</div> |
| 68 | <div class="state-visual state-closed"> |
| 69 | <semantic-menu intent="primary" >Closed</semantic-menu> |
| 70 | </div> |
| 71 | <div class="state-description">Hidden (display: none)</div> |
| 72 | </div> |
| 73 | <div class="state-box"> |
| 74 | <div class="state-label">Open State</div> |
| 75 | <div class="state-visual state-open"> |
| 76 | <semantic-menu intent="primary" >Open</semantic-menu> |
| 77 | </div> |
| 78 | <div class="state-description">Visible with scale-in animation, positioned near anchor</div> |
| 79 | </div> |
| 80 | <div class="state-box"> |
| 81 | <div class="state-label">Hover (items) State</div> |
| 82 | <div class="state-visual state-hover (items)"> |
| 83 | <semantic-menu intent="primary" >Hover (items)</semantic-menu> |
| 84 | </div> |
| 85 | <div class="state-description">Blue background on menu item hover</div> |
| 86 | </div> |
| 87 | </div> |
| 88 | </section> |
| 89 | |
| 90 | <!-- Properties --> |
| 91 | <section class="section"> |
| 92 | <h2 class="section-title">Properties & Attributes</h2> |
| 93 | <table class="property-table"> |
| 94 | <thead> |
| 95 | <tr> |
| 96 | <th>Attribute</th> |
| 97 | <th>Type</th> |
| 98 | <th>Values</th> |
| 99 | <th>Default</th> |
| 100 | <th>Description</th> |
| 101 | </tr> |
| 102 | </thead> |
| 103 | <tbody> |
| 104 | |
| 105 | <tr style="border-bottom: 1px solid #333;"> |
| 106 | <td style="padding: 12px;"><span class="prop-name">open</span></td> |
| 107 | <td style="padding: 12px;"><span class="prop-type">boolean</span></td> |
| 108 | <td style="padding: 12px;"><span class="prop-values">true | false</span></td> |
| 109 | <td style="padding: 12px;">false</td> |
| 110 | <td style="padding: 12px;">Whether menu is currently shown</td> |
| 111 | </tr> |
| 112 | <tr style="border-bottom: 1px solid #333;"> |
| 113 | <td style="padding: 12px;"><span class="prop-name">anchor</span></td> |
| 114 | <td style="padding: 12px;"><span class="prop-type">string</span></td> |
| 115 | <td style="padding: 12px;"><span class="prop-values">Element ID or selector</span></td> |
| 116 | <td style="padding: 12px;"></td> |
| 117 | <td style="padding: 12px;">Element to position relative to</td> |
| 118 | </tr> |
| 119 | |
| 120 | <tr style="border-bottom: 1px solid #333;"> |
| 121 | <td style="padding: 12px;"><span class="prop-name">default</span></td> |
| 122 | <td style="padding: 12px;"><span class="prop-type">slot</span></td> |
| 123 | <td style="padding: 12px;">menu-item elements and menu-divider separators</td> |
| 124 | </tr> |
| 125 | </tbody> |
| 126 | </table> |
| 127 | </section> |
| 128 | |
| 129 | <!-- Events --> |
| 130 | <section class="section"> |
| 131 | <h2 class="section-title">Events</h2> |
| 132 | <table class="property-table"> |
| 133 | <thead> |
| 134 | <tr> |
| 135 | <th>Event</th> |
| 136 | <th>Trigger</th> |
| 137 | <th>Detail</th> |
| 138 | <th>Description</th> |
| 139 | </tr> |
| 140 | </thead> |
| 141 | <tbody> |
| 142 | |
| 143 | <tr style="border-bottom: 1px solid #333;"> |
| 144 | <td style="padding: 12px;"><span class="prop-name">select</span></td> |
| 145 | <td style="padding: 12px;">Menu item clicked</td> |
| 146 | <td style="padding: 12px;"><code>{ action, label }</code></td> |
| 147 | <td style="padding: 12px;">Menu item selection event</td> |
| 148 | </tr> |
| 149 | <tr style="border-bottom: 1px solid #333;"> |
| 150 | <td style="padding: 12px;"><span class="prop-name">close</span></td> |
| 151 | <td style="padding: 12px;">Outside click, Escape key</td> |
| 152 | <td style="padding: 12px;"><code>{ type: "close" }</code></td> |
| 153 | <td style="padding: 12px;">Menu closed event</td> |
| 154 | </tr> |
| 155 | </tbody> |
| 156 | </table> |
| 157 | </section> |
| 158 | </div> |
| 159 | </body> |
| 160 | </html> |