Skip to content

Instantly share code, notes, and snippets.

@Doko-Demo-Doa
Created February 9, 2024 03:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Doko-Demo-Doa/4aafd423197660944a9472ac1b186460 to your computer and use it in GitHub Desktop.
Save Doko-Demo-Doa/4aafd423197660944a9472ac1b186460 to your computer and use it in GitHub Desktop.
Custom Component, simple version
import { PropsWithChildren } from "react";
import { StyleSheet } from "react-native";
import {
TouchableOpacity,
TouchableOpacityProps,
} from "~/components/overrides";
import { createStyleSheet, useStyles } from "~/utils/theme-utils";
interface Props extends PropsWithChildren, TouchableOpacityProps {
variant?: "blue" | "purple" | "default";
}
export const CustomButton: React.FC<Props> = ({ children, ...props }) => {
const { styles } = useStyles(styleSheet);
return (
<TouchableOpacity
{...props}
style={StyleSheet.flatten([styles.default, props.style])}
>
{children}
</TouchableOpacity>
);
};
const styleSheet = createStyleSheet((theme) => ({
default: {
paddingHorizontal: 2,
paddingVertical: 2,
alignItems: "center",
justifyContent: "center",
borderRadius: 8,
backgroundColor: theme.colors.buttonSecondaryEnabled,
},
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment