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

Fixed scoremeter readings limit check and playground controls #27

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

imanshu03
Copy link
Contributor

  1. Added logic to check if our readings are within the specified lowerLimit and upperLimit as follows:
  • If oldReading prop does not exists, set the sanitizedOldReading value to LOWER_THRESHOLD.
  • If oldReading prop exists, check if its values is greater than upperLimit or less than lowerLimit and set the sanitizedOldReading value respectively to upperLimit or lowerLimit. If oldReading falls within the specified limit, set the sanitizedOldReading value to oldReading prop value.
  • If reading prop value falls out of the specified limit range( greater than upperLimit or less than lowerLimit) then set the sanitizedReading value to sanitizedOldReading otherwise set it to reading prop value
  1. Fixed storybook playground controls

@bigint bigint added the enhancement New feature or request label Jul 11, 2022
const sanitizedOldReading = oldReading
? oldReading < 0
? LOWER_THRESHOLD
? oldReading < lowerLimit
Copy link
Contributor

Choose a reason for hiding this comment

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

Please can you simplify the logic or wrap the truthy and falsy blocks in braces, to make it more readable. (I would advocate for simplification of logic) Thanks!

Something like:

const sanitizedOldReading = oldReading
        ? (oldReading < lowerLimit
            ? lowerLimit
            : (
                oldReading > upperLimit
                    ? upperLimit
                    : oldReading
            )
        )
        : LOWER_THRESHOLD;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Eslint rules does not allow us to add braces for ternary expression. I had added braces but they got removed while committing the files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants