-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
305 additions
and
51 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
24 changes: 24 additions & 0 deletions
24
...ts/Calendar/components/DateSelectorComposer/components/SelectorModal/utils/scrollModal.js
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,24 @@ | ||
import { MONTHS } from '../../../../../utils/months'; | ||
|
||
export function scrollModal(selector) { | ||
const { selectorModal } = selector; | ||
|
||
const handleScroll = (event) => { | ||
event.preventDefault(); | ||
const isScrollNext = event.deltaY > 0; | ||
|
||
if (selector.isYear) { | ||
const nextYear = +selector.items[3].innerText; | ||
const prevYear = +selector.items[1].innerText; | ||
const newYear = isScrollNext ? nextYear : prevYear; | ||
selector.changeYear(newYear); | ||
} else { | ||
const nextMonth = MONTHS.indexOf(selector.items[3].innerText); | ||
const prevMonth = MONTHS.indexOf(selector.items[1].innerText); | ||
const newMonth = isScrollNext ? nextMonth : prevMonth; | ||
selector.changeMonth(newMonth); | ||
} | ||
}; | ||
|
||
selectorModal.addEventListener('wheel', handleScroll); | ||
} |
44 changes: 32 additions & 12 deletions
44
src/components/Calendar/components/DateSelectorComposer/components/YearSelector/index.js
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,27 +1,47 @@ | ||
import { Component } from 'pet-dex-utilities'; | ||
import './index.scss'; | ||
import SelectorItem from '../SelectorItem'; | ||
|
||
const events = []; | ||
const events = ['selector:click']; | ||
|
||
const html = ` | ||
<div class="year-selector" data-select="year-selector"></div> | ||
<div class="year-selector" data-select="year-selector"> | ||
<ul class="year-selector__previous-years" data-select="previous-years"></ul> | ||
<span class="year-selector__current-year" data-select="current-year"></span> | ||
<ul class="year-selector__next-years" data-select="next-years"></ul> | ||
</div> | ||
`; | ||
|
||
export default function YearSelector(year) { | ||
export default function YearSelector(yearArray) { | ||
Component.call(this, { html, events }); | ||
|
||
this.year = year; | ||
this.$yearSelector = this.selected.get('year-selector'); | ||
this.setYear(year); | ||
this.yearArray = yearArray; | ||
this.$monthSelector = this.selected.get('year-selector'); | ||
this.$previousYears = this.selected.get('previous-years'); | ||
this.$currentYear = this.selected.get('current-year'); | ||
this.$nextYears = this.selected.get('next-years'); | ||
|
||
for (let i = 0; i < this.yearArray.length; i += 1) { | ||
if (i < 3) { | ||
const selectorItem = new SelectorItem(this.yearArray[i]); | ||
selectorItem.mount(this.$previousYears); | ||
} | ||
if (i === 3) { | ||
this.$currentYear.innerText = this.yearArray[i]; | ||
} | ||
if (i > 3) { | ||
const selectorItem = new SelectorItem(this.yearArray[i]); | ||
selectorItem.mount(this.$nextYears); | ||
} | ||
} | ||
|
||
this.$currentYear.addEventListener('click', () => | ||
this.emit('selector:click'), | ||
); | ||
} | ||
|
||
YearSelector.prototype = Object.assign( | ||
YearSelector.prototype, | ||
Component.prototype, | ||
{ | ||
setYear(year) { | ||
this.year = year; | ||
this.$yearSelector.innerText = this.year; | ||
}, | ||
}, | ||
{}, | ||
); |
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,71 @@ | ||
@use '~styles/base.scss'; | ||
@use '~styles/colors.scss' as colors; | ||
@use '~styles/fonts.scss' as fonts; | ||
@use '~styles/breakpoints.scss' as breakpoints; | ||
|
||
.year-selector { | ||
width: 100%; | ||
|
||
display: flex; | ||
gap: 2.4rem; | ||
|
||
align-items: center; | ||
justify-content: center; | ||
|
||
margin-bottom: 2.4rem; | ||
|
||
padding-bottom: 2.4rem; | ||
|
||
border-bottom: 0.1rem solid colors.$gray150; | ||
|
||
&__previous-years, | ||
&__next-years { | ||
display: flex; | ||
gap: 1.6rem; | ||
|
||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
&__current-year { | ||
align-self: center; | ||
|
||
font-family: fonts.$primaryFont; | ||
color: colors.$primary200; | ||
font-size: fonts.$lg; | ||
font-weight: fonts.$semiBold; | ||
|
||
padding: 0.6rem 1.2rem; | ||
border: 0.1rem solid colors.$blue100; | ||
|
||
background-color: colors.$blue150; | ||
border-radius: 1.4rem; | ||
} | ||
} | ||
|
||
@include breakpoints.from667 { | ||
.year-selector { | ||
width: max-content; | ||
|
||
margin-bottom: 0; | ||
padding-bottom: 0; | ||
border-bottom: 0; | ||
|
||
&__previous-years, | ||
&__next-years { | ||
display: none; | ||
} | ||
|
||
&__current-year { | ||
color: colors.$gray800; | ||
font-weight: fonts.$regular; | ||
|
||
padding: 0; | ||
border: 0; | ||
|
||
background-color: colors.$secondary100; | ||
|
||
cursor: pointer; | ||
} | ||
} | ||
} |
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
Oops, something went wrong.