-
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
committed
Aug 3, 2023
1 parent
7dae484
commit 62dc98a
Showing
25 changed files
with
260 additions
and
298 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { FC } from 'react'; | ||
|
||
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); | ||
|
||
if (props.safeArea) { | ||
return ( | ||
<SafeAreaView {...resolvedProps}>{children}</SafeAreaView> | ||
) | ||
} | ||
|
||
return ( | ||
<View {...resolvedProps} > | ||
{children} | ||
</View> | ||
) | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { PseudoComponentProps } from '../../contexts/theme'; | ||
import type { ViewProps } from 'react-native'; | ||
|
||
|
||
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { View } from "react-native" | ||
import { usePropsResolution } from "../../hooks/usePropsResolution" | ||
import { ButtonProps } from './types'; | ||
|
||
|
||
const Button: FC<ButtonProps> = ({ children, ...props }) => { | ||
const { ...resolvedProps } = usePropsResolution('Button', props); | ||
|
||
return ( | ||
<View {...resolvedProps} > | ||
{children} | ||
</View> | ||
) | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { PseudoComponentProps } from '../../contexts/theme'; | ||
import type { ViewProps } from 'react-native'; | ||
|
||
|
||
export interface ButtonProps extends ViewProps, 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { FC } from 'react'; | ||
|
||
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); | ||
|
||
return ( | ||
<TxtComp {...resolvedProps} > | ||
{children} | ||
</TxtComp> | ||
) | ||
} | ||
|
||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { PseudoComponentProps } from '../../contexts/theme'; | ||
import type { TextProps as TextCompProps } from 'react-native'; | ||
|
||
|
||
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import Box from "./Box"; | ||
import Text from "./Text"; | ||
|
||
export { | ||
Box, | ||
Text | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
import React, { FC, ReactNode, useState, createContext } from "react"; | ||
import defaultTheme, { ThemeUiTypes, ThemeActionTypes } from "./theme"; | ||
|
||
interface ThemeUiProviderProps { | ||
children: ReactNode | ||
mode?: 'light' | 'dark' | ||
} | ||
|
||
|
||
const ThemeUiContext = createContext<ThemeUiTypes>(defaultTheme); | ||
const ThemeUiActionContext = createContext<ThemeActionTypes>({ | ||
setThemeMode: () => { } | ||
}); | ||
|
||
const ThemeUiProvider: FC<ThemeUiProviderProps> = ({ children, mode = "light" }) => { | ||
const [theme, setTheme] = useState<ThemeUiTypes>({ ...defaultTheme, mode }); | ||
|
||
const setThemeMode = (mode: 'light' | 'dark' = 'light') => setTheme({ ...theme, mode }); | ||
|
||
return ( | ||
<ThemeUiContext.Provider value={theme}> | ||
<ThemeUiActionContext.Provider value={{ setThemeMode }}> | ||
{children} | ||
</ThemeUiActionContext.Provider> | ||
</ThemeUiContext.Provider> | ||
) | ||
} | ||
|
||
export { ThemeUiContext, ThemeUiActionContext } | ||
export default ThemeUiProvider; |
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,96 @@ | ||
import { ButtonProps } from "../components/Button/types"; | ||
|
||
export interface PseudoComponentProps<T> { | ||
_light?: T | ||
_dark?: T | ||
} | ||
|
||
interface ThemeUiTypes { | ||
mode: 'light' | 'dark'; | ||
colors: { | ||
light: { | ||
Box: BoxProps['style'] | ||
Text: TextProps['style'] | ||
Button: ButtonProps['style'] | ||
}, | ||
dark: { | ||
Box: BoxProps['style'] | ||
Text: TextProps['style'] | ||
Button: ButtonProps['style'] | ||
} | ||
} | ||
components: { | ||
Button: {} | ||
Box: {}, | ||
Text: { | ||
style: { | ||
color: string; | ||
} | ||
} | ||
} | ||
} | ||
|
||
export const colors: { light: any, dark: any } = { | ||
light: { | ||
Box: { | ||
backgroundColor: 'white', | ||
}, | ||
Text: { | ||
color: "black" | ||
}, | ||
Button: { | ||
backgroundColor: 'blue' | ||
} | ||
}, | ||
dark: { | ||
Box: { | ||
backgroundColor: 'black', | ||
}, | ||
Text: { | ||
color: "white" | ||
}, | ||
Button: { | ||
backgroundColor: 'blue' | ||
} | ||
} | ||
} | ||
const theme: ThemeUiTypes = { | ||
mode: 'light', | ||
colors: colors, | ||
components: { | ||
Box: { | ||
backgroundColor: 'red', | ||
}, | ||
Text: { | ||
style: { | ||
color: "white" | ||
} | ||
}, | ||
Button: { | ||
style: { | ||
backgroundColor: 'blue' | ||
} | ||
} | ||
} | ||
}; | ||
|
||
|
||
|
||
interface ThemeActionTypes { | ||
setThemeMode: (mode: 'light' | 'dark') => void; | ||
} | ||
|
||
|
||
export interface BoxProps { | ||
style?: { | ||
backgroundColor?: string; | ||
} | ||
} | ||
export interface TextProps { | ||
style?: { | ||
color?: string; | ||
} | ||
} | ||
|
||
export { ThemeUiTypes, ThemeActionTypes }; | ||
export default theme; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.