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

docs: fix money input stories and docs #91

Merged
merged 2 commits into from
Sep 25, 2018
Merged

Conversation

dferber90
Copy link
Contributor

The money-input story was broken. This PR fixes it.

It further fixes the docs.

} else if (MoneyInput.isHighPrecision(formValues.price)) {
errors.price.unsupportedHighPrecision = true;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just reordered to be in line with the rest of the document.

@@ -7,7 +7,7 @@ A controlled input component for money values with validation states.
## Usage

```js
import MoneyInput from '@commercetools-frontend/ui-kit/inputs/money-input';
import { MoneyInput } from '@commercetools-frontend/ui-kit';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed import path. See #90.

| `isDisabled` | `bool` | - | - | `false` | Indicates that the field cannot be used. |
| `onBlur` | `func` | - | - | - | Called when the amount field or the currency code dropdown is blurred. |
| `onChange` | `function(event)` | ✳️ | - | - | Called with the event of the input or dropdown when either the currency or the amount have changed. Either `onChange` or `onChangeValue` must be passed. |
| `onChangeValue` | `function(nextValue: { currencyCode: string, amount: string })` | ✳️ | - | - | Called with the full value when either the currency or the amount have changed. Either `onChange` or `onChangeValue` must be passed. |
Copy link
Contributor Author

Choose a reason for hiding this comment

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

onChangeValue This does no longer exist and was removed. onChange was adapted as well.

@@ -218,6 +218,8 @@ export default class MoneyInput extends React.Component {
return moneyValue && moneyValue.type === 'highPrecision';
};

static isTouched = touched => touched && Object.values(touched).some(Boolean);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it up so that all static methods used by consumers are grouped at the top.

} else if (event.target.name.endsWith('.currencyCode')) {
({ ...value, currencyCode: event.target.value });
}
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the story.

@dferber90 dferber90 merged commit 0da2300 into master Sep 25, 2018
@dferber90 dferber90 deleted the df-fix-money-input branch September 25, 2018 13:36
lufego pushed a commit that referenced this pull request Oct 1, 2018
* docs(money-input): fix stories

* docs(money-input): remove onChangeValue, fix onChange
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant