Skip to content

Commit

Permalink
Merge pull request #133 from Descendre/feature/#132
Browse files Browse the repository at this point in the history
add: custom modal added
  • Loading branch information
Hinata0607 authored Sep 1, 2024
2 parents 5325202 + 15e30f7 commit 3a6388a
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/hooks/context/useLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export const useLayout = (): UseLayoutProps => {
setIsLeftDrawer,
isLogSelect,
setIsLogSelect,
isCustomModal,
setIsCustomModal,
} = context;

const handleCharacterSelect = ({
Expand Down Expand Up @@ -73,5 +75,7 @@ export const useLayout = (): UseLayoutProps => {
setIsLogSelect,
handleCharacterSelect,
handleLogSelect,
isCustomModal,
setIsCustomModal,
};
};
2 changes: 2 additions & 0 deletions src/interfaces/hooks/UseLayoutProps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export interface UseLayoutProps {
setIsLogSelect: React.Dispatch<React.SetStateAction<boolean>>;
handleCharacterSelect: ({ uuid }: HandleCharacterSelectProps) => void;
handleLogSelect: ({ chatRoomId }: HandleLogSelectProps) => void;
isCustomModal: boolean;
setIsCustomModal: React.Dispatch<React.SetStateAction<boolean>>;
}

export interface HandleCharacterSelectProps {
Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/provider/ContextProviderProps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export interface ContextProviderProps {
setChat: React.Dispatch<
React.SetStateAction<{ [uuid: string]: ChatsResponse }>
>;
isCustomModal: boolean;
setIsCustomModal: React.Dispatch<React.SetStateAction<boolean>>;
}

export type SelectedContentProps = 'noSelected' | 'character' | 'log' | 'call';
Expand Down
9 changes: 8 additions & 1 deletion src/layouts/mainLayout/MainLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
'use client';
import { MainLayoutProps } from '@/interfaces';
import { MainFooter, MainHeader, MainLeftBar, MainLeftDrawer } from './block';
import {
MainCustomModal,
MainFooter,
MainHeader,
MainLeftBar,
MainLeftDrawer,
} from './block';
import { Box } from '@mui/material';
import { useBreakPoint, useLayout } from '@/hooks';

Expand Down Expand Up @@ -38,6 +44,7 @@ export const MainLayout = ({ children }: MainLayoutProps) => {
</Box>

{['xs', 'sm'].includes(breakpoint) && <MainLeftDrawer />}
<MainCustomModal />
</>
);
};
17 changes: 14 additions & 3 deletions src/layouts/mainLayout/atom/MainHeaderCommandsRight.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use client';
import { useCall, useLayout, usePalette } from '@/hooks';
import { Call, CallEnd } from '@mui/icons-material';
import { Call, CallEnd, Settings } from '@mui/icons-material';
import { Box, Tooltip } from '@mui/material';

export const MainHeaderCommandsRight = () => {
const { selectedContent } = useLayout();
const { selectedContent, setIsCustomModal } = useLayout();
const { handleNewCallStart, handleCallStart, handleCallEnd } = useCall();
const palette = usePalette();
const iconDisabled: boolean = !['character', 'log', 'call'].includes(
Expand All @@ -16,9 +16,20 @@ export const MainHeaderCommandsRight = () => {
display="flex"
justifyContent="center"
alignItems="center"
gap="10px"
gap="15px"
height="100%"
>
<Tooltip placement="bottom" title="カスタマイズ">
<span>
<Settings
onClick={() => setIsCustomModal((prev) => !prev)}
sx={{
cursor: 'pointer',
}}
/>
</span>
</Tooltip>

{selectedContent === 'call' ? (
<Tooltip title="通話を終了" placement="bottom">
<span>
Expand Down
38 changes: 38 additions & 0 deletions src/layouts/mainLayout/block/MainCustomModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use client';
import { useBreakPoint, useLayout, usePalette } from '@/hooks';
import { Grow, Modal, Paper } from '@mui/material';

export const MainCustomModal = () => {
const breakpoint = useBreakPoint();
const palette = usePalette();
const { isCustomModal, setIsCustomModal } = useLayout();

return (
<Modal
open={isCustomModal}
onClose={() => setIsCustomModal(false)}
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: ['xs', 'sm'].includes(breakpoint) ? 'center' : 'start',
}}
>
<Grow in={isCustomModal} timeout={200}>
<Paper
sx={{
position: 'relative',
backgroundColor: palette.layout.mainLayout.customModal.bg,
width: ['xs', 'sm'].includes(breakpoint) ? '100vw' : '800px',
height: ['xs', 'sm'].includes(breakpoint)
? '100vh'
: 'calc(100vh - 90px)',
maxHeight: '800px',
marginTop: ['xs', 'sm'].includes(breakpoint) ? '0px' : '60px',
borderRadius: ['xs', 'sm'].includes(breakpoint) ? '0px' : '0px',
overflow: 'hidden',
}}
></Paper>
</Grow>
</Modal>
);
};
1 change: 1 addition & 0 deletions src/layouts/mainLayout/block/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './MainHeader';
export * from './MainLeftDrawer';
export * from './MainFooter';
export * from './MainLeftBar';
export * from './MainCustomModal';
3 changes: 3 additions & 0 deletions src/provider/ContextProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export const ContextProvider = ({ children }: { children: ReactNode }) => {
);
const [isSending, setIsSending] = useState<boolean>(false);
const [chat, setChat] = useState<{ [uuid: string]: ChatsResponse }>({});
const [isCustomModal, setIsCustomModal] = useState<boolean>(false);

const contextValue = {
characters,
Expand All @@ -58,6 +59,8 @@ export const ContextProvider = ({ children }: { children: ReactNode }) => {
setIsSending,
chat,
setChat,
isCustomModal,
setIsCustomModal,
};

return <Context.Provider value={contextValue}>{children}</Context.Provider>;
Expand Down
3 changes: 3 additions & 0 deletions src/themes/darkTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const darkTheme = createTheme({
footer: {
inputBar: '#161f28',
},
customModal: {
bg: '#0d1318',
},
line: {
main: '#525f6c',
sub: '#283848',
Expand Down
6 changes: 6 additions & 0 deletions src/themes/extendedThemeProps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ declare module '@mui/material/styles' {
footer: {
inputBar: string;
};
customModal: {
bg: string;
};
line: {
main: string;
sub: string;
Expand Down Expand Up @@ -58,6 +61,9 @@ declare module '@mui/material/styles' {
footer: {
inputBar: string;
};
customModal: {
bg: string;
};
line: {
main: string;
sub: string;
Expand Down

0 comments on commit 3a6388a

Please sign in to comment.