-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(RSS-ECOMM-4_38): scroll to top button (#330)
* feat: implement scrollToTop button * fix: binding context * refactor: update confirm component * refactor: update address edit buttons * fix: table heading color
- Loading branch information
1 parent
c1e9264
commit 1b45d94
Showing
14 changed files
with
148 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
position: fixed; | ||
left: 0; | ||
top: 0; | ||
z-index: 1; | ||
z-index: 2; | ||
width: 100%; | ||
height: 100%; | ||
opacity: 1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import ScrollToTopView from '../view/ScrollToTopView.ts'; | ||
|
||
class ScrollToTopModel { | ||
private view: ScrollToTopView; | ||
|
||
constructor() { | ||
this.view = new ScrollToTopView(); | ||
this.init(); | ||
} | ||
|
||
private init(): void { | ||
const buttonElement = this.view.getHTML(); | ||
buttonElement.addEventListener('click', this.scrollToTopHandler.bind(this)); | ||
window.addEventListener('scroll', () => this.view.toggleVisibility()); | ||
this.view.toggleVisibility(); | ||
} | ||
|
||
private scrollToTopHandler(): void { | ||
window.scrollTo(0, 0); | ||
} | ||
|
||
public getHTML(): ScrollToTopView { | ||
return this.view; | ||
} | ||
} | ||
|
||
export default ScrollToTopModel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import ButtonModel from '@/shared/Button/model/ButtonModel.ts'; | ||
import getStore from '@/shared/Store/Store.ts'; | ||
import observeStore, { selectCurrentLanguage } from '@/shared/Store/observer.ts'; | ||
import { SCROLL_TO_TOP_THRESHOLD } from '@/shared/constants/common.ts'; | ||
import SVG_DETAILS from '@/shared/constants/svg.ts'; | ||
import TOOLTIP_TEXT from '@/shared/constants/tooltip.ts'; | ||
import createSVGUse from '@/shared/utils/createSVGUse.ts'; | ||
|
||
import styles from './scrollToTopView.module.scss'; | ||
|
||
class ScrollToTopView { | ||
private button: ButtonModel; | ||
|
||
constructor() { | ||
this.button = this.createButton(); | ||
} | ||
|
||
private createButton(): ButtonModel { | ||
this.button = new ButtonModel({ | ||
classes: [styles.scrollToTopButton], | ||
title: TOOLTIP_TEXT[getStore().getState().currentLanguage].SCROLL_TO_TOP, | ||
}); | ||
|
||
const svg = document.createElementNS(SVG_DETAILS.SVG_URL, 'svg'); | ||
svg.append(createSVGUse(SVG_DETAILS.ARROW_UP)); | ||
this.button.getHTML().append(svg); | ||
|
||
observeStore(selectCurrentLanguage, () => { | ||
this.button.getHTML().title = TOOLTIP_TEXT[getStore().getState().currentLanguage].SCROLL_TO_TOP; | ||
}); | ||
|
||
return this.button; | ||
} | ||
|
||
public getHTML(): HTMLButtonElement { | ||
return this.button.getHTML(); | ||
} | ||
|
||
public toggleVisibility(): void { | ||
this.button.getHTML().classList.toggle(styles.hidden, window.scrollY <= SCROLL_TO_TOP_THRESHOLD); | ||
} | ||
} | ||
|
||
export default ScrollToTopView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* stylelint-disable scss/no-global-function-names */ | ||
@import 'src/app/styles/mixins'; | ||
|
||
$btn-vars: ( | ||
padding: var(--tiny-offset), | ||
bg: var(--steam-green-900), | ||
hover-bg: var(--steam-green-1000), | ||
fill: var(--steam-green-800), | ||
stroke: var(--steam-green-800), | ||
offset: var(--small-offset), | ||
); | ||
|
||
.scrollToTopButton { | ||
@include round-btn( | ||
map-get($btn-vars, padding), | ||
map-get($btn-vars, bg), | ||
map-get($btn-vars, hover-bg), | ||
map-get($btn-vars, fill), | ||
map-get($btn-vars, stroke) | ||
); | ||
|
||
position: fixed; | ||
right: map-get($btn-vars, offset); | ||
bottom: map-get($btn-vars, offset); | ||
z-index: 1; | ||
width: calc(map-get($btn-vars, offset) * 1.5); | ||
height: calc(map-get($btn-vars, offset) * 1.5); | ||
fill: map-get($btn-vars, fill); | ||
stroke: map-get($btn-vars, stroke); | ||
transition: | ||
transform 0.2s, | ||
opacity 0.2s, | ||
visibility 0.2s; | ||
|
||
svg { | ||
width: map-get($btn-vars, offset); | ||
height: map-get($btn-vars, offset); | ||
} | ||
} | ||
|
||
.hidden { | ||
opacity: 0; | ||
visibility: hidden; | ||
transform: scale(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
const SVG_DETAILS = { | ||
ARROW_UP: 'arrowUp', | ||
BILL: 'bill', | ||
BIN: 'bin', | ||
CART: 'cart', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.