Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3899 - Small Screen Responsiveness for Modal - Student #4227

Merged
merged 3 commits into from
Jan 15, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
#3899 - Small Screen Responsiveness for Modal - Student
sh16011993 committed Jan 13, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 035a7f499b08c436532d58ff29ddb887e330e9bc
40 changes: 27 additions & 13 deletions sources/packages/web/src/components/generic/ModalDialogBase.vue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice way to achieve the conditional modal view ❤️
Would the below not achieve the same?
Please disregard the 500 although it produced a nice result during my tests also.

const mediaQuerySmallToLarge = window.matchMedia("(max-width: 500px)");
function handleScreenChangeSmallToLarge(e: MediaQueryList) {
  console.log(e);
  showFullScreen.value = e.matches;
}
mediaQuerySmallToLarge.addEventListener("change", () =>
  handleScreenChangeSmallToLarge(mediaQuerySmallToLarge),
);
handleScreenChangeSmallToLarge(mediaQuerySmallToLarge);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note that (max-width: 500px), (max-height: 300px) can also be used to check with or height. Doing this we may need to add/remove the with="auto" also, so, when the modal expanded is used the with="auto" probably need to be removed. Not a blocker since it may be not part of the ticket.

Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
<template>
<v-dialog
v-model="showHideDialog"
width="auto"
persistent
:no-click-animation="true"
scrollable
:fullscreen="showFullScreen"
>
<!-- TODO remove mx-auto in stable version of vuetify to center modelDialog -->
<v-card
elevation="10"
:max-width="maxWidth"
:min-width="minWidth"
class="modal-height mx-auto"
>
<v-card elevation="10" :max-width="maxWidth" class="modal-height">
<v-card-title>
<slot name="header">
<h2 v-if="title" class="category-header-large primary-color mt-3">
@@ -56,18 +52,36 @@ export default defineComponent({
required: false,
default: 730,
},
minWidth: {
type: Number,
required: false,
default: 730,
},
subTitle: {
type: String,
required: false,
},
},

setup(props, context) {
const showHideDialog = ref(false);
const showFullScreen = ref(true);
const mediaQuerySmallToLarge = window.matchMedia("(min-width: 768px)");
const mediaQueryLargeToSmall = window.matchMedia("(max-width: 767px)");

function handleScreenChangeSmallToLarge(e: MediaQueryList) {
if (e.matches) {
showFullScreen.value = false;
}
}
function handleScreenChangeLargeToSmall(e: MediaQueryList) {
if (e.matches) {
showFullScreen.value = true;
}
}
mediaQuerySmallToLarge.addEventListener("change", () =>
handleScreenChangeSmallToLarge(mediaQuerySmallToLarge),
);
mediaQueryLargeToSmall.addEventListener("change", () =>
handleScreenChangeLargeToSmall(mediaQueryLargeToSmall),
);
handleScreenChangeSmallToLarge(mediaQuerySmallToLarge);

watch(
() => props.showDialog,
(currValue: boolean) => {
@@ -86,7 +100,7 @@ export default defineComponent({
},
);

return { showHideDialog };
return { showHideDialog, showFullScreen };
},
});
</script>