-
Couldn't load subscription status.
- Fork 43
Issue 27 - Componente de Calendário #302
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
Open
DominMFD
wants to merge
36
commits into
devhatt:main
Choose a base branch
from
DominMFD:issue#27
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 25 commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
04b094b
chore: update branch
gustavogularte 652302e
chore: update branch
gustavogularte 9f2bc3a
chore: update branch
DominMFD 44e4b10
chore: colors adjusted
DominMFD 0a8adab
chore: index.scss adjusted
DominMFD 301414d
chore: update main
DominMFD 4cb88f1
fix: add color gray250
DominMFD f5816d2
chore: add lodash
DominMFD 7116331
refactor: init calendar refactor
DominMFD 8dd27fc
feat: calendar content done
DominMFD 0ea029d
feat: implements month selector
DominMFD d850b24
feat: implements date modal
DominMFD 1fc7b5f
chore: implements year selector
DominMFD 05c07d5
chore: remove sliding
DominMFD 67ceede
feat: add hover in date selector
DominMFD 6fb4f94
chore: init virtual scroll
DominMFD 74828a6
chore: complete virtual scroll
DominMFD 5bc0720
fix: month selector array
DominMFD 7835018
chore: trying make central scroll
DominMFD 8f267aa
fix: align active item in center
DominMFD 217d0aa
chore: implements scroll snap
DominMFD 19b2854
chore: year selector scroll
DominMFD a4c87dc
chore: implements scroll selectors
DominMFD 03c18a8
fix: scroll fixes
DominMFD 7369e00
fix: rerender fix
DominMFD 0c79f10
fix: adjust modal height
DominMFD a7a3098
fix: week days abbreviation fix
DominMFD 3bf7c70
fix: media query day composer fixed
DominMFD f149258
fix: bug mobile selector fixed
DominMFD 8e68afe
fix: object properties
DominMFD 3759f75
fix: add bem
DominMFD eaaba8a
fix: array fixed
DominMFD 924b63d
fix: css
DominMFD f64c702
feat: actual day implemented
DominMFD 621a929
fix: organize setters and getters
DominMFD 54abad3
Merge branch 'main' into issue#27
DominMFD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,36 +1,36 @@ | ||
| @use '~styles/colors.scss' as colors; | ||
|
|
||
| .button { | ||
| font-family: 'Noto Sans', sans-serif; | ||
| color: rgb(255, 255, 255); | ||
| font-size: 1.6rem; | ||
| font-weight: 500; | ||
|
|
||
| padding: 1.6rem; | ||
| border: unset; | ||
|
|
||
| background-color: colors.$primary200; | ||
| border-radius: 1.4rem; | ||
|
|
||
| transition: 0.3s ease-in-out; | ||
|
|
||
| cursor: pointer; | ||
| appearance: none; | ||
|
|
||
| &--block { | ||
| width: 100%; | ||
|
|
||
| display: block; | ||
| } | ||
|
|
||
| &:hover:not(:disabled) { | ||
| background: colors.$primary600; | ||
| transform: scale(1.02); | ||
| } | ||
|
|
||
| &:disabled { | ||
| background: colors.$gray600; | ||
|
|
||
| cursor: not-allowed; | ||
| } | ||
| } | ||
| @use '~styles/colors.scss' as colors; | ||
|
|
||
| .button { | ||
| font-family: 'Noto Sans', sans-serif; | ||
| color: rgb(255, 255, 255); | ||
| font-size: 1.6rem; | ||
| font-weight: 500; | ||
|
|
||
| padding: 1.6rem; | ||
| border: unset; | ||
DominMFD marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| background-color: colors.$primary200; | ||
| border-radius: 1.4rem; | ||
|
|
||
| transition: 0.3s ease-in-out; | ||
|
|
||
| cursor: pointer; | ||
| appearance: none; | ||
|
|
||
| &--block { | ||
| width: 100%; | ||
|
|
||
| display: block; | ||
| } | ||
|
|
||
| &:hover:not(:disabled) { | ||
| background: colors.$primary600; | ||
| transform: scale(1.02); | ||
| } | ||
|
|
||
| &:disabled { | ||
| background: colors.$gray600; | ||
|
|
||
| cursor: not-allowed; | ||
| } | ||
| } | ||
31 changes: 31 additions & 0 deletions
31
src/components/Calendar/components/DateSelectorComposer/components/DateSelected/index.js
This file contains hidden or 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,31 @@ | ||
| import { Component } from 'pet-dex-utilities'; | ||
| import './index.scss'; | ||
|
|
||
| const events = ['item:click']; | ||
|
|
||
| const html = ` | ||
| <span class="date-selected" data-select="date-selected"></span> | ||
| `; | ||
|
|
||
| export default function DateSelected(date) { | ||
| Component.call(this, { html, events }); | ||
|
|
||
| this.$dateSelected = this.selected.get('date-selected'); | ||
| this.setDate(date); | ||
|
|
||
| this.emitClickevent = () => { | ||
| this.emit('item:click'); | ||
| }; | ||
|
|
||
| this.$dateSelected.addEventListener('click', this.emitClickevent); | ||
| } | ||
|
|
||
| DateSelected.prototype = Object.assign( | ||
| DateSelected.prototype, | ||
| Component.prototype, | ||
| { | ||
| setDate(date) { | ||
| this.$dateSelected.innerText = date; | ||
| }, | ||
| }, | ||
| ); |
16 changes: 16 additions & 0 deletions
16
src/components/Calendar/components/DateSelectorComposer/components/DateSelected/index.scss
This file contains hidden or 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,16 @@ | ||
| @use '~styles/base.scss'; | ||
| @use '~styles/colors.scss' as colors; | ||
| @use '~styles/fonts.scss' as fonts; | ||
| @use '~styles/breakpoints.scss' as breakpoints; | ||
|
|
||
| .date-selected { | ||
| font-family: fonts.$primaryFont; | ||
| color: colors.$gray800; | ||
| font-size: fonts.$lg; | ||
| font-weight: fonts.$regular; | ||
|
|
||
| &:hover { | ||
| color: colors.$primary200; | ||
| font-weight: fonts.$semiBold; | ||
| } | ||
| } |
141 changes: 141 additions & 0 deletions
141
src/components/Calendar/components/DateSelectorComposer/components/MonthSelector/index.js
This file contains hidden or 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,141 @@ | ||
| import { Component } from 'pet-dex-utilities'; | ||
| import { makeSwipable } from '../../../../../../utils/swiper'; | ||
DominMFD marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import SelectorItem from '../SelectorItem'; | ||
| import { MONTHS } from '../../../../utils/months'; | ||
Frompaje marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import './index.scss'; | ||
|
|
||
| const events = ['month:change', 'selector:click']; | ||
|
|
||
| const html = ` | ||
| <div class="month-selector" data-select="month-selector"> | ||
| <div> | ||
| <div data-select="month-list"> | ||
| <ul data-select="list-content"> | ||
| </ul> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| `; | ||
|
|
||
| export default function MonthSelector(dateArray) { | ||
| Component.call(this, { html, events }); | ||
|
|
||
| this.dateArray = dateArray; | ||
| this.$monthSelector = this.selected.get('month-selector'); | ||
| this.$dateList = this.selected.get('month-list'); | ||
| this.$listContent = this.selected.get('list-content'); | ||
|
|
||
| this.itemCount = this.dateArray.length; | ||
| this.columnWidth = 150; | ||
| this.nodePadding = 6; | ||
| this.scrollLeft = this.$monthSelector.scrollLeft; | ||
|
|
||
| const swiper = makeSwipable(this.$monthSelector); | ||
|
|
||
| const handleItemClick = (index) => { | ||
| const itemScroll = | ||
| index * this.columnWidth - | ||
| (this.viewportWidth / 2 - this.columnWidth / 2); | ||
| this.$monthSelector.scrollLeft = itemScroll; | ||
| }; | ||
|
|
||
| const emitMonthChangeEvent = (month) => { | ||
| const newMonth = MONTHS.indexOf(month); | ||
| this.emit('month:change', newMonth); | ||
| }; | ||
|
|
||
| setTimeout(() => { | ||
| this.viewportWidth = this.$monthSelector.offsetWidth; | ||
|
|
||
| const renderWindow = () => { | ||
| this.totalContentWidth = (this.itemCount - 1) * this.columnWidth + 176; | ||
|
|
||
| this.startNode = | ||
| Math.floor(this.scrollLeft / this.columnWidth) - this.nodePadding; | ||
| this.startNode = Math.max(0, this.startNode); | ||
|
|
||
| this.visibleNodesCount = | ||
| Math.ceil(this.viewportWidth / this.columnWidth) + 2 * this.nodePadding; | ||
| this.visibleNodesCount = Math.min( | ||
| this.itemCount - this.startNode, | ||
| this.visibleNodesCount, | ||
| ); | ||
|
|
||
| this.offsetX = this.startNode * this.columnWidth; | ||
|
|
||
| this.$dateList.style.width = `${this.totalContentWidth}px`; | ||
| this.$listContent.style.transform = `translateX(${this.offsetX}px)`; | ||
|
|
||
| this.$listContent.innerHTML = ''; | ||
| this.visibleChildren = new Array(this.visibleNodesCount) | ||
| .fill(null) | ||
| .map( | ||
| (_, index) => | ||
| new SelectorItem(this.dateArray[index + this.startNode]), | ||
| ); | ||
|
|
||
| this.visibleChildren.forEach((selectorItem, index) => { | ||
| selectorItem.mount(this.$listContent); | ||
| selectorItem.listen('item:click', () => | ||
| handleItemClick(index + this.startNode), | ||
| ); | ||
| selectorItem.listen('item:change', (item) => | ||
| emitMonthChangeEvent(item), | ||
| ); | ||
|
|
||
| if (index === 7) { | ||
| selectorItem.active(); | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| this.$monthSelector.addEventListener('scroll', (e) => { | ||
| if (this.animationFrame) { | ||
| cancelAnimationFrame(this.animationFrame); | ||
| } | ||
| this.animationFrame = requestAnimationFrame(() => { | ||
| this.scrollLeft = e.target.scrollLeft; | ||
| renderWindow(); | ||
|
|
||
| const activeItem = this.$dateList.querySelector( | ||
| 'selector-item--active', | ||
| ); | ||
| if (activeItem) { | ||
| activeItem.scrollIntoView({ | ||
| inline: 'center', | ||
| behavior: 'smooth', | ||
| }); | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| swiper.left(() => { | ||
| this.scrollLeft = Math.max(this.scrollLeft - this.columnWidth, 0); | ||
| this.$monthSelector.scrollLeft = this.scrollLeft; | ||
| renderWindow(); | ||
| }); | ||
|
|
||
| swiper.right(() => { | ||
| this.scrollLeft = Math.min( | ||
| this.scrollLeft + this.columnWidth, | ||
| this.totalContentWidth - this.viewportWidth, | ||
| ); | ||
| this.$monthSelector.scrollLeft = this.scrollLeft; | ||
| renderWindow(); | ||
| }); | ||
|
|
||
| const scrollToMiddle = () => { | ||
| this.scrollLeft = this.totalContentWidth / 2 - this.viewportWidth / 2; | ||
| this.$monthSelector.scrollLeft = this.scrollLeft; | ||
| }; | ||
|
|
||
| renderWindow(); | ||
| scrollToMiddle(); | ||
| }, 0); | ||
| } | ||
|
|
||
| MonthSelector.prototype = Object.assign( | ||
| MonthSelector.prototype, | ||
| Component.prototype, | ||
| {}, | ||
| ); | ||
31 changes: 31 additions & 0 deletions
31
src/components/Calendar/components/DateSelectorComposer/components/MonthSelector/index.scss
This file contains hidden or 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,31 @@ | ||
| @use '~styles/base.scss'; | ||
| @use '~styles/colors.scss' as colors; | ||
| @use '~styles/fonts.scss' as fonts; | ||
| @use '~styles/breakpoints.scss' as breakpoints; | ||
|
|
||
| .month-selector { | ||
| overflow: auto; | ||
|
|
||
| display: flex; | ||
| flex-direction: row; | ||
|
|
||
| margin-bottom: 2.4rem; | ||
|
|
||
| padding-bottom: 2.4rem; | ||
|
|
||
| border-bottom: 0.1rem solid colors.$gray150; | ||
|
|
||
| box-sizing: border-box; | ||
|
|
||
| scroll-snap-type: x proximity; | ||
|
|
||
| scrollbar-width: none; | ||
|
|
||
| [data-select='list-content'] { | ||
| width: fit-content; | ||
|
|
||
| display: flex; | ||
|
|
||
| align-items: center; | ||
| } | ||
| } |
36 changes: 36 additions & 0 deletions
36
src/components/Calendar/components/DateSelectorComposer/components/SelectorItem/index.js
This file contains hidden or 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,36 @@ | ||
| import { Component } from 'pet-dex-utilities'; | ||
| import './index.scss'; | ||
|
|
||
| const events = ['item:change', 'item:click']; | ||
|
|
||
| const html = ` | ||
| <li class="selector-item" data-select="selector-item"></li> | ||
| `; | ||
|
|
||
| export default function SelectorItem(item) { | ||
| Component.call(this, { html, events }); | ||
| this.item = item; | ||
| this.$selectorItem = this.selected.get('selector-item'); | ||
| this.$selectorItem.innerText = this.item; | ||
|
|
||
| if (typeof this.item === 'string') this.$selectorItem.style.width = '150px'; | ||
|
|
||
| if (typeof this.item === 'number') this.$selectorItem.style.width = '70px'; | ||
|
|
||
| this.emitClickEvent = () => { | ||
| this.emit('item:click'); | ||
| }; | ||
|
|
||
| this.$selectorItem.addEventListener('click', this.emitClickEvent); | ||
| } | ||
|
|
||
| SelectorItem.prototype = Object.assign( | ||
| SelectorItem.prototype, | ||
| Component.prototype, | ||
| { | ||
| active() { | ||
| this.$selectorItem.classList.add('selector-item--active'); | ||
| this.emit('item:change', this.item); | ||
| }, | ||
| }, | ||
| ); |
27 changes: 27 additions & 0 deletions
27
src/components/Calendar/components/DateSelectorComposer/components/SelectorItem/index.scss
This file contains hidden or 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 @@ | ||
| @use '~styles/base.scss'; | ||
| @use '~styles/colors.scss' as colors; | ||
| @use '~styles/fonts.scss' as fonts; | ||
| @use '~styles/breakpoints.scss' as breakpoints; | ||
|
|
||
| .selector-item { | ||
| font-family: fonts.$primaryFont; | ||
| color: colors.$gray700; | ||
|
|
||
| text-align: center; | ||
| font-size: fonts.$xs; | ||
| font-weight: fonts.$medium; | ||
|
|
||
| scroll-snap-align: center; | ||
|
|
||
| &--active { | ||
| color: colors.$primary200; | ||
| font-size: fonts.$lg; | ||
| font-weight: fonts.$semiBold; | ||
|
|
||
| padding: 0.6rem 1.2rem; | ||
| border: 1px solid colors.$blue100; | ||
|
|
||
| background-color: rgba(209, 230, 255, 0.5); | ||
| border-radius: 1.4rem; | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
...ar/components/DateSelectorComposer/components/SelectorModal/components/ModalItem/index.js
This file contains hidden or 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,29 @@ | ||
| import { Component } from 'pet-dex-utilities'; | ||
| import './index.scss'; | ||
|
|
||
| const events = ['item:change', 'item:click']; | ||
|
|
||
| const html = ` | ||
| <li class="selector-modal__item" data-select="modal-item"></li> | ||
| `; | ||
|
|
||
| export default function ModalItem(item) { | ||
| Component.call(this, { html, events }); | ||
|
|
||
| this.item = item; | ||
| this.$modalItem = this.selected.get('modal-item'); | ||
| this.$modalItem.innerText = this.item; | ||
|
|
||
| const emitEventClick = () => { | ||
| this.emit('item:click', this.item); | ||
| }; | ||
|
|
||
| this.$modalItem.addEventListener('click', () => emitEventClick()); | ||
| } | ||
|
|
||
| ModalItem.prototype = Object.assign(ModalItem.prototype, Component.prototype, { | ||
| active() { | ||
| this.$modalItem.classList.add('selector-modal__item--active'); | ||
| this.emit('item:change', this.item); | ||
| }, | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.