Skip to content

Commit

Permalink
Add max width to PageBody
Browse files Browse the repository at this point in the history
Closes #447.
  • Loading branch information
matthew-white committed Apr 10, 2023
1 parent 48d8c5f commit 97378f4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 16 deletions.
1 change: 1 addition & 0 deletions src/assets/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ $padding-modal-body: 15px;

// PageBody
$margin-top-page-body: 20px;
$max-width-page-body: 1280px;

// Popover
$box-shadow-popover: 0 5px 10px rgba(0, 0, 0, 0.2);
7 changes: 6 additions & 1 deletion src/assets/scss/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ https://www.apache.org/licenses/LICENSE-2.0. No part of ODK Central,
including this file, may be copied, modified, propagated, or distributed
except according to the terms contained in the LICENSE file.
*/

@use 'sass:math';
@import './mixins';

html {
Expand Down Expand Up @@ -680,7 +680,12 @@ becomes more complicated.

.panel-main {
box-shadow: $box-shadow-panel-main;
margin-left: auto;
margin-right: auto;
margin-top: 70px;
// A .panel-main element is a child of a .col-sm-6 element. .col-sm-6 has
// left + right padding of 30px.
max-width: #{math.div($max-width-page-body, 2) - 30px};

.panel-body {
padding-bottom: 25px;
Expand Down
3 changes: 2 additions & 1 deletion src/components/form-attachment/popups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export default {
</script>

<style lang="scss">
@use 'sass:math';
@import '../../assets/scss/variables';
$z-index-backdrop: 1;
Expand All @@ -176,7 +177,7 @@ $popup-width: 300px;
#form-attachment-popups-main {
bottom: $edge-offset;
position: fixed;
right: $edge-offset;
right: calc($edge-offset + max(50% - #{math.div($max-width-page-body, 2)}, 0));
width: $popup-width;
z-index: $z-index-main;
Expand Down
15 changes: 9 additions & 6 deletions src/components/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ except according to the terms contained in the LICENSE file.
<div>
<div id="home-heading">{{ $t('heading[0]') }}</div>
<home-summary/>
<div id="home-news-container">
<home-news/>
<home-config-section v-if="config.home.title != null"
:title="config.home.title" :body="config.home.body"/>
</div>
<project-list/>
<page-body>
<div id="home-news-container">
<home-news/>
<home-config-section v-if="config.home.title != null"
:title="config.home.title" :body="config.home.body"/>
</div>
<project-list/>
</page-body>
</div>
</template>

Expand All @@ -32,6 +34,7 @@ import { defineAsyncComponent, inject } from 'vue';
import HomeNews from './home/news.vue';
import HomeSummary from './home/summary.vue';
import PageBody from './page/body.vue';
import ProjectList from './project/list.vue';
import useProjects from '../request-data/projects';
Expand Down
15 changes: 14 additions & 1 deletion src/components/page/body.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ including this file, may be copied, modified, propagated, or distributed
except according to the terms contained in the LICENSE file.
-->
<template>
<div id="page-body" class="row">
<div id="page-body" :class="htmlClass">
<div class="col-xs-12">
<slot></slot>
</div>
Expand All @@ -22,11 +22,24 @@ export default {
name: 'PageBody'
};
</script>
<script setup>
import { computed, inject } from 'vue';
const { router } = inject('container');
const htmlClass = computed(() => ({
row: true,
// `router` may be `null` in testing.
'full-width': router != null && router.currentRoute.value.meta.fullWidth
}));
</script>

<style lang="scss">
@import '../../assets/scss/variables';
#page-body {
margin-top: $margin-top-page-body;
max-width: $max-width-page-body;
&.full-width { max-width: none; }
}
</style>
22 changes: 15 additions & 7 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ const routes = [
'assignment.delete'
])
},
title: () => [i18n.t('projectShow.tab.formAccess'), project.name]
title: () => [i18n.t('projectShow.tab.formAccess'), project.name],
fullWidth: true
}
}),
asyncRoute({
Expand Down Expand Up @@ -362,7 +363,8 @@ const routes = [
project: () => project.permits(['form.read', 'form.update', 'dataset.list']),
form: () => form.publishedAt != null
},
title: () => [form.nameOrId]
title: () => [form.nameOrId],
fullWidth: true
}
}),
asyncRoute({
Expand Down Expand Up @@ -393,7 +395,8 @@ const routes = [
]),
form: () => form.publishedAt != null
},
title: () => [i18n.t('resource.submissions'), form.nameOrId]
title: () => [i18n.t('resource.submissions'), form.nameOrId],
fullWidth: true
}
}),
asyncRoute({
Expand Down Expand Up @@ -484,7 +487,8 @@ const routes = [
title: () => [
i18n.t('formHead.draftNav.tab.testing'),
form.nameOrId
]
],
fullWidth: true
}
})
]
Expand Down Expand Up @@ -529,7 +533,8 @@ const routes = [
title: () => [i18n.t('common.data'), dataset.name],
validateData: {
project: () => project.permits(['dataset.read', 'entity.list'])
}
},
fullWidth: true
}
})
]
Expand Down Expand Up @@ -595,7 +600,8 @@ const routes = [
validateData: {
currentUser: () => currentUser.can('audit.read')
},
title: () => [i18n.t('systemHome.tab.audits'), i18n.t('systemHome.title')]
title: () => [i18n.t('systemHome.tab.audits'), i18n.t('systemHome.title')],
fullWidth: true
}
}),
asyncRoute({
Expand All @@ -613,7 +619,8 @@ const routes = [
title: () => [
i18n.t('systemHome.tab.analytics'),
i18n.t('systemHome.title')
]
],
fullWidth: true
},
beforeEnter: () => (config.showsAnalytics ? true : '/')
})
Expand Down Expand Up @@ -655,6 +662,7 @@ const routesByName = new Map();
requireLogin: true,
requireAnonymity: false,
preserveData: [],
fullWidth: false,
...meta,
validateData: meta == null || meta.validateData == null
? []
Expand Down

0 comments on commit 97378f4

Please sign in to comment.