|
| 1 | +/* ActionMenu (dropdown) |
| 2 | +/* ------------------------------------------------------------------------- */ |
| 3 | +/* Open/close animation, selectable (radio/checkbox) items and submenu chevron, |
| 4 | + modeled on the shadcn/ui Dropdown Menu. */ |
| 5 | + |
| 6 | +.dropdown-menu { |
| 7 | + --ea-action-menu-slide: 8px; |
| 8 | +} |
| 9 | + |
| 10 | +/* ENTER: triggered when Bootstrap adds the `.show` class. We animate the |
| 11 | + individual `scale`/`translate` properties (not `transform`) so they compose |
| 12 | + on top of Popper's inline `transform: translate()` positioning instead of |
| 13 | + clobbering it. `transform-origin` is anchored to the corner nearest the |
| 14 | + toggle, mimicking shadcn's --radix-*-transform-origin. */ |
| 15 | +.dropdown-menu.show { |
| 16 | + /* `ease` (the CSS default) is exactly what shadcn/tw-animate-css uses. A strong |
| 17 | + decelerate curve (e.g. --ea-ease-out) has a long, slow tail that reads as sluggish |
| 18 | + at this short duration, so we deliberately match shadcn's `ease` here */ |
| 19 | + animation: ea-action-menu-enter var(--ea-duration-default) ease; |
| 20 | +} |
| 21 | +@keyframes ea-action-menu-enter { |
| 22 | + from { |
| 23 | + opacity: 0; |
| 24 | + scale: 0.95; |
| 25 | + translate: var(--ea-enter-x, 0) var(--ea-enter-y, 0); |
| 26 | + } |
| 27 | + to { |
| 28 | + opacity: 1; |
| 29 | + scale: 1; |
| 30 | + translate: 0 0; |
| 31 | + } |
| 32 | +} |
| 33 | +.dropdown-menu[data-popper-placement^="bottom"] { |
| 34 | + transform-origin: top center; |
| 35 | + --ea-enter-y: calc(-1 * var(--ea-action-menu-slide)); |
| 36 | +} |
| 37 | +.dropdown-menu[data-popper-placement^="top"] { |
| 38 | + transform-origin: bottom center; |
| 39 | + --ea-enter-y: var(--ea-action-menu-slide); |
| 40 | +} |
| 41 | +.dropdown-menu[data-popper-placement^="left"] { |
| 42 | + transform-origin: right center; |
| 43 | + --ea-enter-x: var(--ea-action-menu-slide); |
| 44 | +} |
| 45 | +.dropdown-menu[data-popper-placement^="right"] { |
| 46 | + transform-origin: left center; |
| 47 | + --ea-enter-x: calc(-1 * var(--ea-action-menu-slide)); |
| 48 | +} |
| 49 | +.dropdown-menu[data-popper-placement$="-end"] { |
| 50 | + transform-origin: top right; |
| 51 | +} |
| 52 | +.dropdown-menu[data-popper-placement$="-start"] { |
| 53 | + transform-origin: top left; |
| 54 | +} |
| 55 | + |
| 56 | +/* EXIT: Bootstrap removes `.show` and destroys Popper synchronously, so a |
| 57 | + CSS-only exit can't play. page-layout.js adds `.ea-dropdown-hiding` while |
| 58 | + `.show` (and Popper positioning) is still in place, plays this, then lets |
| 59 | + Bootstrap finish hiding */ |
| 60 | +.dropdown-menu.ea-dropdown-hiding { |
| 61 | + animation: ea-action-menu-exit var(--ea-duration-fast) var(--ea-ease-in) forwards; |
| 62 | + pointer-events: none; |
| 63 | +} |
| 64 | +@keyframes ea-action-menu-exit { |
| 65 | + from { |
| 66 | + opacity: 1; |
| 67 | + scale: 1; |
| 68 | + } |
| 69 | + to { |
| 70 | + opacity: 0; |
| 71 | + scale: var(--ea-action-menu-zoom-from); |
| 72 | + } |
| 73 | +} |
| 74 | + |
| 75 | +@media (prefers-reduced-motion: reduce) { |
| 76 | + .dropdown-menu.show, |
| 77 | + .dropdown-menu.ea-dropdown-hiding { |
| 78 | + animation: none; |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +.dropdown-menu .dropdown-selectable-group { |
| 83 | + list-style: none; |
| 84 | + margin: 0; |
| 85 | + padding: 0; |
| 86 | +} |
| 87 | +.dropdown-menu .dropdown-item-trailing { |
| 88 | + margin-inline-start: auto; |
| 89 | + display: inline-flex; |
| 90 | + align-items: center; |
| 91 | +} |
| 92 | +.dropdown-menu .dropdown-item-check { |
| 93 | + color: var(--color-primary); |
| 94 | + inline-size: 16px; |
| 95 | + block-size: 16px; |
| 96 | + opacity: 0; |
| 97 | + transition: opacity var(--ea-duration-fast) var(--ea-ease-out); |
| 98 | +} |
| 99 | +.dropdown-menu .dropdown-item[aria-checked="true"] .dropdown-item-check, |
| 100 | +.dropdown-menu .dropdown-item-selectable.active .dropdown-item-check { |
| 101 | + opacity: 1; |
| 102 | +} |
| 103 | + |
| 104 | +.dropdown-menu .dropdown-item-selectable.active, |
| 105 | +.dropdown-menu .dropdown-item-selectable[aria-checked="true"] { |
| 106 | + background: var(--dropdown-settings-active-item-bg); |
| 107 | + box-shadow: none; |
| 108 | + color: var(--dropdown-link-color); |
| 109 | +} |
| 110 | +.dropdown-menu .dropdown-item-selectable.active .icon, |
| 111 | +.dropdown-menu .dropdown-item-selectable[aria-checked="true"] .icon { |
| 112 | + color: var(--dropdown-icon-color); |
| 113 | +} |
| 114 | +.dropdown-menu .dropdown-item-selectable.active .dropdown-item-check { |
| 115 | + color: var(--color-primary); |
| 116 | +} |
| 117 | + |
| 118 | +.dropdown-submenu .dropdown-toggle::after, |
| 119 | +.dropdown-submenu .dropdown-toggle::before { |
| 120 | + display: none; /* hide Bootstrap's native caret; we render a chevron icon instead */ |
| 121 | +} |
| 122 | +.dropdown-menu .dropdown-submenu-chevron { |
| 123 | + margin-inline-start: auto; |
| 124 | + color: var(--text-muted); |
| 125 | + inline-size: 16px; |
| 126 | + block-size: 16px; |
| 127 | +} |
| 128 | +/* the chevron follows the side the submenu actually opens to: right by default |
| 129 | + (chevron-right, no flip), flipped to point left when the submenu opens to the |
| 130 | + left (Bootstrap's .dropstart, e.g. datagrid row actions) */ |
| 131 | +.dropstart > .dropdown-submenu-chevron, |
| 132 | +.dropstart > * .dropdown-submenu-chevron { |
| 133 | + scale: -1 1; /* point left */ |
| 134 | + order: -1; /* and sit on the leading (left) edge, the side it opens to */ |
| 135 | + margin-inline-start: 0; |
| 136 | +} |
0 commit comments