-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #886 from andrew-bierman/fix/forking-tamagui-extras
✨ forking tamagui-extras due to dependency issues. WIP
- Loading branch information
Showing
71 changed files
with
2,585 additions
and
49 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
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
107 changes: 107 additions & 0 deletions
107
packages/ui/src/extras/lib/core/src/core/content/LmAlert.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,107 @@ | ||
import { | ||
Card, | ||
CardProps, | ||
ColorProp, | ||
ColorTokens, | ||
Paragraph, | ||
ParagraphProps, | ||
useThemeName, | ||
XStack, | ||
XStackProps, | ||
} from 'tamagui' | ||
import { | ||
CheckCircleRegular, | ||
IconProps, | ||
InfoRegular, | ||
WarningCircleRegular, | ||
WarningRegular, | ||
} from './icons' | ||
|
||
type Severity = 'default' | 'error' | 'info' | 'warning' | 'success' | ||
export type LmAlertProps = CardProps & { | ||
severity?: Severity | ||
text?: string | ||
outlined?: boolean | ||
hideIcon?: boolean | ||
paragraphProps?: ParagraphProps | ||
xStackProps?: XStackProps | ||
iconProps?: IconProps | ||
} | ||
|
||
const severityColor: { [k in Severity]: ColorProp } = { | ||
default: '$gray3', | ||
error: '$red10', | ||
info: '$blue10', | ||
warning: '$orange10', | ||
success: '$green10', | ||
} | ||
|
||
type AlertIconProps = { | ||
severity?: Severity | ||
outlined?: boolean | ||
shouldInvert?: boolean | ||
} | ||
|
||
function AlertIcon({ severity = 'default', outlined, shouldInvert }: AlertIconProps) { | ||
const props: { color?: ColorTokens } = {} | ||
if (outlined) { | ||
props.color = severityColor[severity] as ColorTokens | ||
} else if (shouldInvert) { | ||
props.color = 'white' | ||
} | ||
return { | ||
default: <InfoRegular {...props} />, | ||
error: <WarningCircleRegular {...props} />, | ||
info: <InfoRegular {...props} />, | ||
warning: <WarningRegular {...props} />, | ||
success: <CheckCircleRegular {...props} />, | ||
}[severity] | ||
} | ||
|
||
export function LmAlert({ | ||
severity = 'default', | ||
text, | ||
hideIcon, | ||
outlined, | ||
children, | ||
paragraphProps, | ||
xStackProps, | ||
iconProps, | ||
...rest | ||
}: LmAlertProps) { | ||
const theme = useThemeName() | ||
let shouldInverse = theme === 'light' && severity !== 'default' && !outlined | ||
return ( | ||
<Card | ||
bordered={outlined} | ||
{...(outlined | ||
? { | ||
borderColor: severityColor[severity], | ||
color: severityColor[severity], | ||
} | ||
: { | ||
backgroundColor: severityColor[severity], | ||
})} | ||
{...rest} | ||
padding={rest.padding || '$4'} | ||
> | ||
<XStack space alignItems={'center'} {...xStackProps}> | ||
<AlertIcon | ||
shouldInvert={shouldInverse} | ||
severity={severity} | ||
outlined={outlined} | ||
{...iconProps} | ||
/> | ||
{text && ( | ||
<Paragraph | ||
color={outlined ? severityColor[severity] : shouldInverse ? 'white' : undefined} | ||
{...paragraphProps} | ||
> | ||
{text} | ||
</Paragraph> | ||
)} | ||
{children} | ||
</XStack> | ||
</Card> | ||
) | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/ui/src/extras/lib/core/src/core/content/LmAspectRatio.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,3 @@ | ||
import {styled, ThemeableStack} from "tamagui"; | ||
|
||
export const LmAspectRatio = styled(ThemeableStack, {}) |
46 changes: 46 additions & 0 deletions
46
packages/ui/src/extras/lib/core/src/core/content/LmAvatar.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,46 @@ | ||
import { Avatar, AvatarProps, FontSizeTokens, ImageProps, Paragraph, ParagraphProps } from 'tamagui' | ||
|
||
export type LmAvatarProps = AvatarProps & { | ||
color?: AvatarProps['backgroundColor'] | ||
src?: string | ||
letter?: string | ||
letterProps?: ParagraphProps | ||
imageProps?: ImageProps | ||
} | ||
|
||
export function LmAvatar({ color, src, letter, letterProps, imageProps, ...rest }: LmAvatarProps) { | ||
return ( | ||
<Avatar | ||
circular={rest.circular ?? true} | ||
{...rest} | ||
backgroundColor={src ? undefined : color || '$gray10'} | ||
> | ||
{src || imageProps?.source ? ( | ||
<> | ||
<Avatar.Image | ||
{...imageProps} | ||
{...(imageProps?.source | ||
? { | ||
source: imageProps.source, | ||
} | ||
: { | ||
src: src || imageProps?.src, | ||
})} | ||
/> | ||
<Avatar.Fallback delayMs={600} backgroundColor={color || '$gray10'} /> | ||
</> | ||
) : letter ? ( | ||
<Paragraph | ||
fontSize={rest.size as FontSizeTokens} | ||
color={'white'} | ||
backgroundColor={'$gray10'} | ||
{...letterProps} | ||
> | ||
{letter} | ||
</Paragraph> | ||
) : ( | ||
<Avatar.Fallback backgroundColor={color || '$gray10'} /> | ||
)} | ||
</Avatar> | ||
) | ||
} |
69 changes: 69 additions & 0 deletions
69
packages/ui/src/extras/lib/core/src/core/content/LmCard.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,69 @@ | ||
import { Card, CardProps, H2, Paragraph, ThemeName } from 'tamagui' | ||
import { PropsWithChildren, ReactNode } from 'react' | ||
import { LmImage } from './LmImage' | ||
|
||
export type LmCardProps = PropsWithChildren< | ||
CardProps & { | ||
bouncy?: boolean | ||
title?: string | ||
subTitle?: string | ||
footer?: ReactNode | ||
image?: { | ||
width: number | ||
height: number | ||
src: string | ||
} | ||
} | ||
> | ||
|
||
export const LmCard = ({ | ||
bouncy, | ||
title, | ||
subTitle, | ||
footer, | ||
image, | ||
children, | ||
theme = 'gray' as ThemeName, | ||
...cardProps | ||
}: LmCardProps) => { | ||
return ( | ||
<Card | ||
elevate | ||
size="$4" | ||
bordered | ||
{...(bouncy && { | ||
animation: 'bouncy', | ||
scale: 0.9, | ||
hoverStyle: { | ||
scale: 0.925, | ||
}, | ||
pressStyle: { | ||
scale: 0.875, | ||
}, | ||
})} | ||
theme={theme} | ||
{...cardProps} | ||
> | ||
{(title || subTitle) && ( | ||
<Card.Header padded> | ||
{title && <H2>{title}</H2>} | ||
{subTitle && <Paragraph theme={'alt2'}>{subTitle}</Paragraph>} | ||
</Card.Header> | ||
)} | ||
{children} | ||
{footer && <Card.Footer padded>{footer}</Card.Footer>} | ||
{!!image?.src && ( | ||
<Card.Background> | ||
<LmImage | ||
position="absolute" | ||
resizeMode="cover" | ||
width={'100%'} | ||
height={'auto'} | ||
src={image.src} | ||
source={{ width: image.width, height: image.height }} | ||
/> | ||
</Card.Background> | ||
)} | ||
</Card> | ||
) | ||
} |
Oops, something went wrong.