Skip to content

Commit bfd8981

Browse files
Merge pull request #53 from Strexas/main
Merge main into MDE/PKFE-16
2 parents 9f8baa2 + f55201a commit bfd8981

File tree

13 files changed

+264
-313
lines changed

13 files changed

+264
-313
lines changed

app/front-end/src/app/provider.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { BaseLayout } from '@/components/layouts/baseLayout';
21
import { SessionContextProvider, ThemeContextProvider } from '@/stores';
32
import { CircularProgress } from '@mui/material';
43
import React from 'react';
@@ -41,9 +40,7 @@ export const AppProvider = ({ children }: AppProviderProps) => {
4140
fallback={<CircularProgress sx={{ display: 'flex', justifyItems: 'center', alignContent: 'center' }} />}
4241
>
4342
<SessionContextProvider>
44-
<ThemeContextProvider>
45-
<BaseLayout>{children}</BaseLayout>
46-
</ThemeContextProvider>
43+
<ThemeContextProvider>{children}</ThemeContextProvider>
4744
</SessionContextProvider>
4845
</React.Suspense>
4946
);

app/front-end/src/app/router.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { BaseLayout } from '@/components/layouts/baseLayout';
12
import { Paths } from '@/types';
23
import { useMemo } from 'react';
34
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
@@ -32,14 +33,26 @@ export const AppRouter = () => {
3233
path: Paths.HOME,
3334
lazy: async () => {
3435
const { Home } = await import('./routes/home');
35-
return { Component: Home };
36+
return {
37+
Component: (props) => (
38+
<BaseLayout>
39+
<Home {...props} />
40+
</BaseLayout>
41+
),
42+
};
3643
},
3744
},
3845
{
3946
path: Paths.NOTFOUND,
4047
lazy: async () => {
4148
const { NotFound } = await import('./routes/notFound');
42-
return { Component: NotFound };
49+
return {
50+
Component: (props) => (
51+
<BaseLayout>
52+
<NotFound {...props} />
53+
</BaseLayout>
54+
),
55+
};
4356
},
4457
},
4558
]),

app/front-end/src/components/buttons/IconTitleButton.tsx

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Colors } from '@/types';
21
import { alpha, Box, IconButton, Typography, useTheme } from '@mui/material';
32

