Skip to content

Commit 46bc0ab

Browse files
authored
feat: add more components (#101)
1 parent 2e02321 commit 46bc0ab

File tree

6 files changed

+109
-0
lines changed

6 files changed

+109
-0
lines changed

src/components/ActivityIndicator.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import {
2+
ActivityIndicator as RNActivityIndicator,
3+
type ActivityIndicatorProps,
4+
} from "react-native";
5+
6+
import {
7+
useCssElement,
8+
type StyledConfiguration,
9+
type StyledProps,
10+
} from "../runtime";
11+
12+
const mapping = {
13+
className: {
14+
target: "style",
15+
nativeStyleMapping: {
16+
color: "color",
17+
},
18+
},
19+
} satisfies StyledConfiguration<typeof RNActivityIndicator>;
20+
21+
export function ActivityIndicator(
22+
props: StyledProps<ActivityIndicatorProps, typeof mapping>,
23+
) {
24+
return useCssElement(RNActivityIndicator, props, mapping);
25+
}
26+
27+
export default ActivityIndicator;

src/components/Button.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Button as RNButton, type ButtonProps } from "react-native";
2+
3+
import {
4+
useCssElement,
5+
type StyledConfiguration,
6+
type StyledProps,
7+
} from "../runtime";
8+
9+
const mapping = {
10+
className: {
11+
target: false,
12+
nativeStyleMapping: {
13+
color: "color",
14+
},
15+
},
16+
} satisfies StyledConfiguration<typeof RNButton>;
17+
18+
export function Button(props: StyledProps<ButtonProps, typeof mapping>) {
19+
return useCssElement(RNButton, props, mapping);
20+
}
21+
22+
export default Button;

src/components/FlatList.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { FlatList as RNFlatList, type FlatListProps } from "react-native";
2+
3+
import {
4+
useCssElement,
5+
type StyledConfiguration,
6+
type StyledProps,
7+
} from "../runtime";
8+
9+
const mapping = {
10+
columnWrapperStyle: "columnWrapperStyle",
11+
listFooterComponentClassName: "ListFooterComponentStyle",
12+
listHeaderComponentClassName: "ListHeaderComponentStyle",
13+
} satisfies StyledConfiguration<typeof RNFlatList>;
14+
15+
export function FlatList<ItemT>(
16+
props: StyledProps<FlatListProps<ItemT>, typeof mapping>,
17+
) {
18+
return useCssElement(RNFlatList, props, mapping);
19+
}
20+
21+
export default FlatList;

src/components/Image.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Image as RNImage, type ImageProps } from "react-native";
2+
3+
import {
4+
useCssElement,
5+
type StyledConfiguration,
6+
type StyledProps,
7+
} from "../runtime";
8+
9+
const mapping = {
10+
className: "style",
11+
} satisfies StyledConfiguration<typeof RNImage>;
12+
13+
export function Image(props: StyledProps<ImageProps, typeof mapping>) {
14+
return useCssElement(RNImage, props, mapping);
15+
}
16+
17+
export default Image;

src/components/TextInput.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { TextInput as RNTextInput, type TextInputProps } from "react-native";
2+
3+
import {
4+
useCssElement,
5+
type StyledConfiguration,
6+
type StyledProps,
7+
} from "../runtime";
8+
9+
const mapping = {
10+
className: "style",
11+
} satisfies StyledConfiguration<typeof RNTextInput>;
12+
13+
export function TextInput(props: StyledProps<TextInputProps, typeof mapping>) {
14+
return useCssElement(RNTextInput, props, mapping);
15+
}
16+
17+
export default TextInput;

src/components/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
export * from "react-native";
22

3+
export { ActivityIndicator } from "./ActivityIndicator";
4+
export { Button } from "./Button";
5+
export { FlatList } from "./FlatList";
6+
export { Image } from "./Image";
37
export { Text } from "./Text";
8+
export { TextInput } from "./TextInput";
49
export { View } from "./View";

0 commit comments

Comments
 (0)