discourse/app/assets/stylesheets/common/base/modal.scss
chapoi f698bb9088
UX: fix cmd-k bottom padding (#34440)
Moved some things around to fix the lack of bottom padding while
searching for results:
<img width="1706" height="398" alt="CleanShot 2025-08-20 at 15 58 32@2x"
src="https://github.com/user-attachments/assets/c67f2c35-719d-4a3d-98ee-191353a476e2"
/>

🔽 
<img width="1706" height="398" alt="CleanShot 2025-08-20 at 15 52 13@2x"
src="https://github.com/user-attachments/assets/65869c9d-06b7-4dd9-b5ef-156e320a798a"
/>
2025-08-20 16:45:39 +02:00

721 lines
12 KiB
SCSS
Vendored

@use "lib/viewport";
html.modal-open {
// prevents bg scrolling when modal is open
overflow: hidden;
scrollbar-gutter: stable;
}
html.keyboard-visible.mobile-view {
.d-modal {
max-height: calc(var(--composer-vh, 1dvh) * 100);
height: calc(var(--composer-vh, 1dvh) * 100);
bottom: 0;
}
.d-modal__container {
max-height: calc(var(--composer-vh, 1dvh) * 100);
height: calc(var(--composer-vh, 1dvh) * 100);
}
}
html:not(.keyboard-visible).mobile-device {
.d-modal__container {
padding-bottom: env(safe-area-inset-bottom, 1rem);
}
}
// Modal wrappers
.d-modal {
pointer-events: none; // Allow clicks through wrappers so they hit the adjacent backdrop element
display: flex;
align-items: center;
width: 100%;
height: 100%;
position: fixed;
top: 0;
z-index: z("modal", "content");
overflow: auto;
@include viewport.until(sm) {
align-items: flex-end;
}
@include viewport.from(sm) {
--modal-max-width: 600px;
--modal-width: 30em; // set in ems to scale with user font-size
--modal-min-width: 400px;
}
&.-inline {
position: relative;
}
&__container {
display: flex;
flex-direction: column;
pointer-events: auto;
box-sizing: border-box;
border-radius: var(--d-border-radius);
margin: 0 auto;
background-color: var(--secondary);
box-shadow: var(--shadow-modal);
max-height: var(--modal-max-height, 80vh); // unset, optional theme utility
@include viewport.until(sm) {
// this is a hack to prevent issues on safari with transforms
position: fixed;
width: 100%;
max-width: 100%;
max-height: calc(var(--composer-vh, 1dvh) * 85);
}
@include viewport.from(sm) {
max-width: var(--modal-max-width);
min-width: var(--modal-min-width);
min-height: var(--modal-min-height); // unset, optional theme utility
.d-modal.-large & {
max-width: 800px;
}
.d-modal.-max & {
max-width: 90vw;
}
}
}
&__header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem;
border-bottom: 1px solid var(--content-border-color);
&:not(.--has-primary-action) {
padding: 0.5rem 0.5rem 0.5rem 1.5rem; // offset for close button padding
}
.modal-close {
margin-left: auto;
align-self: start;
.d-icon {
font-size: var(--font-up-2);
color: var(--primary-high);
}
&:focus-visible {
.d-icon {
color: var(--primary);
}
}
}
}
.d-modal__primary-action,
.d-modal__dismiss-action {
.btn {
text-transform: capitalize;
}
}
&__title-text {
font-size: var(--font-up-1-rem);
line-height: var(--line-height-medium);
@include viewport.from(sm) {
font-size: var(--font-up-3);
}
}
&__title-text,
&__subtitle-text {
margin: 0;
}
&__body {
overflow-y: auto;
padding: 1rem 1.5rem;
box-sizing: border-box;
&.empty {
display: none;
}
input {
width: auto;
&[type="text"] {
width: 100%;
}
}
textarea {
width: 100%;
height: 80px;
}
.password-confirmation {
display: none;
}
section.field {
padding: 0.25em 0;
margin-bottom: 5px;
&.with-items {
display: flex;
align-items: flex-start;
}
.field-item {
display: inline-block;
margin-right: 10px;
}
}
pre code {
white-space: pre-wrap;
max-width: 100%;
}
}
&__footer {
display: flex;
flex-wrap: wrap;
align-items: center;
padding: 1rem 1.5rem;
border-top: 1px solid var(--content-border-color);
gap: 0.5rem;
@include viewport.until(sm) {
&__footer {
margin-top: auto;
.--stacked & {
flex-direction: column;
align-items: stretch;
}
}
}
}
&__backdrop {
user-select: none;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: z("modal", "overlay");
background-color: #000;
animation: fade 0.3s forwards;
@media (prefers-reduced-motion) {
animation-duration: 0s;
}
}
#modal-alert {
padding-left: 1.5rem;
}
.ios-device & {
&__footer {
margin-top: auto;
}
}
// fixes modal placement on Android when keyboard is visible
html.keyboard-visible:not(.ios-device) & {
height: calc(100% - env(keyboard-inset-height));
.d-modal__container {
max-height: 100%;
min-height: 100%;
height: 100%;
}
}
}
// legacy
.input-hint-text {
margin-left: 0.5em;
color: var(--secondary-high);
}
.modal-backdrop {
user-select: none;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: z("modal", "overlay");
background-color: #111;
&.fade {
opacity: 0;
}
}
.modal-backdrop,
.modal-backdrop.fade.in {
animation: fade 0.3s;
opacity: 0.9;
filter: alpha(opacity=90);
@media (prefers-reduced-motion) {
animation-duration: 0s;
}
}
// fade in
@keyframes fade {
from {
opacity: 0;
}
to {
opacity: 0.6;
}
}
.modal-form {
margin-bottom: 0;
}
.modal {
&.has-tabs {
.modal-tabs {
display: inline-flex;
flex-wrap: wrap;
flex: 1 0 auto;
margin: 0;
.modal-tab {
list-style: none;
padding: 4px 8px;
margin-right: 4px;
cursor: pointer;
&.is-active {
color: var(--secondary);
background: var(--danger);
&.single-tab {
background: none;
color: var(--primary);
padding: 0;
font-size: var(--font-up-3);
font-weight: bold;
}
}
}
}
}
&:not(.has-tabs) {
.modal-tab {
position: absolute;
width: 95%;
}
}
.nav {
padding: 10px 30px 10px 15px;
background-color: var(--secondary);
border-bottom: 1px solid var(--content-border-color);
li > a {
font-size: var(--font-0);
}
}
&.hidden {
display: none;
}
pre code {
white-space: pre-wrap;
max-width: var(--modal-max-width);
}
.close {
font-size: var(--font-up-4);
text-decoration: none;
cursor: pointer;
@include viewport.from(sm) {
font-size: var(--font-up-3);
&:hover {
color: var(--primary);
}
}
}
@include viewport.from(sm) {
.category-chooser {
width: 50%;
}
}
}
.reply-where-modal {
.dialog-content {
width: 100%;
min-width: unset;
max-width: 30em;
}
.dialog-footer {
display: block;
}
.btn {
display: block;
text-align: left;
margin-bottom: 0.75em;
margin-right: 0;
overflow: hidden;
width: 100%;
border-radius: var(--d-border-radius);
&.dialog-close {
display: none;
}
&.btn-reply-on-original {
--text-color: var(--secondary);
}
&.btn-reply-where__cancel {
padding-left: 0;
margin: 0;
}
&.btn-reply-here {
--text-color: var(--primary);
.discourse-no-touch & {
&:hover {
--text-color: var(--secondary);
}
}
}
&.btn-reply-where {
min-height: 3em; // for situations when there are no categories/tags
}
.fancy-title {
display: inline-block;
width: 100%;
@include ellipsis;
}
.topic-title__top-line {
display: flex;
align-items: baseline;
color: var(--text-color);
font-size: var(--font-up-1);
.d-icon {
color: var(--text-color);
margin: 0;
}
}
.topic-statuses {
display: flex;
font-size: 0.95em;
}
.topic-title__bottom-line {
margin-top: 0.15em;
display: flex;
align-items: baseline;
gap: 0.5em;
.discourse-tags {
font-size: var(--font-down-1);
}
.badge-category__name,
.discourse-tag {
color: var(--text-color);
}
}
}
}
.admin-delete-user-posts-progress-modal {
.progress-bar {
height: 15px;
position: relative;
background: var(--primary-low-mid);
border-radius: 25px;
overflow: hidden;
margin: 30px 0 20px;
span {
display: block;
width: 0%;
height: 100%;
background-color: var(--tertiary);
position: relative;
transition: width 0.6s linear;
}
}
}
.incoming-email-modal {
max-height: 80vh;
.btn {
background-color: transparent;
margin-right: 5px;
&:hover,
&.active {
color: var(--primary);
}
&.active {
font-weight: bold;
}
&:focus {
outline: 2px solid var(--primary-low);
}
}
.incoming-email-tabs {
margin-bottom: 15px;
}
.incoming-email-content {
height: 300px;
max-width: 100%;
width: 90vw; // forcing textarea wider
textarea,
.incoming-email-html-part {
height: 95%;
border: none;
border-top: 1px solid var(--content-border-color);
padding-top: 10px;
width: 100%;
}
textarea {
font-family: var(--d-font-family--monospace);
resize: none;
border-radius: 0;
box-shadow: none;
}
.incoming-email-html-part {
width: calc(100% - 36px);
padding: 10px 4px 4px 4px;
}
@media screen and (width <= 760px) {
.incoming-email-html-part {
width: calc(100% - 10px);
}
}
}
}
.change-timestamp {
width: 28em; // scales with user font-size
max-width: 90vw; // prevents overflow due to extra large user font-size
#date-container {
.pika-single {
position: relative !important; // overriding another important
display: inline-block;
margin-top: 0.5em;
}
}
.date-picker-wrapper {
min-width: 130px;
margin-right: 0.5em;
}
input[type="time"] {
width: 130px;
}
form {
margin: 0;
}
}
.flag-modal-body {
form {
margin: 0;
}
.flag-action-type .controls .checkbox-label {
margin-bottom: 0.25em;
}
.flag-action-type-details {
width: 100%;
// max-width: 500px;
line-height: var(--line-height-large);
a {
margin: 0;
}
}
.flag-confirmation {
margin-top: 0.5em;
padding-left: 1.125em;
}
}
.flag-message {
margin: 0;
}
.custom-message-length {
color: var(--primary-medium);
font-size: var(--font-down-1);
}
.ignore-duration-with-username-modal {
.future-date-input {
margin-top: 1em;
}
}
.bulk-notification-list {
margin-bottom: 1.5em;
}
.notification-level-radio {
flex-wrap: wrap;
align-items: baseline;
margin-bottom: 0.5em;
.description {
width: 100%;
margin-top: 0.25em;
}
}
.json-editor-btn-delete {
@extend .btn-danger;
@extend .no-text;
}
.json-editor-btn-collapse {
@extend .no-text;
@extend .btn-flat;
@extend .btn-small;
}
.confirm-session {
&__instructions {
margin-bottom: 0.5em;
}
form {
margin: 1.5em 0;
}
&__passkey {
margin-top: 1em;
}
&__fine-print {
font-size: var(--font-down-1);
color: var(--primary-medium);
max-width: 600px;
}
&__reset {
font-size: var(--font-down-1);
color: var(--primary-medium);
}
}
.rename-passkey__message {
max-width: 500px;
margin-bottom: 2em;
}
@include viewport.from(sm) {
.flag-modal-body .flag-message {
height: 3em;
}
.choose-topic-modal {
#choosing-topic {
// prevents content from moving when user selects different move options 525px
width: 525px;
p {
margin-top: 0;
}
.radios {
margin-bottom: 10px;
display: flex;
flex-direction: row;
.radio-label {
display: inline-block;
padding-right: 15px;
}
}
button {
margin-top: 10px;
display: block;
}
form {
width: 95%;
margin-top: 20px;
.participant-selector {
width: 100%;
}
div.ac-wrap {
width: 100%;
margin-bottom: 9px;
}
}
}
}
.create-invite-modal,
.create-invite-bulk-modal,
.share-topic-modal {
.title {
align-items: center;
display: flex;
.subtitle {
margin-left: 0.5em;
}
}
.alert-error {
label {
display: inline-block;
}
}
}
}