forgejo/web_src/css/modules/dialog.css
0ko 79c47c2e50 feat(ui): improve modal width rules (#10246)
Followup to https://codeberg.org/forgejo/forgejo/pulls/9636, https://codeberg.org/forgejo/forgejo/pulls/8859#issuecomment-6651595.

1. Due to lack of `min-width`, currently the new consistent dialogs can get disproportionally small to the screen. This PR adds a min-width of 400px. No deep consideration went into choosing this particular width.
    * To make the test not depend on modals we have in the UI with some arbitrary widths a devtest page was added instead
2. Use more horizontal space on narrow screens

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10246
Reviewed-by: Gusted <gusted@noreply.codeberg.org>
2025-11-28 19:38:50 +01:00

108 lines
2.2 KiB
CSS

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;
z-index: 1001;
pointer-events: auto;
touch-action: auto;
/* Modals shouldn't be wider than 800px ever. On narrow screens they shouldn't
* be wider than the screen, with a small margin */
max-width: min(800px, calc(100vw - var(--page-margin-x) * 2));
/* Modals also should't be tiny compared to the screen width */
min-width: min(400px, calc(100vw - var(--page-margin-x) * 2));
/* Suppress default <dialog> padding */
padding: 0;
}
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 .content:not(.tw-hidden) + form > .content {
padding-top: 0;
}
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;
}