Skip to content

Commit

Permalink
Merge pull request #886 from andrew-bierman/fix/forking-tamagui-extras
Browse files Browse the repository at this point in the history
✨ forking tamagui-extras due to dependency issues. WIP
  • Loading branch information
andrew-bierman authored May 10, 2024
2 parents 6a1e49a + 8bb9311 commit 9f465ac
Show file tree
Hide file tree
Showing 71 changed files with 2,585 additions and 49 deletions.
3 changes: 2 additions & 1 deletion apps/next/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const enableMillionJS = true;
const plugins = [
withTamagui({
config: '../../packages/ui/src/tamagui.config.ts',
components: ['tamagui', '@tamagui-extras/form'],
components: ['tamagui'],
importsWhitelist: ['constants.js', 'colors.js'],
outputCSS:
process.env.NODE_ENV === 'production' ? './public/tamagui.css' : null,
Expand Down Expand Up @@ -71,6 +71,7 @@ const nextConfig = function () {
'expo-font',
'expo-asset',
'expo-constants',
'expo-clipboard',
'expo-file-system',
'expo-linking',
'expo-permissions',
Expand Down
1 change: 1 addition & 0 deletions apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"react-dom": "18.2.0",
"react-native-web": "^0.19.10",
"setimmediate": "^1.0.5",
"sharp": "^0.33.3",
"tamagui": "^1.96.0",
"url-loader": "^4.1.1",
"vercel": "latest"
Expand Down
10 changes: 9 additions & 1 deletion apps/tauri/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const { withTamagui } = require('@tamagui/next-plugin');
const { join } = require('path');
const path = require('path');
const webpack = require('webpack');
const { withCrossPath } = require('@packrat/crosspath/adapter');
const million = require('million/compiler');

const boolVals = {
Expand All @@ -18,7 +19,7 @@ const enableMillionJS = true;
const plugins = [
withTamagui({
config: '../../packages/ui/src/tamagui.config.ts',
components: ['tamagui', '@tamagui-extras/form'],
components: ['tamagui'],
importsWhitelist: ['constants.js', 'colors.js'],
outputCSS:
process.env.NODE_ENV === 'production' ? './public/tamagui.css' : null,
Expand All @@ -38,6 +39,7 @@ const plugins = [
// ],
}),
withExpo,
withCrossPath('solito'),
];

const nextConfig = function () {
Expand Down Expand Up @@ -69,6 +71,7 @@ const nextConfig = function () {
'expo-font',
'expo-asset',
'expo-constants',
'expo-clipboard',
'expo-file-system',
'expo-linking',
'expo-permissions',
Expand Down Expand Up @@ -110,6 +113,11 @@ const nextConfig = function () {
'@react-navigation/drawer',
'@bacons/react-views',
// End remove section
'@rneui/themed',
'@rneui/base',
'react-native-ratings',
'react-native-size-matters',
'zeego',
],
experimental: {
scrollRestoration: true,
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@shopify/flash-list": "^1.6.1",
"@tamagui-extras/core": "^1.11.0",
"@tamagui-extras/form": "^1.16.0",
"@tamagui-extras/core": "^1.12.2",
"@tamagui-extras/form": "^1.17.2",
"@tamagui/animations-react-native": "^1.96.0",
"@tamagui/font-inter": "^1.96.0",
"@tamagui/progress": "^1.96.0",
Expand Down
107 changes: 107 additions & 0 deletions packages/ui/src/extras/lib/core/src/core/content/LmAlert.tsx
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>
)
}
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 packages/ui/src/extras/lib/core/src/core/content/LmAvatar.tsx
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 packages/ui/src/extras/lib/core/src/core/content/LmCard.tsx
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>
)
}
Loading

0 comments on commit 9f465ac

Please sign in to comment.