-
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.
Merge pull request #11 from guicoelhodev/develop
Fix chat style errors and increase user experience in mobile devices
- Loading branch information
Showing
11 changed files
with
160 additions
and
31 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
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
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,13 +1,37 @@ | ||
import { FC, ReactNode } from 'react'; | ||
import React, { ReactNode } from 'react'; | ||
import { ThemeContextProvider } from './theme'; | ||
import { UserActionsProvider } from './userActions'; | ||
interface MultiProviderProps { | ||
children: ReactNode; | ||
} | ||
|
||
const providers = [ThemeContextProvider, UserActionsProvider]; | ||
|
||
interface IGlobalContext { | ||
export const MultiProvider: React.FC<MultiProviderProps> = ({ children }) => ( | ||
<> | ||
{providers.reduceRight((acc, Comp) => { | ||
return <Comp>{acc}</Comp>; | ||
}, children)} | ||
</> | ||
); | ||
|
||
/* | ||
If you want to add provider by props: | ||
interface MultiProviderProps { | ||
providers: Array<React.JSXElementConstructor<React.PropsWithChildren<unknown>> | ||
>; | ||
children: ReactNode; | ||
} | ||
export const GlobalProvider: FC<IGlobalContext> = ({ children }) => { | ||
return ( | ||
<> | ||
<ThemeContextProvider>{children}</ThemeContextProvider> | ||
</> | ||
); | ||
}; | ||
export const MultiProvider: React.FC<MultiProviderProps> = ({ | ||
providers = [], | ||
children, | ||
}) => ( | ||
<> | ||
{providers.reduceRight((acc, Comp) => { | ||
return <Comp>{acc}</Comp>; | ||
}, children)} | ||
</> | ||
); | ||
*/ |
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,37 @@ | ||
import { createContext, FC, ReactNode, useReducer } from 'react'; | ||
import { globalComponentsReducer } from 'src/reducers/globalComponentsReducer/reducer'; | ||
|
||
export type IGlobalComponents = { | ||
chat: boolean; | ||
createPost: boolean; | ||
addFriend: boolean; | ||
}; | ||
type IUserActionsContext = { | ||
globalComponentsState: any; | ||
dispatchGlobalComponents: any; | ||
}; | ||
|
||
interface IUserActionsProvider { | ||
children: ReactNode; | ||
} | ||
|
||
export const UserActionsContext = createContext<IUserActionsContext>(null!); | ||
|
||
export const UserActionsProvider: FC<IUserActionsProvider> = ({ children }) => { | ||
const [globalComponentsState, dispatchGlobalComponents] = useReducer<any>( | ||
globalComponentsReducer, | ||
{ | ||
addFriend: false, | ||
chat: false, | ||
createPost: false, | ||
} | ||
); | ||
|
||
return ( | ||
<UserActionsContext.Provider | ||
value={{ globalComponentsState, dispatchGlobalComponents }} | ||
> | ||
{children} | ||
</UserActionsContext.Provider> | ||
); | ||
}; |
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,17 @@ | ||
export enum ActionsGlobalComponents { | ||
HANDLE_CHAT_STATE = 'HANDLE_CHAT_STATE', | ||
HANDLE_CREATE_POST = 'HANDLE_CREATE_POST', | ||
HANDLE_ADD_FRIEND = 'HANDLE_ADD_FRIEND', | ||
} | ||
|
||
export const handleChatState = () => { | ||
return { type: ActionsGlobalComponents.HANDLE_CHAT_STATE }; | ||
}; | ||
|
||
export const handleCreatPostState = () => { | ||
return { type: ActionsGlobalComponents.HANDLE_CREATE_POST }; | ||
}; | ||
|
||
export const handleAddFriend = () => { | ||
return { type: ActionsGlobalComponents.HANDLE_ADD_FRIEND }; | ||
}; |
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 @@ | ||
import { IGlobalComponents } from '@context/userActions'; | ||
import { ActionsGlobalComponents } from './actions'; | ||
|
||
export const globalComponentsReducer = ( | ||
state: IGlobalComponents, | ||
action: { type: string } | ||
) => { | ||
switch (action.type) { | ||
case ActionsGlobalComponents.HANDLE_CHAT_STATE: { | ||
return { ...state, chat: !state.chat }; | ||
} | ||
case ActionsGlobalComponents.HANDLE_CREATE_POST: { | ||
return { ...state, createPost: !state.createPost }; | ||
} | ||
case ActionsGlobalComponents.HANDLE_ADD_FRIEND: { | ||
return { ...state, addFriend: !state.addFriend }; | ||
} | ||
default: | ||
state; | ||
} | ||
}; |
3777ba7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
social-dev – ./
social-dev-git-main-guicoelho-s.vercel.app
social-dev-guicoelho-s.vercel.app
social-dev-sandy.vercel.app