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

feat: Enhance template picker size and layout depending on aspect ratio #38174

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions apps/files/src/views/TemplatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<NcModal v-if="opened"
:clear-view-delay="-1"
class="templates-picker"
size="normal"
size="large"
@close="close">
<form class="templates-picker__form"
:style="style"
Expand All @@ -47,9 +47,6 @@

<!-- Cancel and submit -->
<div class="templates-picker__buttons">
<button @click="close">
{{ t('files', 'Cancel') }}
</button>
<input type="submit"
class="primary"
:value="t('files', 'Create')"
Expand All @@ -75,7 +72,6 @@ import TemplatePreview from '../components/TemplatePreview.vue'

const border = 2
const margin = 8
const width = margin * 20

export default {
name: 'TemplatePicker',
Expand Down Expand Up @@ -136,6 +132,11 @@ export default {
* @return {object}
*/
style() {
// Fallback to 16:9 landscape ratio
const ratio = this.provider.ratio ? this.provider.ratio : 1.77
// Landscape templates should be wider than tall ones
// We fit 3 templates per row at max for landscape and 4 for portrait
const width = ratio > 1 ? margin * 30 : margin * 20
return {
'--margin': margin + 'px',
'--width': width + 'px',
Expand Down Expand Up @@ -275,7 +276,7 @@ export default {

&__buttons {
display: flex;
justify-content: space-between;
justify-content: end;
padding: calc(var(--margin) * 2) var(--margin);
position: sticky;
bottom: 0;
Expand Down
4 changes: 2 additions & 2 deletions dist/files-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.