-
Notifications
You must be signed in to change notification settings - Fork 399
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
export icon variants as props & listitem (wip)
- Loading branch information
1 parent
51318f1
commit 4047d8d
Showing
23 changed files
with
1,849 additions
and
1,639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Avatar } from 'tamagui'; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/components/src/Icon/react/outline/ChevronLeftSmall.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Svg, { SvgProps, Path } from 'react-native-svg'; | ||
const SvgChevronLeftSmall = (props: SvgProps) => ( | ||
<Svg fill="none" viewBox="0 0 24 24" accessibilityRole="image" {...props}> | ||
<Path | ||
fill="currentColor" | ||
fillRule="evenodd" | ||
d="M14.293 7.293a1 1 0 0 1 0 1.414L11 12l3.293 3.293a1 1 0 0 1-1.414 1.414l-3.293-3.293a2 2 0 0 1 0-2.828l3.293-3.293a1 1 0 0 1 1.414 0Z" | ||
clipRule="evenodd" | ||
/> | ||
</Svg> | ||
); | ||
export default SvgChevronLeftSmall; |
11 changes: 5 additions & 6 deletions
11
packages/components/src/Icon/react/outline/ChevronRightSmall.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
packages/components/src/Icon/react/solid/ChevronLeftSmall.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Svg, { SvgProps, Path } from 'react-native-svg'; | ||
const SvgChevronLeftSmall = (props: SvgProps) => ( | ||
<Svg fill="none" viewBox="0 0 24 24" accessibilityRole="image" {...props}> | ||
<Path | ||
fill="currentColor" | ||
fillRule="evenodd" | ||
d="M14.293 7.293a1 1 0 0 0-1.414 0l-3.293 3.293a2 2 0 0 0 0 2.828l3.293 3.293a1 1 0 0 0 1.414-1.414L11 12l3.293-3.293a1 1 0 0 0 0-1.414Z" | ||
clipRule="evenodd" | ||
/> | ||
</Svg> | ||
); | ||
export default SvgChevronLeftSmall; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { Image } from 'tamagui'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
import { isValidElement } from 'react'; | ||
|
||
import { Avatar } from '../Avatar'; | ||
import { type ICON_NAMES, Icon } from '../Icon'; | ||
import { IconButton } from '../IconButton'; | ||
import { Stack } from '../Stack'; | ||
import { Text } from '../Text'; | ||
|
||
import type { IconButtonProps } from '../IconButton'; | ||
import type { AvatarProps, GetProps, StackProps } from 'tamagui'; | ||
|
||
/* Image */ | ||
type ListItemAvatarProps = { | ||
src: string; | ||
} & AvatarProps; | ||
|
||
const ListItemAvatar = (props: ListItemAvatarProps) => { | ||
const { src, ...rest } = props; | ||
|
||
return ( | ||
<Avatar size="$10" {...rest}> | ||
<Avatar.Image src={src} /> | ||
<Avatar.Fallback /> | ||
</Avatar> | ||
); | ||
}; | ||
|
||
/* Text */ | ||
interface ListItemTextProps extends StackProps { | ||
primary?: string | React.ReactNode; | ||
secondary?: string | React.ReactNode; | ||
align?: 'left' | 'center' | 'right'; | ||
primaryTextProps?: GetProps<typeof Text>; | ||
secondaryTextProps?: GetProps<typeof Text>; | ||
} | ||
|
||
const ListItemText = (props: ListItemTextProps) => { | ||
const { | ||
primary, | ||
secondary, | ||
align = 'left', | ||
primaryTextProps, | ||
secondaryTextProps, | ||
...rest | ||
} = props; | ||
|
||
const getJustifyContent = () => { | ||
if (align === 'left') { | ||
return 'flex-start'; | ||
} | ||
if (align === 'center') { | ||
return 'center'; | ||
} | ||
return 'flex-end'; | ||
}; | ||
|
||
return ( | ||
<Stack {...rest} justifyContent={getJustifyContent()}> | ||
{primary && | ||
(isValidElement(primary) ? ( | ||
primary | ||
) : ( | ||
<Text | ||
textAlign={align} | ||
variant="$bodyLgMedium" | ||
userSelect="none" | ||
{...primaryTextProps} | ||
> | ||
{primary} | ||
</Text> | ||
))} | ||
{secondary && | ||
(isValidElement(secondary) ? ( | ||
secondary | ||
) : ( | ||
<Text | ||
variant="$bodyMd" | ||
tone="subdued" | ||
textAlign={align} | ||
userSelect="none" | ||
{...secondaryTextProps} | ||
> | ||
{secondary} | ||
</Text> | ||
))} | ||
</Stack> | ||
); | ||
}; | ||
|
||
/* IconButton */ | ||
const ListItemIconButton = (props: IconButtonProps) => ( | ||
<IconButton variant="tertiary" size="medium" {...props} /> | ||
); | ||
|
||
/* ListItem */ | ||
interface ListItemProps extends StackProps { | ||
title?: string; | ||
titleProps?: ListItemTextProps['primaryTextProps']; | ||
subtitle?: string; | ||
subtitleProps?: ListItemTextProps['secondaryTextProps']; | ||
avatarProps?: ListItemAvatarProps; | ||
icon?: ICON_NAMES; | ||
drillIn?: boolean; | ||
checkMark?: boolean; | ||
} | ||
|
||
function ListItem(props: ListItemProps) { | ||
const { | ||
avatarProps, | ||
icon, | ||
title, | ||
titleProps, | ||
subtitle, | ||
subtitleProps, | ||
drillIn, | ||
checkMark, | ||
onPress, | ||
children, | ||
...rest | ||
} = props; | ||
|
||
return ( | ||
<Stack | ||
flexDirection="row" | ||
alignItems="center" | ||
space="$3" | ||
p="$2" | ||
mx="$3" | ||
borderRadius="$3" | ||
onPress={onPress} | ||
{...(onPress && { | ||
hoverStyle: { bg: '$bgHover' }, | ||
pressStyle: { bg: '$bgActive' }, | ||
focusable: true, | ||
focusStyle: { | ||
outlineWidth: 2, | ||
outlineStyle: 'solid', | ||
outlineColor: '$focusRing', | ||
}, | ||
})} | ||
{...rest} | ||
> | ||
{avatarProps && ( | ||
<ListItemAvatar | ||
{...(!avatarProps.circular && { borderRadius: '$2' })} | ||
{...avatarProps} | ||
/> | ||
)} | ||
{icon && <Icon name={icon} color="$iconSubdued" />} | ||
<ListItemText | ||
flex={1} | ||
primary={title} | ||
primaryTextProps={titleProps} | ||
secondary={subtitle} | ||
secondaryTextProps={subtitleProps} | ||
/> | ||
{children} | ||
{drillIn && ( | ||
<Icon name="ChevronRightSmallOutline" color="$iconSubdued" mx="$-1.5" /> | ||
)} | ||
{checkMark && <Icon name="CheckRadioSolid" color="$iconActive" />} | ||
</Stack> | ||
); | ||
} | ||
|
||
ListItem.Text = ListItemText; | ||
ListItem.Image = ListItemAvatar; | ||
ListItem.IconButton = ListItemIconButton; | ||
|
||
export { ListItem }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.