Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Fix global layout issues #849

Merged
merged 5 commits into from
Feb 14, 2022
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
9 changes: 6 additions & 3 deletions src/components/VContentSwitcher/VContentSwitcherButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
@click="$emit('click')"
>
<VIcon :icon-path="icon" />
<span v-show="showLabel" :class="{ 'ms-2 md:w-20 text-left': showLabel }">{{
buttonLabel
}}</span>
<span
v-show="showLabel"
class="hidden xs:block"
:class="{ 'ms-2 md:w-20 text-left': showLabel }"
>{{ buttonLabel }}</span
>
<VIcon
class="hidden md:block text-dark-charcoal-40 md:ms-2"
:icon-path="caretDownIcon"
Expand Down
30 changes: 8 additions & 22 deletions src/components/VHeader/VHeader.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<template>
<header
class="flex px-4 md:px-7 items-stretch z-40 w-full bg-white gap-x-2 gap-y-4 flex-wrap md:flex-nowrap"
class="flex px-4 md:px-7 items-center md:items-stretch z-40 w-screen bg-white gap-x-2 gap-y-4"
:class="{
'py-3': isHeaderScrolled,
'py-4': !isHeaderScrolled,
'py-3 ': isHeaderScrolled,
'py-4 flex-wrap md:flex-nowrap': !isHeaderScrolled,
'border-b border-white': !isHeaderScrolled && !isMenuOpen,
'border-b border-dark-charcoal-20':
isSearchRoute && (isHeaderScrolled || isMenuOpen),
Expand All @@ -20,7 +20,7 @@

<VSearchBar
v-model.trim="searchTerm"
class="md:w-full lg:w-1/2 2xl:w-1/3"
class="flex-grow lg:flex-grow-0 lg:w-1/2 2xl:w-1/3"
:size="isMinScreenMd ? 'medium' : isHeaderScrolled ? 'small' : 'large'"
:class="{
'order-4 md:order-none w-full md:w-auto': !isHeaderScrolled,
Expand All @@ -30,7 +30,7 @@
>
<span
v-show="searchStatus"
class="info font-semibold text-xs text-dark-charcoal-70 group-hover:text-dark-charcoal group-focus:text-dark-charcoal mx-4"
class="hidden lg:block info font-semibold text-xs text-dark-charcoal-70 group-hover:text-dark-charcoal group-focus:text-dark-charcoal mx-4"
>
{{ searchStatus }}
</span>
Expand Down Expand Up @@ -144,16 +144,11 @@ const VHeader = defineComponent({
const resultsCount = computed(() => store.getters['media/resultCount'])
const { getI18nCount } = useI18nResultsCount()
/**
* Status is hidden below the medium breakpoint.
* It shows Loading... or Number of results on bigger screens.
* Additional text at the end of the search bar.
* Shows the loading state or result count.
*/
const searchStatus = computed(() => {
if (
!isMinScreenMd.value ||
!isSearchRoute.value ||
store.state.search.query.q === ''
)
return ''
if (!isSearchRoute.value || store.state.search.query.q === '') return ''
if (isFetching.value) return i18n.t('header.loading')
return getI18nCount(resultsCount.value)
})
Expand Down Expand Up @@ -237,12 +232,3 @@ const VHeader = defineComponent({

export default VHeader
</script>
<style scoped>
@media (max-width: 767px) {
.search-bar-mobile-scrolled {
/* outer padding, inner gaps, (logo, content switcher and filter button), additional content switcher padding */
/* width: calc(100vw - 2rem - 1.5rem - 3 * 2.5rem - 0.25rem); */
width: calc(100vw - 11.25rem);
}
}
</style>
4 changes: 2 additions & 2 deletions src/components/VHeader/VLogoButton.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<VButton
as="NuxtLink"
to="/"
:to="localePath('/')"
Copy link
Contributor

Choose a reason for hiding this comment

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

Great catch!

variant="plain"
size="disabled"
class="max-w-min hover:bg-yellow text-dark-charcoal"
Expand All @@ -12,7 +12,7 @@
/>
<OpenverseLogoText
v-if="!isHeaderScrolled"
class="-ml-1 mt-1 me-3"
class="hidden xs:block -ml-1 mt-1 me-3"
:class="{ 'md:hidden': isSearchRoute }"
width="95"
height="15"
Expand Down
1 change: 1 addition & 0 deletions src/constants/screens.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const SCREEN_SIZES = new Map([
['lg', 1024],
['md', 768],
['sm', 640],
['xs', 340],
])

const VIEWPORTS = Object.fromEntries(
Expand Down
45 changes: 27 additions & 18 deletions src/layouts/default.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<template>
<div class="app grid h-screen overflow-hidden relative">
<VTeleportTarget name="skip-to-content" />
<MigrationNotice v-show="isReferredFromCc" />
<VTranslationStatusBanner />
<VHeader />
<div>
<VTeleportTarget name="skip-to-content" />
<MigrationNotice v-show="isReferredFromCc" />
<VTranslationStatusBanner />
<VHeader />
</div>
<main
class="main embedded overflow-x-hidden"
:class="{ 'has-sidebar': isSidebarVisible }"
Expand Down Expand Up @@ -108,23 +110,30 @@ export default embeddedPage
grid-template-rows: auto 1fr;
}

@screen md {
// Logic for displaying the filter sidebar and search results
// as independently-scrolling sections.
.main {
Comment on lines +114 to +116
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for documenting the grid logic!

height: 100%;
display: grid;
grid-template-columns: 1fr 316px;
}
// Make the main content area span both grid columns
// when the sidebar is closed...
.main > *:first-child {
grid-column: span 2;
}
// ...and only one column when it is visible.
.main.has-sidebar > *:first-child {
grid-column: 1;
}
}

.main {
display: grid;
grid-template-columns: 1fr 316px;
height: 100%;
overflow: hidden;
}

.main > * {
.main > *:not(:empty) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Adding :not(:empty) is such a great solution to all the teleports taking up grid areas when empty!

overflow-y: scroll;
min-height: 100%;
}

.main > *:first-child {
grid-column: span 2;
}

.main.has-sidebar > *:first-child {
grid-column: 1;
height: 100%;
}
</style>
2 changes: 0 additions & 2 deletions src/styles/base/generic.sass
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import "../utilities/mixins"

$body-background-color: $scheme-main
$body-min-width: 300px
$body-rendering: optimizeLegibility
$body-family: $family-primary

Expand Down Expand Up @@ -32,7 +31,6 @@ html
background-color: $body-background-color
-moz-osx-font-smoothing: grayscale
-webkit-font-smoothing: antialiased
min-width: $body-min-width
text-rendering: $body-rendering
text-size-adjust: 100%

Expand Down