-
Notifications
You must be signed in to change notification settings - Fork 6
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: collapse desktop header in scrolling #288
feat: collapse desktop header in scrolling #288
Conversation
PR #288 preview deployed in https://x.test.empathy.co/preview/288/index.html |
src/components/desktop/desktop.vue
Outdated
@@ -90,7 +100,9 @@ | |||
NoResultsMessage: () => import('../search').then(m => m.NoResultsMessage), | |||
SelectedFilters: () => import('../search').then(m => m.SelectedFilters), | |||
SpellcheckMessage: () => import('../search').then(m => m.SpellcheckMessage) | |||
} | |||
}, | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove blank space
|
||
<script lang="ts"> | ||
import { defineComponent } from 'vue'; | ||
//import RelatedTagsFloatedPredictive from './related-tags-floated-predictive.vue'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment
export default defineComponent({ | ||
components: { | ||
DesktopToolbar, | ||
//RelatedTagsFloatedPredictive, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this a wrapper Vue component (not like the the animations components we have in X, but one that applies the classes with a prop)
> | ||
<div class="x-layout__sub-header-content"> | ||
<DesktopSearchboxAlign class="x-layout-container"> | ||
<RelatedTagsFullPredictive /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This way if we have to change the type of predictive we use we'll have to change it in two places, change the components structure so it's only one place (maybe with a prop to make things easier, something like this flowchart)
PR #288 preview deployed in https://x.test.empathy.co/preview/288/index.html |
PR #288 preview deployed in https://x.test.empathy.co/preview/288/index.html |
PR #288 preview deployed in https://x.test.empathy.co/preview/288/index.html |
PR #288 preview deployed in https://x.test.empathy.co/preview/288/index.html |
PR #288 preview deployed in https://x.test.empathy.co/preview/288/index.html |
@@ -0,0 +1,44 @@ | |||
<template> | |||
<div | |||
class="x-collapse" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collapse
is too generic, change to collapse-height
}, | ||
mixins: [IsScrollingUp], | ||
props: { | ||
hasScrolled: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This prop is not being used
<div> | ||
<DesktopHeaderFullPredictive /> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wrapping is not needed
<div> | |
<DesktopHeaderFullPredictive /> | |
</div> | |
<DesktopHeaderFullPredictive /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to collapse-height-animation
<CollapseHeigthAnimation | ||
class="x-layout-max-width-md desktop:x-layout-min-margin-32 large:x-layout-max-width-lg large:x-layout-min-margin-48" | ||
:isExtended="hasScrolled" | ||
> | ||
<div class="x-layout__sub-header-content"> | ||
<DesktopSearchboxAlign> | ||
<div class="x-layout-item" :class="{ 'x-grid x-grid-cols-6': !isFullPredictive }"> | ||
<LocationProvider location="predictive_layer"> | ||
<RelatedTags v-if="$x.relatedTags.length > 0" class="x-pb-24" /> | ||
</LocationProvider> | ||
</div> | ||
</DesktopSearchboxAlign> | ||
|
||
<div v-if="!$x.redirections.length && hasSearched"> | ||
<DesktopToolbar /> | ||
</div> | ||
<div v-if="$x.totalResults > 0 && hasSearched && $x.selectedFilters.length"> | ||
<SelectedFilters class="x-py-16" /> | ||
</div> | ||
</div> | ||
</CollapseHeigthAnimation> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the MaxDesktopWidthItem
component instead of the CSS classes.
Also x-layout__sub-header-content
is not needed anymore.
<CollapseHeigthAnimation | |
class="x-layout-max-width-md desktop:x-layout-min-margin-32 large:x-layout-max-width-lg large:x-layout-min-margin-48" | |
:isExtended="hasScrolled" | |
> | |
<div class="x-layout__sub-header-content"> | |
<DesktopSearchboxAlign> | |
<div class="x-layout-item" :class="{ 'x-grid x-grid-cols-6': !isFullPredictive }"> | |
<LocationProvider location="predictive_layer"> | |
<RelatedTags v-if="$x.relatedTags.length > 0" class="x-pb-24" /> | |
</LocationProvider> | |
</div> | |
</DesktopSearchboxAlign> | |
<div v-if="!$x.redirections.length && hasSearched"> | |
<DesktopToolbar /> | |
</div> | |
<div v-if="$x.totalResults > 0 && hasSearched && $x.selectedFilters.length"> | |
<SelectedFilters class="x-py-16" /> | |
</div> | |
</div> | |
</CollapseHeigthAnimation> | |
<CollapseHeigthAnimation :isExtended="hasScrolled"> | |
<MaxDesktopWidthItem> | |
<DesktopSearchboxAlign> | |
<div class="x-layout-item" :class="{ 'x-grid x-grid-cols-6': !isFullPredictive }"> | |
<LocationProvider location="predictive_layer"> | |
<RelatedTags v-if="$x.relatedTags.length > 0" class="x-pb-24" /> | |
</LocationProvider> | |
</div> | |
</DesktopSearchboxAlign> | |
<div v-if="!$x.redirections.length && hasSearched"> | |
<DesktopToolbar /> | |
</div> | |
<div v-if="$x.totalResults > 0 && hasSearched && $x.selectedFilters.length"> | |
<SelectedFilters class="x-py-16" /> | |
</div> | |
</MaxDesktopWidthItem> | |
</CollapseHeigthAnimation> |
@XOn('UserChangedScrollDirection') | ||
scrollDirectionChanged(direction: ScrollDirection): void { | ||
this.stopsScrollDown = direction === 'UP'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will listen to any scroll direction change managed by the scroll module. We should be concerned only by changes on the main scroll. Change the implementation to using the state of the main scroll only.
@XOn('UserChangedScrollDirection') | |
scrollDirectionChanged(direction: ScrollDirection): void { | |
this.stopsScrollDown = direction === 'UP'; | |
} | |
@State('scroll', 'data') | |
public scrollPositionsMap!: Dictionary<ScrollComponentState>; | |
protected get mainScrollPosition(): number { | |
return this.scrollPositionsMap['main-scroll']?.position; | |
} |
if (this.stopsScrollDown || position < this.scrollOffset) { | ||
this.isScrollingUp = true; | ||
} else if (!this.stopsScrollDown && position > this.scrollOffset) { | ||
this.isScrollingUp = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the main scroll state and apply the changes to the property of isScrollingUp
.
if (this.stopsScrollDown || position < this.scrollOffset) { | |
this.isScrollingUp = true; | |
} else if (!this.stopsScrollDown && position > this.scrollOffset) { | |
this.isScrollingUp = false; | |
} | |
const isScrollingUp = this.scrollPositionsMap['main-scroll']?.direction === 'UP'; | |
if (isScrollingUp || this.mainScrollPosition < this.scrollOffset) { | |
this. hasScrolledPastThreshold = false; | |
} else if (!isScrollingUp && this.mainScrollPosition > this.scrollOffset) { | |
this. hasScrolledPastThreshold = true; | |
}``` |
@XOn(['UserScrolled']) | ||
scrollLength(position: number): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert to watcher and rename function
@XOn(['UserScrolled']) | |
scrollLength(position: number): void { | |
@Watch('mainScrollPosition', { deep: true }) | |
updateHasScrolledPastThreshold(): void { |
protected get hasScrolled(): boolean { | ||
return this.isScrollingUp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update naming
protected get hasScrolled(): boolean { | |
return this.isScrollingUp; | |
protected get hasScrolled(): boolean { | |
return this.hasScrolledPastThreshold; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename mixing name to something like has-scroll-past-threshold
PR #288 preview deployed in https://x.test.empathy.co/preview/288/index.html |
PR #288 preview deployed in https://x.test.empathy.co/preview/288/index.html |
PR #288 preview deployed in https://x.test.empathy.co/preview/288/index.html |
EMP-1003
Motivation and context
Provide the user a better visualization with more space for the results.
We have created a new component (
desktop-sub-header
) where we add all the elements that we want to be hidden (related-tags
,desktop-toolbar
andselected-filters
). We have also created the animation that we separated into 2 files,collapse-heigth-animation.scss
andis-scrolling-up.mixin.ts
.Type of change
What is the destination branch of this PR?
Main
How has this been tested?
When you scroll over the result list, the related tags, toolbar and selected filters should hide.
Replace
DesktopHeaderFullPredictive
withDesktopHeaderFloatingPredictive
indesktop
andRelatedTagsFullPredictive
withRelatedTagsFloatedPredictive
indesktop-sub-header
if you want to test this feature with the floating empathize.