mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-10-05 19:30:58 +00:00
feat: first native dialog for modal (#8859)
- The current implementation for modals is provided by fomantic UI. - This patch introduces a new implementation that relies on the `<dialog>` element to provide modal, whereby the heavy lifting is done by the browser. - This implementation is considerably simpler, accessible (although untested) and lightweight. It is capable of replacing fomantic UI's modal implementation + our dimmer implementation (~2k lines of code and CSS).[^1] As a first step the empty content modal is migrated. - This brings in the CSS needed to display `<dialog>` and a helper function that hides some boilerplate code that's needed to show `<dialog>` as a modal. - Add a E2E test that shows the modal's cancel and approve button works. [^1]: The heavy work has already been done by me in a local branch, but reviewing that gigantic patch in one PR is not doable. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/8859 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-committed-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
parent
c00c5d9c48
commit
aa345c9e0c
9 changed files with 232 additions and 57 deletions
|
@ -18,6 +18,7 @@
|
|||
@import "./modules/checkbox.css";
|
||||
@import "./modules/modal.css";
|
||||
@import "./modules/dimmer.css";
|
||||
@import "./modules/dialog.css";
|
||||
|
||||
@import "./modules/switch.css";
|
||||
@import "./modules/dropdown.css";
|
||||
|
|
98
web_src/css/modules/dialog.css
Normal file
98
web_src/css/modules/dialog.css
Normal file
|
@ -0,0 +1,98 @@
|
|||
body:has(dialog[open]) {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
dialog {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
position: fixed;
|
||||
text-align: left;
|
||||
border: none;
|
||||
background: var(--color-body);
|
||||
box-shadow:
|
||||
1px 3px 3px 0 var(--color-shadow),
|
||||
1px 3px 15px 2px var(--color-shadow);
|
||||
border-radius: 0.28571429rem;
|
||||
outline: none;
|
||||
padding: 0;
|
||||
max-width: min(800px, 90vw);
|
||||
width: fit-content;
|
||||
z-index: 1001;
|
||||
|
||||
pointer-events: auto;
|
||||
touch-action: auto;
|
||||
}
|
||||
|
||||
dialog[open],
|
||||
dialog:target {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
dialog::backdrop {
|
||||
background-color: var(--color-overlay-backdrop);
|
||||
will-change: opacity;
|
||||
opacity: 0;
|
||||
animation-name: fadein;
|
||||
animation-duration: 100ms;
|
||||
animation-timing-function: ease-in-out;
|
||||
}
|
||||
|
||||
dialog[open]::backdrop {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
dialog header {
|
||||
font-size: 1.42857143rem;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
font-family: var(--fonts-regular);
|
||||
color: var(--color-text-dark);
|
||||
margin: 0;
|
||||
padding: 1.25rem 1.5rem;
|
||||
box-shadow: none;
|
||||
border-top-left-radius: var(--border-radius);
|
||||
border-top-right-radius: var(--border-radius);
|
||||
border-bottom: 1px solid var(--color-secondary);
|
||||
}
|
||||
|
||||
dialog article {
|
||||
display: block;
|
||||
width: 100%;
|
||||
font-size: 1em;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
dialog .content {
|
||||
padding: 1.5em;
|
||||
background: var(--color-body);
|
||||
color: var(--color-text);
|
||||
}
|
||||
|
||||
dialog .actions {
|
||||
background: var(--color-secondary-bg);
|
||||
border-color: var(--color-secondary);
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
justify-content: flex-end;
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
/* positive/negative action buttons */
|
||||
dialog .actions .ui.button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 10px 12px;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
dialog .actions .ui.button.danger {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
dialog .actions .ui.button .svg {
|
||||
margin-right: 5px;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue