From 0b352ce7fb00b4f26d33639ca27aecc2475d86d0 Mon Sep 17 00:00:00 2001 From: chapoi <101828855+chapoi@users.noreply.github.com> Date: Fri, 24 Nov 2023 11:28:46 +0200 Subject: [PATCH] UX: fix date time modal on mobile (#24531) * UX: fix date time modal --- .../common/modal/modal-overrides.scss | 156 ++++++++++++ app/assets/stylesheets/mobile/_index.scss | 1 + .../stylesheets/mobile/modal-overrides.scss | 20 ++ .../components/modal/local-dates-create.hbs | 2 +- .../common/discourse-local-dates.scss | 236 ------------------ 5 files changed, 178 insertions(+), 237 deletions(-) create mode 100644 app/assets/stylesheets/mobile/modal-overrides.scss diff --git a/app/assets/stylesheets/common/modal/modal-overrides.scss b/app/assets/stylesheets/common/modal/modal-overrides.scss index 227c2cf3be6..38e17f40870 100644 --- a/app/assets/stylesheets/common/modal/modal-overrides.scss +++ b/app/assets/stylesheets/common/modal/modal-overrides.scss @@ -342,3 +342,159 @@ } } } + +.d-modal.discourse-local-dates-create-modal { + .advanced-mode-btn { + margin-left: auto; + } + + .date-time-configuration { + display: flex; + + .fake-input { + display: none; + } + + .timezone-input { + width: 100%; + + .select-kit-header { + .d-icon { + margin-right: 1em; + } + + .caret-icon { + margin-right: 0; + } + } + } + + .date-time-control { + position: relative; + display: flex; + border: 1px solid var(--primary-low); + + &.is-filled, + &.is-selected { + .date-time { + color: var(--primary); + background: var(--secondary); + } + + .d-icon { + color: var(--primary-high); + } + } + + &.from { + border-radius: 5px 5px 0 0; + + .date-time { + border-radius: 5px 5px 0 0; + } + + &.is-selected { + border-color: var(--tertiary); + } + } + + &.to { + border-radius: 0 0 5px 5px; + margin-bottom: 1em; + + .date-time { + border-radius: 0 0 5px 5px; + padding-right: 3em; + } + + &.is-selected { + border-color: var(--tertiary); + } + } + + .date-time { + color: var(--primary-medium); + background: var(--primary-very-low); + padding: 1em 0.5em 1em 2em; + border: 0; + outline: none; + flex: 1; + @include ellipsis; + width: 100%; + justify-content: flex-start; + &:focus { + background-color: var(--tertiary-50); + } + } + + .d-icon { + position: absolute; + margin-top: auto; + margin-bottom: auto; + left: 0.5em; + top: 0; + bottom: 0; + color: var(--primary-medium); + } + + .delete-to-date { + position: absolute; + margin-top: auto; + margin-bottom: auto; + right: 0; + width: 30px; + top: 0; + bottom: 0; + color: var(--primary-high); + border-radius: 0 0 5px 0; + } + } + + .inputs-panel { + flex: 1; + } + } + + .preview { + text-align: center; + margin-bottom: 0.5em; + padding: 0.5em; + + b { + margin-right: 0.5em; + margin-left: 0.5em; + } + + b + p { + margin: 0; + display: inline-block; + } + } + + .validation-error { + margin-bottom: 0.5em; + } + + .format { + .format-input { + width: 280px; + } + } + + .formats { + list-style: none; + padding: 0; + margin: 0; + .format { + .previewed-format { + color: var(--primary-medium); + } + } + } + + .control-group.recurrence, + .control-group.format, + .control-group.timezones { + margin-top: 1em; + } +} diff --git a/app/assets/stylesheets/mobile/_index.scss b/app/assets/stylesheets/mobile/_index.scss index 6f251403a0a..5271c220047 100644 --- a/app/assets/stylesheets/mobile/_index.scss +++ b/app/assets/stylesheets/mobile/_index.scss @@ -20,6 +20,7 @@ @import "menu-panel"; @import "login-modal"; @import "modal"; +@import "modal-overrides"; @import "new-user"; @import "onebox"; @import "personal-message"; diff --git a/app/assets/stylesheets/mobile/modal-overrides.scss b/app/assets/stylesheets/mobile/modal-overrides.scss new file mode 100644 index 00000000000..bbef4f95640 --- /dev/null +++ b/app/assets/stylesheets/mobile/modal-overrides.scss @@ -0,0 +1,20 @@ +.d-modal.discourse-local-dates-create-modal { + .date-time-configuration { + flex-direction: column; + gap: 0.5em; + } + .calendar-date-time-input { + width: 100%; + margin: 0 0 1rem 0; + } + + .picker-panel { + //mysteriously needed to prevent it from overlapping the timezone-input + position: relative; + z-index: 0; + } + + .pika-single { + justify-content: center; + } +} diff --git a/plugins/discourse-local-dates/assets/javascripts/discourse/components/modal/local-dates-create.hbs b/plugins/discourse-local-dates/assets/javascripts/discourse/components/modal/local-dates-create.hbs index 1175375e5e9..dd917a0322d 100644 --- a/plugins/discourse-local-dates/assets/javascripts/discourse/components/modal/local-dates-create.hbs +++ b/plugins/discourse-local-dates/assets/javascripts/discourse/components/modal/local-dates-create.hbs @@ -1,7 +1,7 @@ <:body>
diff --git a/plugins/discourse-local-dates/assets/stylesheets/common/discourse-local-dates.scss b/plugins/discourse-local-dates/assets/stylesheets/common/discourse-local-dates.scss index 459d530a61f..7209c1abdd3 100644 --- a/plugins/discourse-local-dates/assets/stylesheets/common/discourse-local-dates.scss +++ b/plugins/discourse-local-dates/assets/stylesheets/common/discourse-local-dates.scss @@ -47,239 +47,3 @@ cursor: pointer; margin-top: 0.5em; } - -.discourse-local-dates-create-modal .modal-footer { - display: flex; - align-items: center; - justify-content: flex-start; - - &:before, - &:after { - content: none; - } - - .advanced-mode-btn { - margin-left: auto; - } -} - -.discourse-local-dates-create-modal { - box-sizing: border-box; - min-height: 320px; - display: flex; - flex-direction: row; - padding: 0.5em; - overflow: auto; - - .form { - flex: 1 0 0px; - - label { - font-weight: 700; - } - - .date-time-configuration { - display: flex; - - .fake-input { - display: none; - } - - .timezone-input { - width: 100%; - - &.is-expanded { - .select-kit-header { - border: 1px solid var(--primary-medium); - } - } - - .select-kit-header { - padding: 0.5em 0.5em; - border: 1px solid var(--primary-low); - - .d-icon { - margin-right: 1em; - } - - .caret-icon { - margin-right: 0; - } - } - } - - .date-time-control { - position: relative; - display: flex; - border: 1px solid var(--primary-low); - - &.is-filled, - &.is-selected { - .date-time { - color: var(--primary); - background: var(--secondary); - } - - .d-icon { - color: var(--primary-high); - } - } - - &.from { - border-radius: 5px 5px 0 0; - - .date-time { - border-radius: 5px 5px 0 0; - } - - &.is-selected { - border-color: var(--tertiary); - } - } - - &.to { - border-radius: 0 0 5px 5px; - margin-bottom: 1em; - - .date-time { - border-radius: 0 0 5px 5px; - padding-right: 3em; - } - - &.is-selected { - border-color: var(--tertiary); - } - } - - .date-time { - color: var(--primary-medium); - background: var(--primary-very-low); - padding: 1em 0.5em 1em 2em; - border: 0; - outline: none; - flex: 1; - @include ellipsis; - width: 100%; - justify-content: flex-start; - &:focus { - background-color: var(--tertiary-50); - } - } - - .d-icon { - position: absolute; - margin-top: auto; - margin-bottom: auto; - left: 0.5em; - top: 0; - bottom: 0; - color: var(--primary-medium); - } - - .delete-to-date { - position: absolute; - margin-top: auto; - margin-bottom: auto; - right: 0; - width: 30px; - top: 0; - bottom: 0; - color: var(--primary-high); - border-radius: 0 0 5px 0; - } - } - - .inputs-panel { - flex: 1; - } - } - - .preview { - text-align: center; - margin-top: 0; - margin-bottom: 0.5em; - display: flex; - align-items: center; - padding: 0.5em; - flex-wrap: wrap; - - b { - margin-right: 0.5em; - margin-left: 0.5em; - } - - b + p { - margin: 0; - display: inline-block; - } - } - - .recurrence { - .recurrence-input { - width: 350px; - } - } - } - - .validation-error { - margin-bottom: 0.5em; - } - - .format { - .format-input { - width: 280px; - } - } - - .formats { - list-style: none; - padding: 0; - margin: 0; - .format { - .previewed-format { - color: var(--primary-medium); - } - } - } - - .control-group.recurrence, - .control-group.format, - .control-group.timezones { - margin-top: 1em; - } - - .timezones-input { - width: 350px; - } -} - -html:not(.mobile-view) { - .discourse-local-dates-create-modal .modal-body { - width: 40em; // using ems to scale with user font size - max-width: 100vw; // avoids overflow if someone has extreme font-sizes impacting width - max-height: 400px !important; - } -} - -html.mobile-view { - .discourse-local-dates-create-modal .modal-body { - max-height: 400px !important; - - .date-time-configuration { - flex-direction: column; - } - - .calendar-date-time-input { - width: 100%; - margin: 0 0 1em 0; - - .pika-single { - justify-content: center; - } - - .time-picker { - padding-top: 6px; - } - } - } -}