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

feat: add percent input component #2473

Merged
merged 3 commits into from
Oct 12, 2022

Conversation

yvmunayev
Copy link
Contributor

fix: #2472

Changes proposed in this PR:

  • feat: add percent input component

  • fix: using minimumIntegerDigits={5} write 23567 then remove numbers, the cursor move its position in an unexpected way

  • fix: improve doc, it mention things about number and percent formating

  • I have followed (at least) the PR section of the contributing guide.

@nexxtway/react-rainbow

@commit-lint
Copy link

commit-lint bot commented Oct 10, 2022

Features

  • add percent input component (bf18b91)

Bug Fixes

  • improve doc, it mention things about currency, number and percent formating (1afd18a)

Contributors

yvmunayev, LeandroTorresSicilia

Commit-Lint commands

You can trigger Commit-Lint actions by commenting on this PR:

  • @Commit-Lint merge patch will merge dependabot PR on "patch" versions (X.X.Y - Y change)
  • @Commit-Lint merge minor will merge dependabot PR on "minor" versions (X.Y.Y - Y change)
  • @Commit-Lint merge major will merge dependabot PR on "major" versions (Y.Y.Y - Y change)
  • @Commit-Lint merge disable will desactivate merge dependabot PR
  • @Commit-Lint review will approve dependabot PR
  • @Commit-Lint stop review will stop approve dependabot PR

@@ -1,6 +1,10 @@
import { useMemo } from 'react';
import { getSeparator } from '../helpers';

export default function useDecimalSeparator(locale, options) {
return useMemo(() => getSeparator(locale, 'decimal', options), [locale, options]);
export default function useDecimalSeparator({ locale, style, currency }) {
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

@@ -1,6 +1,10 @@
import { useMemo } from 'react';
import { getSeparator } from '../helpers';

export default function useGroupSeparator(locale, options) {
return useMemo(() => getSeparator(locale, 'group', options), [locale, options]);
export default function useGroupSeparator({ locale, style, currency }) {
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

import formatPercent from './helpers/formatPercent';
import { normalizeValue } from './helpers';

const PercentInput = forwardRef((props, ref) => {
Copy link

Choose a reason for hiding this comment

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

Function PercentInput has 150 lines of code (exceeds 25 allowed). Consider refactoring.

import { normalizeValue } from './helpers';

const PercentInput = forwardRef((props, ref) => {
const {
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 3 locations. Consider refactoring.


const isReadOnly = !!(!disabled && readOnly);

useImperativeHandle(ref, () => ({
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 16 locations. Consider refactoring.

@github-actions
Copy link

github-actions bot commented Oct 10, 2022

Visit the preview URL for this PR (updated for commit 763a19a):

https://react-rainbow--pr2473-feat-add-percent-inp-cb3ietsi.web.app

(expires Wed, 19 Oct 2022 04:04:13 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

onFocus(event);
};

return (
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 2 locations. Consider refactoring.

inputRef.current.setSelectionRange(cursor, cursor);
}, [cursor]);

const handleChange = event => {
Copy link

Choose a reason for hiding this comment

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

Identical blocks of code found in 2 locations. Consider refactoring.

inputRef.current.setSelectionRange(cursor, cursor);
}, [cursor]);

const handleChange = event => {
Copy link

Choose a reason for hiding this comment

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

Function handleChange has 29 lines of code (exceeds 25 allowed). Consider refactoring.

import formatPercent from './helpers/formatPercent';
import { normalizeValue } from './helpers';

const PercentInput = forwardRef((props, ref) => {
Copy link

Choose a reason for hiding this comment

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

Function PercentInput has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.

@@ -0,0 +1,19 @@
import formatInteger from '../../CurrencyInput/helpers/formatInteger';

export default function normalizeValue({ value, locale, decimalSeparator, options }) {
Copy link

Choose a reason for hiding this comment

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

Function normalizeValue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

@codeclimate
Copy link

codeclimate bot commented Oct 12, 2022

Code Climate has analyzed commit 763a19a and detected 14 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 4
Duplication 10

View more on Code Climate.

@LeandroTorresSicilia LeandroTorresSicilia merged commit 4836de3 into master Oct 12, 2022
@LeandroTorresSicilia LeandroTorresSicilia deleted the feat-add-percent-input-component branch October 12, 2022 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add percent input component
2 participants