Files
gitea/web_src/css/modules/modal.css
T
silverwindandwxiaoguang e645afbb3f refactor: replace Fomantic modal with native dialog (#39846)
Replace Fomantic's hard-forked jQuery modal with native `<dialog>`
elements, advancing https://github.com/go-gitea/gitea/issues/29849. The
UI is visually unchanged. Dialogs open with `show()` over an `inert`
page, so tooltips, popups and toasts mounted on `<body>` stay usable
above them, unlike with `showModal()`
(https://github.com/whatwg/html/issues/9936).

- Remove the Fomantic modal and dimmer, add `showModal` and `hideModal`
- Declare modals as `<dialog class="modal-dialog">`, shown inside a
`.modal-backdrop`, instead of `ui modal` with its unused size classes
- Remove two modals that could never be opened
- Block the page while a modal is open, close the topmost one on Escape
and restore focus to its opener
- Allow stacked modals, use a confirm modal instead of `window.confirm`
for deleting content history
- Hide popups and toasts when a modal opens or closes
- Keep the release notes modal open when generating notes fails

Fixes: https://github.com/go-gitea/gitea/issues/39643
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2026-10-20 12:32:27 +02:00

121 lines
2.9 KiB
CSS

.modal-page-blocked {
overflow: hidden;
}
.modal-dialog {
text-align: left;
background: var(--color-body);
border: none;
margin: 0;
padding: 0;
color: inherit;
box-shadow: 1px 3px 3px 0 var(--color-shadow), 1px 3px 15px 2px var(--color-shadow);
border-radius: var(--border-radius);
user-select: text;
width: fit-content;
/* on small screens, the modal should not exceed 90% of the viewport width;
on large screens, the modal should not exceed 800px in width (ref: ".ui.container" width is 1280px) */
max-width: min(800px, 90vw);
/* on small screens, the modal should not be smaller than 300px or 90vw in width;
on large screens, the minimum width is 30% of the viewport width, capped at 800px */
min-width: min(800px, max(min(300px, 90vw), 30vw));
}
.modal-dialog > :first-child {
border-top-left-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
}
.modal-dialog > :last-child {
border-bottom-left-radius: var(--border-radius);
border-bottom-right-radius: var(--border-radius);
}
.modal-dialog .close-modal {
cursor: pointer;
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 1rem;
z-index: 1;
opacity: 0.5;
padding: 0;
border: none;
background: none;
width: 1.5rem;
height: 1.5rem;
}
.modal-dialog .close-modal::before {
content: "";
display: block;
width: 100%;
height: 100%;
background-color: currentcolor;
mask-image: var(--octicon-x);
mask-size: cover;
}
.modal-dialog .close-modal:hover {
opacity: 1;
}
.modal-dialog > .header {
display: block;
position: relative;
font-size: 18px;
font-weight: var(--font-weight-medium);
background: var(--color-body);
margin: 0;
padding: 1.25rem 3rem 1.25rem 1.5rem; /* leave more right space for the "close" button */
box-shadow: none;
color: var(--color-text-dark);
border-bottom: 1px solid var(--color-secondary);
border-top-left-radius: var(--border-radius);
border-top-right-radius: var(--border-radius);
}
.modal-dialog > .content,
.modal-dialog form > .content {
display: block;
width: 100%;
font-size: 1em;
line-height: 1.4;
padding: 1.5em;
background: var(--color-body);
border-radius: 0 0 var(--border-radius) var(--border-radius);
}
.modal-dialog > .actions,
.modal-dialog .content + .actions,
.modal-dialog .content + form > .actions {
background: var(--color-secondary-bg);
padding: 1rem;
border-top: 1px solid var(--color-secondary);
text-align: right;
border-radius: 0 0 var(--border-radius) var(--border-radius);
}
.modal-dialog .content > form > .actions,
.modal-dialog .content > .actions {
padding-top: 1em;
text-align: right;
}
.modal-dialog .actions > .ui.button {
display: inline-flex;
gap: var(--gap-inline);
align-items: center;
padding-inline: 10px 12px;
margin-left: 0.75em;
margin-right: 0;
}
.modal-dialog .actions > .ui.button.danger {
display: block;
width: 100%;
margin: 0 auto;
text-align: center;
}