Skip to content

Commit

Permalink
fix: keyboard shortcut modal not being responsive
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Steinmetz <richard@steinmetz.cloud>
  • Loading branch information
st3iny committed Feb 17, 2025
1 parent 4775e46 commit 1f93c1a
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 77 deletions.
45 changes: 0 additions & 45 deletions css/app-settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,51 +57,6 @@
}
}

.shortcut-overview-modal {
.modal-container {
display: flex !important;
flex-wrap: wrap;
padding: 0 12px 12px 12px !important;

* {
box-sizing: border-box;
}

.shortcut-section {
width: 50%;
flex-grow: 0;
flex-shrink: 0;
padding: 10px;

.shortcut-section-item {
width: 100%;
display: grid;
grid-template-columns: 33% 67%;
column-gap: 10px;

&:not(:first-child) {
margin-top: 10px;
}

&__keys {
display: block;
text-align: right;
}

&__label {
display: block;
text-align: left;
padding-top: 5px;
}

&__spacer {
margin: 0 3px;
}
}
}
}
}

// Fix the shortcut overview on smaller screens
@media screen and (max-width: 800px) {
.shortcut-overview-modal .modal-container .shortcut-section {
Expand Down
116 changes: 84 additions & 32 deletions src/components/AppNavigation/Settings/ShortcutOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,52 @@
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<Modal class="shortcut-overview-modal"
size="large"
<NcDialog size="large"
dialogClasses="foobar"

Check warning on line 7 in src/components/AppNavigation/Settings/ShortcutOverview.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute 'dialogClasses' must be hyphenated
:name="$t('calendar', 'Shortcut overview')"
@close="$emit('close')">
<section v-for="category in shortcuts"
:key="category.categoryId"
class="shortcut-section">
<h3 class="shortcut-section__header">
{{ category.categoryLabel }}
</h3>
<div v-for="(shortcut, index) in category.shortcuts"
:key="`${category.categoryId}-${index}`"
class="shortcut-section-item">
<span class="shortcut-section-item__keys">
<template v-for="(keyCombination, index2) of shortcut.keys">
<template v-for="(key, index3) in keyCombination">
<kbd :key="`${category.categoryId}-${index}-${index2}-${index3}`">{{ key }}</kbd>
<span v-if="index3 !== (keyCombination.length - 1)"
:key="`${category.categoryId}-${index}-${index2}-${index3}`"
:closeOnClickOutside="true"

Check warning on line 9 in src/components/AppNavigation/Settings/ShortcutOverview.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute ':closeOnClickOutside' must be hyphenated
@update:open="onUpdateOpen">
<div class="shortcut-overview-modal">
<section v-for="category in shortcuts"
:key="category.categoryId"
class="shortcut-section">
<h3 class="shortcut-section__header">
{{ category.categoryLabel }}
</h3>
<div v-for="(shortcut, index) in category.shortcuts"
:key="`${category.categoryId}-${index}`"
class="shortcut-section-item">
<span class="shortcut-section-item__keys">
<template v-for="(keyCombination, index2) of shortcut.keys">
<template v-for="(key, index3) in keyCombination">
<kbd :key="`${category.categoryId}-${index}-${index2}-${index3}`">{{ key }}</kbd>
<span v-if="index3 !== (keyCombination.length - 1)"
:key="`${category.categoryId}-${index}-${index2}-${index3}`"
class="shortcut-section-item__spacer">
+
</span>
</template>
<span v-if="index2 !== (shortcut.keys.length - 1)"
:key="`${category.categoryId}-${index}-${index2}`"
class="shortcut-section-item__spacer">
+
{{ $t('calendar', 'or') }}
</span>
</template>
<span v-if="index2 !== (shortcut.keys.length - 1)"
:key="`${category.categoryId}-${index}-${index2}`"
class="shortcut-section-item__spacer">
{{ $t('calendar', 'or') }}
</span>
</template>
</span>
<span class="shortcut-section-item__label">{{ shortcut.label }}</span>
</div>
</section>
</Modal>
</span>
<span class="shortcut-section-item__label">{{ shortcut.label }}</span>
</div>
</section>
</div>
</NcDialog>
</template>

<script>
import { translate as t } from '@nextcloud/l10n'
import { NcModal as Modal } from '@nextcloud/vue'
import { NcDialog } from '@nextcloud/vue'

export default {
components: {
Modal,
NcDialog,
},
computed: {
shortcuts() {
Expand Down Expand Up @@ -110,5 +113,54 @@ export default {
}]
},
},
methods: {
onUpdateOpen(open) {
if (!open) {
this.$emit('close')
}
}

Check warning on line 121 in src/components/AppNavigation/Settings/ShortcutOverview.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Missing trailing comma
},
}
</script>

<style lang="scss" scoped>
.shortcut-overview-modal {
display: flex;
flex-wrap: wrap;

.shortcut-section {
width: 50%;
min-width: 425px;
flex-grow: 0;
flex-shrink: 0;
padding: 10px;
box-sizing: border-box;

.shortcut-section-item {
width: 100%;
display: grid;
grid-template-columns: 33% 67%;
column-gap: 10px;

&:not(:first-child) {
margin-top: 10px;
}

&__keys {
display: block;
text-align: right;
}

&__label {
display: block;
text-align: left;
padding-top: 5px;
}

&__spacer {
margin: 0 3px;
}
}
}
}
</style>

0 comments on commit 1f93c1a

Please sign in to comment.