Skip to content

Commit

Permalink
feat: add decimalSeparator prop (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
krestaino authored Feb 10, 2024
1 parent cddee2c commit 03f7c52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ const App = () => {
| `enterAnimationType` | no | `'slide-in-up' or 'slide-in-down'` | Whether the new digit should enter from the top or the bottom |
| `separatorStyle` | no | `StyleProp<TextStyle>` | Extra style applied only to separators. In this case, the colon (`:`) and the comma (`,`) |
| `textCharStyle` | no | `StyleProp<TextStyle>` | The style applied to each individual character of the stopwatch/timer |
| `decimalSeparator` | no | `string` | Decimal separator for formatting time. Defaults to a comma `,` |

## Methods

Expand Down
7 changes: 6 additions & 1 deletion src/StopwatchTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ export interface StopwatchTimerProps {
* If 1, the component will display seconds, minutes and hundredth of ms.
*/
trailingZeros?: 0 | 1 | 2;
/**
* Decimal separator for formatting time. Defaults to a comma (','), but any string can be used for custom formats.
*/
decimalSeparator?: string;
}

export interface StopwatchTimerMethods {
Expand Down Expand Up @@ -105,6 +109,7 @@ function Stopwatch(
separatorStyle,
textCharStyle,
trailingZeros = 1,
decimalSeparator = ',',
}: StopwatchTimerProps,
ref: ForwardedRef<StopwatchTimerMethods>
) {
Expand Down Expand Up @@ -241,7 +246,7 @@ function Stopwatch(
separatorStyle,
]}
>
,
{decimalSeparator}
</Text>
<Text
style={[
Expand Down

0 comments on commit 03f7c52

Please sign in to comment.