43
interface Props {
@@ -8,6 +7,8 @@ interface Props {
87
height?: string;
98
borderRadius?: string;
109
onClick?: () => void;
10+
isActive?: boolean;
11+
disabled?: boolean;
1112
}
1213

1314
/**
@@ -29,8 +30,18 @@ interface Props {
2930
*
3031
* @returns {JSX.Element} The `IconTitleButton` component rendering an icon button and an optional title.
3132
*/
32-
export const IconTitleButton: React.FC<Props> = ({ icon, title, width, height, borderRadius, onClick }) => {
33+
export const IconTitleButton: React.FC<Props> = ({
34+
icon,
35+
title,
36+
width,
37+
height,
38+
borderRadius,
39+
onClick,
40+
isActive = false,
41+
disabled = false,
42+
}) => {
3343
const Theme = useTheme();
44+
3445
return (
3546
<Box sx={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
3647
<IconButton
@@ -40,16 +51,34 @@ export const IconTitleButton: React.FC<Props> = ({ icon, title, width, height, b
4051
height: height || '3rem',
4152
borderRadius: borderRadius || '1rem',
4253
transition: 'background-color 0.5s ease',
54+
color: disabled ? alpha(Theme.palette.primary.contrastText, 0.4) : Theme.palette.primary.contrastText,
4355
':hover': {
44-
backgroundColor: alpha(Theme.palette.primary.contrastText, 0.2),
56+
backgroundColor: disabled
57+
? 'transparent'
58+
: isActive
59+
? alpha(Theme.palette.primary.contrastText, 0.3)
60+
: alpha(Theme.palette.primary.contrastText, 0.2),
4561
},
62+
backgroundColor: disabled
63+
? 'transparent'
64+
: isActive
65+
? alpha(Theme.palette.primary.contrastText, 0.3)
66+
: 'transparent',
4667
}}
47-
onClick={onClick}
68+
onClick={disabled ? () => {} : onClick}
4869
>
4970
{icon}
5071
</IconButton>
5172
{title && (
52-
<Typography sx={{ color: Colors.backgroundPrimaryLight, fontSize: '0.875rem', fontWeight: 'bold' }}>
73+
<Typography
74+
sx={{
75+
color: disabled ? alpha(Theme.palette.primary.contrastText, 0.4) : Theme.palette.primary.contrastText,
76+
fontSize: '0.875rem',
77+
fontWeight: 'bold',
78+
cursor: 'pointer',
79+
}}
80+
onClick={disabled ? () => {} : onClick}
81+
>
5382
{title}
5483
</Typography>
5584
)}

app/front-end/src/components/layouts/baseLayout.tsx

Lines changed: 9 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import { IconTitleButton } from '@/components/buttons/IconTitleButton';
21
import { SettingsDialog, ShortcutsDialog } from '@/components/dialogs';
2+
import { Sidebar } from '@/components/sidebar';
33
import { Colors } from '@/types';
4-
import {
5-
AutoMode as AutoModeIcon,
6-
Home as HomeIcon,
7-
SettingsOutlined as SettingsOutlinedIcon,
8-
SwitchAccessShortcut as SwitchAccessShortcutIcon,
9-
} from '@mui/icons-material';
104
import { Box, Typography, useTheme } from '@mui/material';
115
import { useState } from 'react';
126

@@ -33,12 +27,12 @@ interface Props {
3327
export const BaseLayout: React.FC<Props> = ({ children }) => {
3428
const Theme = useTheme();
3529

36-
const [isShortcutsMenuOpen, setIsShortcutsMenuOpen] = useState(false);
37-
const handleShortcutsMenuOpen = () => {
38-
setIsShortcutsMenuOpen(true);
30+
const [isShortcutsDialogOpen, setIsShortcutsDialogOpen] = useState(false);
31+
const handleShortcutsDialogOpen = () => {
32+
setIsShortcutsDialogOpen(true);
3933
};
40-
const handleShortcutsMenuClose = () => {
41-
setIsShortcutsMenuOpen(false);
34+
const handleShortcutsDialogClose = () => {
35+
setIsShortcutsDialogOpen(false);
4236
};
4337

4438
const [isSettingsDialogOpen, setIsSettingsDialogOpen] = useState(false);
@@ -115,56 +109,8 @@ export const BaseLayout: React.FC<Props> = ({ children }) => {
115109
flexDirection: 'row',
116110
}}
117111
>
118-
<Box sx={{ width: '5vw', height: '100%', display: 'flex', flexDirection: 'column' }}>
119-
<Box
120-
sx={{
121-
width: '100%',
122-
height: '50%',
123-
paddingTop: '0.625rem',
124-
display: 'flex',
125-
flexDirection: 'column',
126-
gap: '0.625rem',
127-
alignItems: 'center',
128-
}}
129-
>
130-
<IconTitleButton
131-
icon={<HomeIcon sx={{ width: '1.5rem', height: '1.5rem', color: Colors.backgroundPrimaryLight }} />}
132-
title={'Home'}
133-
/>
134-
<IconTitleButton
135-
icon={<AutoModeIcon sx={{ width: '1.5rem', height: '1.5rem', color: Colors.backgroundPrimaryLight }} />}
136-
title={'Macros'}
137-
/>
138-
</Box>
139-
<Box
140-
sx={{
141-
width: '100%',
142-
height: '50%',
143-
paddingBottom: '0.625rem',
144-
display: 'flex',
145-
flexDirection: 'column-reverse',
146-
gap: '0.625rem',
147-
alignItems: 'center',
148-
}}
149-
>
150-
<IconTitleButton
151-
icon={
152-
<SettingsOutlinedIcon
153-
sx={{ width: '1.5rem', height: '1.5rem', color: Colors.backgroundPrimaryLight }}
154-
/>
155-
}
156-
onClick={handleSettingsDialogOpen}
157-
/>
158-
<IconTitleButton
159-
icon={
160-
<SwitchAccessShortcutIcon
161-
sx={{ width: '1.5rem', height: '1.5rem', color: Colors.backgroundPrimaryLight }}
162-
/>
163-
}
164-
onClick={handleShortcutsMenuOpen}
165-
/>
166-
</Box>
167-
</Box>
112+
<Sidebar settingsDialogOpen={handleSettingsDialogOpen} shortcutsDialogOpen={handleShortcutsDialogOpen} />
113+
168114
<Box
169115
sx={{
170116
width: '95.75%',
@@ -176,7 +122,7 @@ export const BaseLayout: React.FC<Props> = ({ children }) => {
176122
{children}
177123
</Box>
178124
<SettingsDialog open={isSettingsDialogOpen} onClose={handleSettingsDialogClose} />
179-
<ShortcutsDialog open={isShortcutsMenuOpen} onClose={handleShortcutsMenuClose} />
125+
<ShortcutsDialog open={isShortcutsDialogOpen} onClose={handleShortcutsDialogClose} />
180126
</Box>
181127
</Box>
182128
);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { Sidebar } from './sidebar';
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { IconTitleButton } from '@/components/buttons/IconTitleButton';
2+
import { Paths } from '@/types';
3+
import {
4+
AutoMode as AutoModeIcon,
5+
Home as HomeIcon,
6+
SettingsOutlined as SettingsOutlinedIcon,
7+
SwitchAccessShortcut as SwitchAccessShortcutIcon,
8+
} from '@mui/icons-material';
9+
import { Box } from '@mui/material';
10+
import { useLocation, useNavigate } from 'react-router-dom';
11+
12+
interface SidebarProps {
13+
settingsDialogOpen: () => void;
14+
shortcutsDialogOpen: () => void;
15+
}
16+
17+
export const Sidebar: React.FC<SidebarProps> = ({ settingsDialogOpen, shortcutsDialogOpen }) => {
18+
const location = useLocation();
19+
const navigate = useNavigate();
20+
21+
return (
22+
<Box sx={{ width: '4.2vw', height: '100%', display: 'flex', flexDirection: 'column' }}>
23+
<Box
24+
sx={{
25+
width: '100%',
26+
height: '50%',
27+
paddingTop: '0.625rem',
28+
display: 'flex',
29+
flexDirection: 'column',
30+
gap: '0.625rem',
31+
alignItems: 'center',
32+
}}
33+
>
34+
<IconTitleButton
35+
icon={
36+
<HomeIcon
37+
sx={{
38+
width: '1.5rem',
39+
height: '1.5rem',
40+
}}
41+
/>
42+
}
43+
title={'Home'}
44+
isActive={location.pathname === Paths.HOME}
45+
onClick={() => navigate(Paths.HOME)}
46+
/>
47+
<IconTitleButton
48+
icon={
49+
<AutoModeIcon
50+
sx={{
51+
width: '1.5rem',
52+
height: '1.5rem',
53+
}}
54+
/>
55+
}
56+
title={'Macros'}
57+
isActive={location.pathname === Paths.MACROS}
58+
onClick={() => navigate(Paths.MACROS)}
59+
disabled
60+
/>
61+
</Box>
62+
<Box
63+
sx={{
64+
width: '100%',
65+
height: '50%',
66+
paddingBottom: '0.625rem',
67+
display: 'flex',
68+
flexDirection: 'column-reverse',
69+
gap: '0.625rem',
70+
alignItems: 'center',
71+
}}
72+
>
73+
<IconTitleButton
74+
icon={<SettingsOutlinedIcon sx={{ width: '1.5rem', height: '1.5rem' }} />}
75+
onClick={settingsDialogOpen}
76+
/>
77+
<IconTitleButton
78+
icon={<SwitchAccessShortcutIcon sx={{ width: '1.5rem', height: '1.5rem' }} />}
79+
onClick={shortcutsDialogOpen}
80+
/>
81+
</Box>
82+
</Box>
83+
);
84+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Deblur as DeblurIcon } from '@mui/icons-material';
2+
3+
import { ToolbarGroupItemProps } from '@/features/editor/components/toolbarView';
4+
5+
const applySpliceAiClick = () => {
6+
console.log('Clicked Apply SpliceAI Button!');
7+
};
8+
9+
const applyCaddClick = () => {
10+
console.log('Clicked Apply CADD Button!');
11+
};
12+
13+
export const ApplyGroupButtons: ToolbarGroupItemProps[] = [
14+
{
15+
group: 'apply',
16+
icon: DeblurIcon,
17+
label: 'Apply SpliceAI',
18+
onClick: applySpliceAiClick,
19+
},
20+
{
21+
group: 'apply',
22+
icon: DeblurIcon,
23+
label: 'Apply CADD',
24+
onClick: applyCaddClick,
25+
},
26+
];
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { ToolbarGroupItemProps } from '@/features/editor/components/toolbarView';
2+
3+
import { Download as DownloadIcon } from '@mui/icons-material';
4+
5+
const handleDownloadLovdClick = () => {
6+
console.log('Clicked Download Lovd Button!');
7+
};
8+
9+
const handleDownloadClinvarClick = () => {
10+
console.log('Clicked Download Clinvar Button!');
11+
};
12+
13+
const handleDownloadGnomadClick = () => {
14+
console.log('Clicked Download Gnomad Button!');
15+
};
16+
17+
export const DownloadGroupButtons: ToolbarGroupItemProps[] = [
18+
{
19+
group: 'download',
20+
icon: DownloadIcon,
21+
label: 'LOVD',
22+
onClick: handleDownloadLovdClick,
23+
},
24+
{
25+
group: 'download',
26+
icon: DownloadIcon,
27+
label: 'ClinVar',
28+
onClick: handleDownloadClinvarClick,
29+
},
30+
{
31+
group: 'download',
32+
icon: DownloadIcon,
33+
label: 'gnomAD',
34+
onClick: handleDownloadGnomadClick,
35+
},
36+
];
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { ApplyGroupButtons } from './applyGroupButtons';
2+
export { DownloadGroupButtons } from './downloadGroupButtons';
3+
export { MergeGroupButtons } from './mergeGroupButtons';

0 commit comments

Comments
 (0)