project_note
Clone
https://git.tahinli.com/Tahinli/project_note.git
0 watching0 forksRust3.6 MiBc49f5e7Tahinli1 month ago2 commits
| 1 | use |
| 2 | |
| 3 | |
| 4 | ; |
| 5 | |
| 6 | use ; |
| 7 | |
| 8 | /// A floating action menu controlled by a trigger. |
| 9 | /// |
| 10 | /// Add a [`dropdown_menu_trigger`] and a [`dropdown_menu_content`] as children. Create |
| 11 | /// an ID with [`element_id`](topcoat::view::element_id) and use it for the trigger's |
| 12 | /// `target` and the content's `id`. The button opens and closes the menu without |
| 13 | /// JavaScript. Clicking outside or pressing Escape also closes it. The menu appears |
| 14 | /// above the page and is not cut off by a parent's overflow settings. |
| 15 | /// |
| 16 | /// `attrs` adds attributes and classes to the wrapper `<div>`, which takes up no space |
| 17 | /// in the layout. Use Tab to move between items. Arrow-key menu navigation is not |
| 18 | /// provided. |
| 19 | /// |
| 20 | /// ```ignore |
| 21 | /// view! { |
| 22 | /// let menu = element_id(cx); |
| 23 | /// dropdown_menu( |
| 24 | /// dropdown_menu_trigger(target: &menu, "Options") |
| 25 | /// dropdown_menu_content( |
| 26 | /// id: &menu, |
| 27 | /// align: FloatingAlign::Start, |
| 28 | /// dropdown_menu_item(close: Some(&menu), "Rename") |
| 29 | /// dropdown_menu_item(close: Some(&menu), "Duplicate") |
| 30 | /// dropdown_menu_separator() |
| 31 | /// dropdown_menu_item( |
| 32 | /// close: Some(&menu), |
| 33 | /// attrs: attributes! { class="text-destructive" }, |
| 34 | /// "Delete" |
| 35 | /// ) |
| 36 | /// ) |
| 37 | /// ) |
| 38 | /// } |
| 39 | /// ``` |
| 40 | |
| 41 | pub async |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | |
| 53 | |
| 54 | |
| 55 | /// A button for opening and closing the dropdown menu. |
| 56 | /// |
| 57 | /// Set `target` to the [`dropdown_menu_content`]'s `id` and put the button's label in |
| 58 | /// its children. Add [`button_variants`](super::button::button_variants) classes through |
| 59 | /// `attrs` to give it the standard button style. All attributes go on the `<button>`. |
| 60 | /// Use `group-has-[:popover-open]/dropdown-menu:` classes to change how children look |
| 61 | /// while the menu is open. |
| 62 | /// |
| 63 | /// ```ignore |
| 64 | /// view! { |
| 65 | /// dropdown_menu_trigger( |
| 66 | /// target: &menu, |
| 67 | /// attrs: attributes! { |
| 68 | /// class=(button_variants(ButtonVariant::Outline, ButtonSize::Md)) |
| 69 | /// }, |
| 70 | /// "Options" |
| 71 | /// icon( |
| 72 | /// data: iconify_icon!("lucide:chevron-down"), |
| 73 | /// attrs: attributes! { |
| 74 | /// class="group-has-[:popover-open]/dropdown-menu:rotate-180" |
| 75 | /// } |
| 76 | /// ) |
| 77 | /// ) |
| 78 | /// } |
| 79 | /// ``` |
| 80 | |
| 81 | pub async |
| 82 | |
| 83 | |
| 84 | |
| 85 | |
| 86 | |
| 87 | |
| 88 | |
| 89 | |
| 90 | |
| 91 | |
| 92 | |
| 93 | |
| 94 | |
| 95 | |
| 96 | |
| 97 | |
| 98 | |
| 99 | |
| 100 | |
| 101 | |
| 102 | |
| 103 | /// Classes for floating menu panels with their own background, border, and text color. |
| 104 | const PANEL: StaticClass = class! |
| 105 | |
| 106 | |
| 107 | ; |
| 108 | |
| 109 | /// The floating panel of a [`dropdown_menu`], holding the menu's items. |
| 110 | /// |
| 111 | /// Use `side` to choose where the menu opens and `align` to line it up with the button. |
| 112 | /// By default, it opens below the button and is centered on it. The browser tries other |
| 113 | /// positions if there is not enough room in the window. |
| 114 | |
| 115 | pub async |
| 116 | |
| 117 | |
| 118 | |
| 119 | |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | |
| 125 | |
| 126 | |
| 127 | |
| 128 | |
| 129 | |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | |
| 136 | |
| 137 | |
| 138 | |
| 139 | |
| 140 | |
| 141 | |
| 142 | |
| 143 | |
| 144 | |
| 145 | |
| 146 | |
| 147 | /// Classes for a menu item and its interaction states. |
| 148 | const ITEM: StaticClass = class! |
| 149 | |
| 150 | |
| 151 | |
| 152 | |
| 153 | ; |
| 154 | |
| 155 | /// A button for an action inside [`dropdown_menu_content`]. |
| 156 | /// |
| 157 | /// The button defaults to `type="button"`. Pass the menu's ID to `close` to close the |
| 158 | /// menu and its submenus when clicked. Omit `close` to leave them open. If you set |
| 159 | /// `type="submit"` through `attrs`, the button submits its form and ignores `close`. |
| 160 | |
| 161 | pub async |
| 162 | |
| 163 | |
| 164 | |
| 165 | |
| 166 | |
| 167 | |
| 168 | |
| 169 | |
| 170 | |
| 171 | |
| 172 | |
| 173 | |
| 174 | |
| 175 | |
| 176 | |
| 177 | |
| 178 | |
| 179 | |
| 180 | |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | /// A nested menu that opens from a row in the parent menu. |
| 186 | /// |
| 187 | /// Add a [`dropdown_menu_sub_trigger`] and a [`dropdown_menu_sub_content`] as children. |
| 188 | /// Give the trigger's `target` and the content's `id` the same value. The parent menu |
| 189 | /// stays open when the submenu opens. Closing the parent closes the submenu too. |
| 190 | /// |
| 191 | /// `attrs` adds attributes and classes to the wrapper `<div>`. The wrapper takes up no |
| 192 | /// space in the layout. |
| 193 | /// |
| 194 | /// ```ignore |
| 195 | /// view! { |
| 196 | /// let menu = element_id(cx); |
| 197 | /// let move_to = element_id(cx); |
| 198 | /// dropdown_menu_content( |
| 199 | /// id: &menu, |
| 200 | /// dropdown_menu_item(close: Some(&menu), "Back") |
| 201 | /// dropdown_menu_sub( |
| 202 | /// dropdown_menu_sub_trigger(target: &move_to, "Move to") |
| 203 | /// dropdown_menu_sub_content( |
| 204 | /// id: &move_to, |
| 205 | /// dropdown_menu_item(close: Some(&menu), "Inbox") |
| 206 | /// dropdown_menu_item(close: Some(&menu), "Archive") |
| 207 | /// ) |
| 208 | /// ) |
| 209 | /// ) |
| 210 | /// } |
| 211 | /// ``` |
| 212 | |
| 213 | pub async |
| 214 | |
| 215 | |
| 216 | |
| 217 | |
| 218 | |
| 219 | |
| 220 | |
| 221 | |
| 222 | |
| 223 | |
| 224 | |
| 225 | |
| 226 | |
| 227 | /// The row that opens or closes a submenu. |
| 228 | /// |
| 229 | /// Set `target` to the [`dropdown_menu_sub_content`]'s `id` and put the label in the |
| 230 | /// children. The row includes a chevron and stays highlighted while the submenu is |
| 231 | /// open. `attrs` adds attributes and classes to the row's `<button>`. |
| 232 | |
| 233 | pub async |
| 234 | |
| 235 | |
| 236 | |
| 237 | |
| 238 | |
| 239 | |
| 240 | |
| 241 | |
| 242 | |
| 243 | |
| 244 | |
| 245 | |
| 246 | |
| 247 | |
| 248 | |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | |
| 254 | |
| 255 | |
| 256 | |
| 257 | |
| 258 | |
| 259 | |
| 260 | |
| 261 | |
| 262 | |
| 263 | |
| 264 | |
| 265 | |
| 266 | |
| 267 | |
| 268 | |
| 269 | /// A submenu that opens beside its button, to the right unless `side` says otherwise. |
| 270 | /// |
| 271 | /// The browser tries other positions if the submenu does not fit in the window. |
| 272 | |
| 273 | pub async |
| 274 | |
| 275 | |
| 276 | |
| 277 | |
| 278 | |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | |
| 286 | |
| 287 | |
| 288 | |
| 289 | |
| 290 | |
| 291 | |
| 292 | |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | |
| 298 | |
| 299 | |
| 300 | |
| 301 | |
| 302 | /// A non-interactive heading grouping the items after it. |
| 303 | |
| 304 | pub async |
| 305 | |
| 306 | |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | |
| 315 | |
| 316 | |
| 317 | |
| 318 | |
| 319 | |
| 320 | |
| 321 | /// A hairline rule separating groups of items. |
| 322 | |
| 323 | pub async |
| 324 | |
| 325 | |
| 326 | |
| 327 |