-
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 3, 2023
1 parent
4ab033b
commit dedbf8e
Showing
15 changed files
with
189 additions
and
160 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,18 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { View } from "react-native" | ||
import { usePropsResolution } from "../../hooks/usePropsResolution" | ||
import { View } from 'react-native'; | ||
import { usePropsResolution } from '../../hooks/usePropsResolution'; | ||
import { BoxProps } from './types'; | ||
import { SafeAreaView } from 'react-native-safe-area-context'; | ||
|
||
|
||
const Box: FC<BoxProps> = ({ children, ...props }) => { | ||
const { ...resolvedProps } = usePropsResolution('Box', props); | ||
const { ...resolvedProps } = usePropsResolution('Box', props); | ||
|
||
if (props.safeArea) { | ||
return ( | ||
<SafeAreaView {...resolvedProps}>{children}</SafeAreaView> | ||
) | ||
} | ||
if (props.safeArea) { | ||
return <SafeAreaView {...resolvedProps}>{children}</SafeAreaView>; | ||
} | ||
|
||
return ( | ||
<View {...resolvedProps} > | ||
{children} | ||
</View> | ||
) | ||
} | ||
return <View {...resolvedProps}>{children}</View>; | ||
}; | ||
|
||
export default Box | ||
export default Box; |
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,7 +1,8 @@ | ||
import { PseudoComponentProps } from '../../contexts/theme'; | ||
import type { ViewProps } from 'react-native'; | ||
|
||
|
||
export interface BoxProps extends ViewProps, PseudoComponentProps<ViewProps["style"]> { | ||
safeArea?: boolean | ||
} | ||
export interface BoxProps | ||
extends ViewProps, | ||
PseudoComponentProps<ViewProps['style']> { | ||
safeArea?: boolean; | ||
} |
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,18 +1,13 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { View } from "react-native" | ||
import { usePropsResolution } from "../../hooks/usePropsResolution" | ||
import { Button as BtnComp } from 'react-native'; | ||
import { usePropsResolution } from '../../hooks/usePropsResolution'; | ||
import { ButtonProps } from './types'; | ||
|
||
|
||
const Button: FC<ButtonProps> = ({ children, ...props }) => { | ||
const { ...resolvedProps } = usePropsResolution('Button', props); | ||
const { ...resolvedProps } = usePropsResolution('Button', props); | ||
|
||
return ( | ||
<View {...resolvedProps} > | ||
{children} | ||
</View> | ||
) | ||
} | ||
return <BtnComp {...resolvedProps}>{children}</BtnComp>; | ||
}; | ||
|
||
export default Button | ||
export default Button; |
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,7 +1,4 @@ | ||
import { PseudoComponentProps } from '../../contexts/theme'; | ||
import type { ViewProps } from 'react-native'; | ||
import type { ButtonProps as BtnProps } from 'react-native'; | ||
import { PseudoComponentProps } from 'src/contexts/theme'; | ||
|
||
|
||
export interface ButtonProps extends ViewProps, PseudoComponentProps<ViewProps["style"]> { | ||
|
||
} | ||
export interface ButtonProps extends BtnProps, PseudoComponentProps<BtnProps> {} |
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,13 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { View } from 'react-native'; | ||
import { usePropsResolution } from '../../hooks/usePropsResolution'; | ||
import { IconProps } from './types'; | ||
|
||
const Icon: FC<IconProps> = ({ children, as, name, ...props }) => { | ||
console.log({ as, name }); | ||
const { ...resolvedProps } = usePropsResolution('Button', props); | ||
return <View {...resolvedProps}>{children}</View>; | ||
}; | ||
|
||
export default 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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { PseudoComponentProps } from '../../contexts/theme'; | ||
import type { ViewProps } from 'react-native'; | ||
|
||
export interface IconProps | ||
extends ViewProps, | ||
PseudoComponentProps<ViewProps['style']> { | ||
as: React.ReactNode; | ||
name: 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,18 +1,13 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { Text as TxtComp } from "react-native" | ||
import { usePropsResolution } from "../../hooks/usePropsResolution" | ||
import { Text as TxtComp } from 'react-native'; | ||
import { usePropsResolution } from '../../hooks/usePropsResolution'; | ||
import { TextProps } from './types'; | ||
|
||
|
||
const Text: FC<TextProps> = ({ children, ...props }) => { | ||
const { ...resolvedProps } = usePropsResolution('Text', props); | ||
const { ...resolvedProps } = usePropsResolution('Text', props); | ||
|
||
return ( | ||
<TxtComp {...resolvedProps} > | ||
{children} | ||
</TxtComp> | ||
) | ||
} | ||
return <TxtComp {...resolvedProps}>{children}</TxtComp>; | ||
}; | ||
|
||
export default Text | ||
export default Text; |
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,7 +1,6 @@ | ||
import { PseudoComponentProps } from '../../contexts/theme'; | ||
import type { TextProps as TextCompProps } from 'react-native'; | ||
|
||
|
||
export interface TextProps extends TextCompProps, PseudoComponentProps<TextCompProps["style"]> { | ||
|
||
} | ||
export interface TextProps | ||
extends TextCompProps, | ||
PseudoComponentProps<TextCompProps['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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import Box from "./Box"; | ||
import Text from "./Text"; | ||
import Box from './Box'; | ||
import Button from './Button'; | ||
import Text from './Text'; | ||
|
||
export { | ||
Box, | ||
Text | ||
} | ||
export { Box, Text, Button }; |
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,31 +1,34 @@ | ||
import React, { FC, ReactNode, useState, createContext } from "react"; | ||
import defaultTheme, { ThemeUiTypes, ThemeActionTypes } from "./theme"; | ||
import React, { FC, ReactNode, useState, createContext } from 'react'; | ||
import defaultTheme, { ThemeUiTypes, ThemeActionTypes } from './theme'; | ||
|
||
interface ThemeUiProviderProps { | ||
children: ReactNode | ||
mode?: 'light' | 'dark' | ||
children: ReactNode; | ||
mode?: 'light' | 'dark'; | ||
} | ||
|
||
|
||
const ThemeUiContext = createContext<ThemeUiTypes>(defaultTheme); | ||
const ThemeUiActionContext = createContext<ThemeActionTypes>({ | ||
setThemeMode: () => { } | ||
setThemeMode: () => {}, | ||
}); | ||
|
||
const ThemeUiProvider: FC<ThemeUiProviderProps> = ({ mode = "light", children }) => { | ||
defaultTheme.mode = mode; | ||
const [theme, setTheme] = useState<ThemeUiTypes>(defaultTheme); | ||
const ThemeUiProvider: FC<ThemeUiProviderProps> = ({ | ||
mode = 'light', | ||
children, | ||
}) => { | ||
defaultTheme.mode = mode; | ||
const [theme, setTheme] = useState<ThemeUiTypes>(defaultTheme); | ||
|
||
const setThemeMode = (mode: 'light' | 'dark' = 'light') => setTheme({ ...theme, mode }); | ||
const setThemeMode = (mode: 'light' | 'dark' = 'light') => | ||
setTheme({ ...theme, mode }); | ||
|
||
return ( | ||
<ThemeUiContext.Provider value={theme}> | ||
<ThemeUiActionContext.Provider value={{ setThemeMode }}> | ||
{children} | ||
</ThemeUiActionContext.Provider> | ||
</ThemeUiContext.Provider> | ||
) | ||
} | ||
return ( | ||
<ThemeUiContext.Provider value={theme}> | ||
<ThemeUiActionContext.Provider value={{ setThemeMode }}> | ||
{children} | ||
</ThemeUiActionContext.Provider> | ||
</ThemeUiContext.Provider> | ||
); | ||
}; | ||
|
||
export { ThemeUiContext, ThemeUiActionContext } | ||
export default ThemeUiProvider; | ||
export { ThemeUiContext, ThemeUiActionContext }; | ||
export default ThemeUiProvider; |
Oops, something went wrong.