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 decimalSeparator prop #8

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading