Skip to content
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

Add continuous counter update to VaCounter close #2108 #3247

Merged
merged 8 commits into from Apr 11, 2023
Merged

Add continuous counter update to VaCounter close #2108 #3247

merged 8 commits into from Apr 11, 2023

Conversation

ghost
Copy link

@ghost ghost commented Mar 26, 2023

Description

This PR adds a feature to the counter component in Vuestic UI that allows the counter to continuously update when the user keeps the button pressed instead of updating only once. close #2108

Markup:

Relevant code
<template>
  ...
  <va-button class="va-counter__button-decrease" :aria-label="t('decreaseCounter')" v-bind="decreaseButtonProps"
    @click="decreaseCount" @mousedown.prevent="startDecreasing" @mouseup.prevent="stopDecreasing" />
  ...
  <va-button class="va-counter__button-increase" :aria-label="t('increaseCounter')" v-bind="increaseButtonProps"
    @click="increaseCount" @mousedown.prevent="startIncreasing" @mouseup.prevent="stopIncreasing" />
  ...
</template>

<script>
...
let decreaseInterval: number | undefined
let increaseInterval: number | undefined
...
const startDecreasing = () => {
  decreaseCount()
  decreaseInterval = setInterval(decreaseCount, 100) as any
}
const stopDecreasing = () => {
  clearInterval(decreaseInterval)
}
const startIncreasing = () => {
  increaseCount()
  increaseInterval = setInterval(increaseCount, 100) as any
}
const stopIncreasing = () => {
  clearInterval(increaseInterval)
}
...
setup(props, { emit, attrs }) {
  ...
  return {
    ...
    startDecreasing,
    stopDecreasing,
    startIncreasing,
    stopIncreasing,
    ...
  }
}
...
</script>


## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [X ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Improvement/refactoring (non-breaking change that doesn't add any feature but make things better)

@ghost ghost changed the title Add continuous counter update to VaCounter Add continuous counter update to VaCounter close #2108 Mar 26, 2023
@rustem-nasyrov rustem-nasyrov requested a review from m0ksem March 27, 2023 09:47
@m0ksem m0ksem requested a review from RVitaly1978 March 27, 2023 17:34
Copy link
Member

@RVitaly1978 RVitaly1978 left a comment

Choose a reason for hiding this comment

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

Fix: elements with multiple attributes should span multiple lines, with one attribute per line

Copy link
Collaborator

@m0ksem m0ksem left a comment

Choose a reason for hiding this comment

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

Looks good. Thanks! Will do QA later. Try to move logic outside this component to composables. We likely will use it for other components like Carousel, Tabs, etc.

Lmk if you need help with this.

packages/ui/src/components/va-counter/VaCounter.vue Outdated Show resolved Hide resolved
@ghost ghost requested review from RVitaly1978 and m0ksem March 30, 2023 10:26
@m0ksem
Copy link
Collaborator

m0ksem commented Apr 5, 2023

Hey, @Skander999. Composable looks good, thanks! I simplified it a bit using our existing utility composables like useEvent, useTemplateRef and removed your old implementation in VaCounter, so logic implemented in composable now, not in component.

@m0ksem
Copy link
Collaborator

m0ksem commented Apr 5, 2023

@RVitaly1978, check how your unnecessary refactoring impact other's PR- it was beautiful until I merged develop here to resolve conflicts :) Also, waiting for your review here, and we're ready to merge.

@m0ksem m0ksem added the feature Something useful to end user label Apr 5, 2023
@ghost
Copy link
Author

ghost commented Apr 5, 2023

Thank you for your feedback @m0ksem !

@m0ksem m0ksem merged commit aacb851 into epicmaxco:develop Apr 11, 2023
m0ksem added a commit that referenced this pull request Apr 12, 2023
* Continous update of the counter when keep clicked

* Refactor elements to span multiple lines with one attribute per line

* Refactor: Moved logic to compostables

* chore: eslint fixes

* chore: refactor useLongPress composable

* fix(counter): correctly use useLongPress composable

* fix(counter): add long-press-delay prop

---------

Co-authored-by: Maksim Nedoshev <m0ksem1337@gmail.com>
@ghost ghost deleted the feat/continousCounterUpdate branch May 11, 2023 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Something useful to end user
Projects
None yet
Development

Successfully merging this pull request may close these issues.

VaCounter increase/decrease value on long click
3 participants