-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Izet Molla
authored and
Izet Molla
committed
Aug 5, 2023
1 parent
e81819d
commit fabc33a
Showing
10 changed files
with
136 additions
and
107 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import { SafeAreaProps, GeneralStyles } from '../../types'; | ||
import { PseudoComponentProps } from '../../contexts/theme'; | ||
import type { ViewProps } from 'react-native'; | ||
|
||
export interface BoxProps | ||
extends ViewProps, | ||
PseudoComponentProps<ViewProps['style']> { | ||
safeArea?: boolean; | ||
} | ||
SafeAreaProps, | ||
GeneralStyles, | ||
PseudoComponentProps<ViewProps['style']> {} |
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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import React, { memo } from 'react'; | ||
import React, { FC, memo } from 'react'; | ||
import { usePropsResolution } from '../../hooks/usePropsResolution'; | ||
import { IconProps } from './types'; | ||
import { omit } from '../../utils'; | ||
|
||
const Icon = (props: IconProps) => { | ||
const { as, ...resolvedProps } = usePropsResolution('Icon', props); | ||
return React.cloneElement(as, { | ||
...resolvedProps, | ||
//@ts-ignore | ||
...as.props, | ||
}); | ||
const Icon: FC<IconProps> = ({ as, ...props }) => { | ||
const Comp = as; | ||
|
||
const { ...resolvedProps } = usePropsResolution('Icon', omit(props, 'as')); | ||
return <Comp {...resolvedProps} />; | ||
}; | ||
|
||
export default memo(Icon); |
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 |
---|---|---|
@@ -1,37 +1,24 @@ | ||
export interface IconProps { | ||
as?: any; | ||
/** | ||
* The viewBox of the icon. | ||
*/ | ||
// viewBox?: string; | ||
/** | ||
* The size of the icon. | ||
*/ | ||
size?: number; | ||
import { OpaqueColorValue, TextProps } from 'react-native'; | ||
|
||
export interface IconProps extends TextProps { | ||
as?: React.ReactNode | any; | ||
/** | ||
* The color of the icon. | ||
*/ | ||
// color?: string; | ||
color?: string; | ||
/** | ||
* Size of the icon, can also be passed as fontSize in the style object. | ||
* | ||
* @default 12 | ||
*/ | ||
// focusable?: boolean; | ||
/** | ||
* | ||
*/ | ||
children?: JSX.Element[] | JSX.Element; | ||
/** | ||
* | ||
*/ | ||
name?: string; | ||
size?: number; | ||
/** | ||
* Name of the icon to show | ||
* | ||
* See Icon Explorer app | ||
* {@link https://expo.github.io/vector-icons/} | ||
*/ | ||
// stroke?: string; | ||
name: string; | ||
/** | ||
* Color of the icon. Can be a string or OpaqueColorValue (returned from | ||
* PlatformColor(..)) | ||
* | ||
*/ | ||
// strokeWidth?: string; | ||
color?: string | OpaqueColorValue; | ||
} |
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 |
---|---|---|
@@ -1,74 +1,82 @@ | ||
/* eslint-disable prettier/prettier */ | ||
import { useContext } from 'react'; | ||
import { ThemeUiContext } from '../contexts/ThemeUiProvider'; | ||
import { omit, pick } from '../utils'; | ||
//test | ||
export function usePropsResolution( | ||
component: 'Box' | 'Text' | 'Button' | 'Icon' | 'Pressable', | ||
incomingProps: any, | ||
state?: any, | ||
_config?: { | ||
componentTheme?: any; | ||
resolveResponsively?: string[]; | ||
ignoreProps?: string[]; | ||
cascadePseudoProps?: boolean; | ||
extendTheme?: string[]; | ||
} | ||
component: 'Box' | 'Text' | 'Button' | 'Icon' | 'Pressable', | ||
incomingProps: any, | ||
state?: any, | ||
_config?: { | ||
componentTheme?: any; | ||
resolveResponsively?: string[]; | ||
ignoreProps?: string[]; | ||
cascadePseudoProps?: boolean; | ||
extendTheme?: string[]; | ||
} | ||
) { | ||
const { mode, colors } = useContext(ThemeUiContext); | ||
const { mode, colors } = useContext(ThemeUiContext); | ||
|
||
const optionalStyle = mode === 'light' ? incomingProps?._light : incomingProps?._dark; | ||
const style: any = colors[mode][component]; | ||
if (component === 'Icon') { | ||
return { | ||
...style, | ||
...optionalStyle, | ||
...incomingProps | ||
} | ||
} | ||
|
||
if (component === 'Button') { | ||
const btnStyles: string[] = [ | ||
'borderRadius', | ||
'backgroundColor', | ||
'borderColor', | ||
'borderWidth', | ||
'fontSize', | ||
'fontWeight', | ||
'fontFamily', | ||
'padding', | ||
'margin', | ||
'width', | ||
'height', | ||
'marginBottom', | ||
'marginTop', | ||
'marginLeft', | ||
'marginRight', | ||
'paddingBottom', | ||
'paddingTop', | ||
'paddingLeft', | ||
'paddingRight', | ||
'alignSelf', | ||
'alignItems', | ||
'justifyContent', | ||
'flexDirection', | ||
'flexGrow', | ||
'flexShrink', | ||
'flexWrap', | ||
'position', | ||
'top', | ||
'bottom', | ||
'left', | ||
'right', | ||
]; | ||
return { | ||
...omit(incomingProps, btnStyles), | ||
...optionalStyle, | ||
style: { ...incomingProps?.style, ...pick(incomingProps, ...btnStyles) }, | ||
...state, | ||
}; | ||
} | ||
|
||
const optionalStyle = | ||
mode === 'light' ? incomingProps?._light : incomingProps?._dark; | ||
const style: any = colors[mode][component]; | ||
if (component === 'Button') { | ||
const btnStyles: string[] = [ | ||
'borderRadius', | ||
'backgroundColor', | ||
'borderColor', | ||
'borderWidth', | ||
'fontSize', | ||
'fontWeight', | ||
'fontFamily', | ||
'padding', | ||
'margin', | ||
'width', | ||
'height', | ||
'marginBottom', | ||
'marginTop', | ||
'marginLeft', | ||
'marginRight', | ||
'paddingBottom', | ||
'paddingTop', | ||
'paddingLeft', | ||
'paddingRight', | ||
'alignSelf', | ||
'alignItems', | ||
'justifyContent', | ||
'flexDirection', | ||
'flexGrow', | ||
'flexShrink', | ||
'flexWrap', | ||
'position', | ||
'top', | ||
'bottom', | ||
'left', | ||
'right', | ||
]; | ||
return { | ||
...omit(incomingProps, btnStyles), | ||
...optionalStyle, | ||
style: { ...incomingProps?.style, ...pick(incomingProps, ...btnStyles) }, | ||
...state, | ||
...incomingProps, | ||
style: { | ||
...style, | ||
...optionalStyle, | ||
...incomingProps?.style, | ||
}, | ||
...state, | ||
}; | ||
} | ||
|
||
return { | ||
...incomingProps, | ||
style: { | ||
...style, | ||
...optionalStyle, | ||
...incomingProps?.style, | ||
}, | ||
...state, | ||
}; | ||
} | ||
// git commit -m "feat: new components added" |
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,21 @@ | ||
export interface GeneralStyles { | ||
rounded?: boolean; | ||
w?: number | string; | ||
h?: number | string; | ||
m?: number | string; | ||
mt?: number | string; | ||
mr?: number | string; | ||
mb?: number | string; | ||
ml?: number | string; | ||
mx?: number | string; | ||
my?: number | string; | ||
p?: number | string; | ||
pt?: number | string; | ||
pr?: number | string; | ||
pb?: number | string; | ||
pl?: number | string; | ||
px?: number | string; | ||
py?: number | string; | ||
bg?: string; | ||
bgColor?: string; | ||
} |
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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './PlatformProps'; | ||
export * from './ExtraProps'; | ||
export * from './GeneralStyles'; |