Skip to content

Commit

Permalink
Enhance typings in [ButtonGroup] to receive different props for data (
Browse files Browse the repository at this point in the history
#40)

* Enhance `typings` in [ButtonGroup] to receive different props for data

* Release 0.1.19
  • Loading branch information
hyochan committed Jul 28, 2021
1 parent ef97e2e commit 55776e4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOGS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Changelogs

## 0.1.19

Enhance `typings` in [ButtonGroup] to receive different props for data.

## 0.1.18

Add `comment-light` icon to `dooboo-ui` Icon.
Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dooboo-ui",
"version": "0.1.18",
"version": "0.1.19",
"main": "index.js",
"types": "index.d.ts",
"author": "dooboolab",
Expand Down
12 changes: 6 additions & 6 deletions main/ButtonGroup.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {DoobooTheme, light, useTheme, withTheme} from './theme';
import React, {FC, useState} from 'react';
import React, {useState} from 'react';
import {
StyleProp,
StyleSheet,
Expand All @@ -18,20 +18,20 @@ interface Styles {
selectedText: StyleProp<TextStyle>;
}

interface Props {
interface Props<T> {
testID?: string;
theme: DoobooTheme;
borderRadius?: number;
borderWidth?: number;
style?: StyleProp<ViewStyle>;
styles?: Styles;
data: string[];
data: T[];
color?: string;
onPress?: (i: number) => void;
initialIndex?: number;
}

const StyledButtonGroup: FC<Props> = (props) => {
function StyledButtonGroup<T>(props: Props<T>): React.ReactElement {
const {theme} = useTheme();

const {
Expand Down Expand Up @@ -111,7 +111,7 @@ const StyledButtonGroup: FC<Props> = (props) => {
})}
</View>
);
};
}

StyledButtonGroup.defaultProps = {
theme: light,
Expand Down Expand Up @@ -153,4 +153,4 @@ StyledButtonGroup.defaultProps = {
data: ['option 1', 'option 2'],
};

export const ButtonGroup = withTheme(StyledButtonGroup);
export const ButtonGroup = withTheme<any>(StyledButtonGroup);

0 comments on commit 55776e4

Please sign in to comment.