Skip to content

Feat/nw4.1 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 11 additions & 86 deletions expo-app/components/ui/accordion/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
'use client';
import React, { useMemo } from 'react';
import React from 'react';
import { createAccordion } from '@gluestack-ui/accordion';
import { Svg } from 'react-native-svg';
import { View, Pressable, Text, Platform, TextProps } from 'react-native';
import { tva } from '@gluestack-ui/nativewind-utils/tva';
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
import {
withStyleContext,
useStyleContext,
} from '@gluestack-ui/nativewind-utils/withStyleContext';
import { withStyleContextAndStates } from '@gluestack-ui/nativewind-utils/withStyleContextAndStates';
import { H3 } from '@expo/html-elements';
import { cssInterop } from 'nativewind';
import { PrimitiveIcon, UIIcon } from '@gluestack-ui/icon';

const SCOPE = 'ACCORDION';
/** Styles */
Expand All @@ -30,7 +29,9 @@ const accordionStyle = tva({
},
},
});

const accordionItemStyle = tva({
base: '',
parentVariants: {
variant: {
filled: 'bg-background-0',
Expand Down Expand Up @@ -65,7 +66,7 @@ const accordionContentTextStyle = tva({
base: 'text-typography-700 font-normal',
parentVariants: {
size: {
sm: 'text-sm ',
sm: 'text-sm',
md: 'text-base',
lg: 'text-lg',
},
Expand All @@ -75,79 +76,13 @@ const accordionHeaderStyle = tva({
base: 'mx-0 my-0',
});
const accordionContentStyle = tva({
base: 'px-5 mt-2 pb-5',
base: 'mt-4',
});
const accordionTriggerStyle = tva({
base: 'w-full py-5 px-5 flex-row justify-between items-center web:outline-none focus:outline-none data-[disabled=true]:opacity-40 data-[disabled=true]:cursor-not-allowed data-[focus-visible=true]:bg-background-50',
base: 'w-full flex-row justify-between items-center web:outline-none focus:outline-none data-[disabled=true]:opacity-40 data-[disabled=true]:cursor-not-allowed data-[focus-visible=true]:bg-background-50 py-3 px-4',
});

type IPrimitiveIcon = {
height?: number | string;
width?: number | string;
fill?: string;
color?: string;
size?: number | string;
stroke?: string;
as?: React.ElementType;
className?: string;
};

const PrimitiveIcon = React.forwardRef<
React.ElementRef<typeof Svg>,
IPrimitiveIcon & React.ComponentPropsWithoutRef<typeof Svg>
>(
(
{
height,
width,
fill,
color,
size,
stroke = 'currentColor',
as: AsComp,
...props
},
ref
) => {
const sizeProps = useMemo(() => {
if (size) return { size };
if (height && width) return { height, width };
if (height) return { height };
if (width) return { width };
return {};
}, [size, height, width]);

const colorProps =
stroke === 'currentColor' && color !== undefined ? color : stroke;

if (AsComp) {
return (
<AsComp
ref={ref}
fill={fill}
{...props}
{...sizeProps}
stroke={colorProps}
/>
);
}
return (
<Svg
ref={ref}
height={height}
width={width}
fill={fill}
stroke={colorProps}
{...props}
/>
);
}
);

const Root =
Platform.OS === 'web'
? withStyleContext(View, SCOPE)
: withStyleContextAndStates(View, SCOPE);
const Root = withStyleContext(View, SCOPE);

const Header = (
Platform.OS === 'web' ? H3 : View
Expand All @@ -159,30 +94,20 @@ const UIAccordion = createAccordion({
Item: View,
Header: Header,
Trigger: Pressable,
Icon: PrimitiveIcon,
Icon: UIIcon,
TitleText: Text,
ContentText: Text,
Content: View,
});

cssInterop(UIAccordion, { className: 'style' });
cssInterop(UIAccordion.Item, { className: 'style' });
cssInterop(UIAccordion.Header, { className: 'style' });
cssInterop(UIAccordion.Trigger, { className: 'style' });
cssInterop(UIAccordion.Icon, { className: 'style' });
cssInterop(UIAccordion.TitleText, { className: 'style' });
cssInterop(UIAccordion.Content, { className: 'style' });
cssInterop(UIAccordion.ContentText, { className: 'style' });
// @ts-ignore
cssInterop(UIAccordion.Icon, {
cssInterop(PrimitiveIcon, {
className: {
target: 'style',
nativeStyleToProp: {
height: true,
width: true,
// @ts-ignore
fill: true,
color: true,
color: 'classNameColor',
stroke: true,
},
},
Expand Down
79 changes: 7 additions & 72 deletions expo-app/components/ui/actionsheet/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use client';
import React, { useMemo } from 'react';
import React from 'react';
import { H4 } from '@expo/html-elements';
import { Svg } from 'react-native-svg';
import { createActionsheet } from '@gluestack-ui/actionsheet';
import {
Pressable,
Expand All @@ -11,82 +10,18 @@ import {
VirtualizedList,
FlatList,
SectionList,
Platform,
PressableProps,
} from 'react-native';

import { PrimitiveIcon, UIIcon } from '@gluestack-ui/icon';
import { tva } from '@gluestack-ui/nativewind-utils/tva';
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
import { withStates } from '@gluestack-ui/nativewind-utils/withStates';
import { cssInterop } from 'nativewind';
import {
Motion,
AnimatePresence,
createMotionAnimatedComponent,
} from '@legendapp/motion';

type IPrimitiveIcon = {
height?: number | string;
width?: number | string;
fill?: string;
color?: string;
size?: number | string;
stroke?: string;
as?: React.ElementType;
className?: string;
};
const PrimitiveIcon = React.forwardRef<
React.ElementRef<typeof Svg>,
IPrimitiveIcon & React.ComponentPropsWithoutRef<typeof Svg>
>(
(
{
height,
width,
fill,
color,
size,
stroke = 'currentColor',
as: AsComp,
...props
},
ref
) => {
const sizeProps = useMemo(() => {
if (size) return { size };
if (height && width) return { height, width };
if (height) return { height };
if (width) return { width };
return {};
}, [size, height, width]);

const colorProps =
stroke === 'currentColor' && color !== undefined ? color : stroke;

if (AsComp) {
return (
<AsComp
ref={ref}
fill={fill}
{...props}
{...sizeProps}
stroke={colorProps}
/>
);
}
return (
<Svg
ref={ref}
height={height}
width={width}
fill={fill}
stroke={colorProps}
{...props}
/>
);
}
);

const ItemWrapper = React.forwardRef<
React.ElementRef<typeof Pressable>,
PressableProps
Expand All @@ -99,7 +34,7 @@ const AnimatedPressable = createMotionAnimatedComponent(Pressable);
export const UIActionsheet = createActionsheet({
Root: View,
Content: Motion.View,
Item: Platform.OS === 'web' ? ItemWrapper : withStates(ItemWrapper),
Item: ItemWrapper,
ItemText: Text,
DragIndicator: View,
IndicatorWrapper: View,
Expand All @@ -109,7 +44,7 @@ export const UIActionsheet = createActionsheet({
FlatList: FlatList,
SectionList: SectionList,
SectionHeaderText: H4,
Icon: PrimitiveIcon,
Icon: UIIcon,
AnimatePresence: AnimatePresence,
});

Expand Down Expand Up @@ -142,15 +77,15 @@ cssInterop(UIActionsheet.FlatList, {
});
cssInterop(UIActionsheet.SectionList, { className: 'style' });
cssInterop(UIActionsheet.SectionHeaderText, { className: 'style' });
cssInterop(UIActionsheet.Icon, {

cssInterop(PrimitiveIcon, {
className: {
target: 'style',
nativeStyleToProp: {
height: true,
width: true,
// @ts-ignore
fill: true,
color: true,
color: 'classNameColor',
stroke: true,
},
},
Expand Down
22 changes: 5 additions & 17 deletions expo-app/components/ui/alert-dialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,22 @@ import {
withStyleContext,
useStyleContext,
} from '@gluestack-ui/nativewind-utils/withStyleContext';
import { withStyleContextAndStates } from '@gluestack-ui/nativewind-utils/withStyleContextAndStates';

import { cssInterop } from 'nativewind';
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
import {
Motion,
AnimatePresence,
createMotionAnimatedComponent,
} from '@legendapp/motion';
import { View, Pressable, ScrollView, Platform } from 'react-native';
import { View, Pressable, ScrollView } from 'react-native';

const AnimatedPressable = createMotionAnimatedComponent(Pressable);

const SCOPE = 'ALERT_DIALOG';

const UIAccessibleAlertDialog = createAlertDialog({
Root:
Platform.OS === 'web'
? withStyleContext(View, SCOPE)
: withStyleContextAndStates(View, SCOPE),
Root: withStyleContext(View, SCOPE),
Body: ScrollView,
Content: Motion.View,
CloseButton: Pressable,
Expand All @@ -34,17 +31,8 @@ const UIAccessibleAlertDialog = createAlertDialog({
AnimatePresence: AnimatePresence,
});

cssInterop(UIAccessibleAlertDialog, { className: 'style' });
cssInterop(UIAccessibleAlertDialog.Content, { className: 'style' });
cssInterop(UIAccessibleAlertDialog.CloseButton, { className: 'style' });
cssInterop(UIAccessibleAlertDialog.Header, { className: 'style' });
cssInterop(UIAccessibleAlertDialog.Footer, { className: 'style' });
cssInterop(UIAccessibleAlertDialog.Body, {
className: 'style',
contentContainerClassName: 'contentContainerStyle',
indicatorClassName: 'indicatorStyle',
});
cssInterop(UIAccessibleAlertDialog.Backdrop, { className: 'style' });
cssInterop(Motion.View, { className: 'style' });
cssInterop(AnimatedPressable, { className: 'style' });

const alertDialogStyle = tva({
base: 'group/modal w-full h-full justify-center items-center web:pointer-events-none',
Expand Down
Loading