Skip to content

Commit

Permalink
Feature/addingreadme
Browse files Browse the repository at this point in the history
Feature/addingreadme
  • Loading branch information
CharlesCoqueret committed Oct 12, 2021
2 parents da0d496 + 05957b6 commit 2ce7df8
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions README.md
@@ -0,0 +1,69 @@
# React component supporting the following

[![GitHub open issues](https://img.shields.io/github/issues/CharlesCoqueret/react-amount?style=flat-square)](https://github.com/CharlesCoqueret/react-amount/issues)
[![MIT](https://img.shields.io/npm/l/react-amount?style=flat-square)](https://github.com/CharlesCoqueret/react-amount/blob/master/LICENSE.txt)
[![Coverage Status](https://coveralls.io/repos/github/CharlesCoqueret/react-amount/badge.svg?branch=master)](https://coveralls.io/github/CharlesCoqueret/react-amount?branch=master)

## Installation

```
yarn add react-amount
```

or

```
npm install react-amount
```

## Usage

```typescript
import React, { useState } from 'react';
import Amount from 'react-currency-input';

interface MyComponent {
value: string | number | undefined;
}

const MyComponent = (props: MyComponentProps): React.Element => {
const { value } = props;

const [currentValue, setCurrentValue] = useState(value);
return (
<Amount
value={currentValue}
suffix=""
onChange={(newValue) => setCurrentValue(newValue.float)}
/>
);
};

export default MyComponent;
```

## Options

| Option | Type | Default value | Description |
| :---------------: | :-------------------------------------------------------: | :-----------: | ------------------------------------------------- |
| value | string \| number | undefined | Initial value of the control |
| readonly | boolean | false | Value is not editable |
| name | string | mandatory | Name of the input field |
| className | string | undefined | Class to be added to the wrapper of the component |
| onChange | (updatedObject: FormattedValues) => void \| Promise<void> | undefined | Callback function to handle value changes |
| decimals | number | 2 | Number of decimals |
| decimalSeparator | string | . | Decimal separator |
| thousandSeparator | string | , | Thousand separator |
| thousandGrouping | ThousangGroupingStyle: "thousand" \| "wan" \| "lakh" | thousand | Thousand grouping style |
| displayOnInvalid | string | - | Value displayed on invalid input in readonly |
| dataTestId | string | undefined | Id value for testing |
| required | boolean | false | Required of the input field |
| prefix | string | undefined | Prefix |
| suffix | string | undefined | Suffix |

## Contributing

We very much welcome contributions.

- Submit [GitHub issues](http://github.com/CharlesCoqueret/react-amount/issues) to report bugs or ask questions.
- Propose [Pull Request](http://github.com/CharlesCoqueret/react-amount/pulls) to improve our code.

0 comments on commit 2ce7df8

Please sign in to comment.