-
-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathHeaderedCard.tsx
41 lines (35 loc) · 1.21 KB
/
HeaderedCard.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { ReactNode } from 'react';
import { RequireAllOrNone } from 'type-fest';
import { IconName } from '@suite-native/icons';
import { Card, CardProps } from './Card';
import { Text } from '../Text';
import { Headered } from '../Headered';
import { HStack } from '../Stack';
import { TextButton } from '../Button/TextButton';
type HeaderedCardProps = CardProps & CardHeaderProps;
type CardHeaderProps = RequireAllOrNone<
{
title: ReactNode;
onButtonPress: () => void;
buttonTitle: ReactNode;
buttonIcon?: IconName;
},
'buttonTitle' | 'onButtonPress'
>;
const CardHeader = ({ title, onButtonPress, buttonTitle, buttonIcon }: CardHeaderProps) => (
<HStack justifyContent="space-between">
<Text color="textSubdued" variant="hint">
{title}
</Text>
{buttonTitle && (
<TextButton size="small" onPress={onButtonPress} viewRight={buttonIcon}>
{buttonTitle}
</TextButton>
)}
</HStack>
);
export const HeaderedCard = ({ children, style, ...headerProps }: HeaderedCardProps) => (
<Headered header={<CardHeader {...headerProps} />}>
<Card style={style}>{children}</Card>
</Headered>
);