Skip to content

Instantly share code, notes, and snippets.

@hellsan631
Created June 23, 2021 18:16
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 hellsan631/d25b64597795b4c4e0c292f83bd08c81 to your computer and use it in GitHub Desktop.
Save hellsan631/d25b64597795b4c4e0c292f83bd08c81 to your computer and use it in GitHub Desktop.
interface ComposableComponentProps {
icon: React.ReactNode;
NameComponent: React.FC<BaseNameComponentProps>;
hideIcon?: boolean;
IndicatorComponent?: React.FC<BaseIndicatorComponentProps>;
children?: React.ReactNode;
}
export default function ComposableComponent({
icon,
NameComponent,
hideIcon,
IndicatorComponent = BaseIndicatorComponent,
children,
}: ComposableComponentProps) {
return (
<View
style={[
styles.row,
hideIcon && styles.rowPaddingNoIcon,
]}>
<IndicatorComponent hideIcon={hideIcon} />
<View style={styles.container}>
{!hideIcon && icon}
<NameComponent />
{children}
</View>
</View>
);
}
interface ComposableComponentProps {
icon: React.ReactNode;
NameComponent: React.FC<BaseNameComponentProps>;
hideIcon?: boolean;
IndicatorComponent?: React.FC<BaseIndicatorComponentProps>;
children?: React.ReactNode;
}
export default function ComposableComponent({
icon,
NameComponent,
hideIcon,
IndicatorComponent = BaseIndicatorComponent,
children,
}: ComposableComponentProps) {
return (
<div
className={classNames(
styles.row,
hideIcon && styles.rowPaddingNoIcon,
)}>
<IndicatorComponent hideIcon={hideIcon} />
<div className={styles.container}>
{!hideIcon && icon}
<NameComponent />
{children}
</div>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment