Skip to content

Commit

Permalink
Small fixes to menus
Browse files Browse the repository at this point in the history
  • Loading branch information
pauljonescodes committed Feb 19, 2024
1 parent 16fa71d commit 5c0e8c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 133 deletions.
137 changes: 5 additions & 132 deletions src/main/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class MenuBuilder {
const template =
process.platform === 'darwin'

Check failure on line 30 in src/main/menu.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

Replace `⏎········?·this.buildDarwinTemplate()⏎·······` with `·?·this.buildDarwinTemplate()`
? this.buildDarwinTemplate()
: this.buildDefaultTemplate();
: [];

const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
Expand All @@ -54,17 +54,17 @@ export default class MenuBuilder {

buildDarwinTemplate(): MenuItemConstructorOptions[] {
const subMenuAbout: DarwinMenuItemConstructorOptions = {
label: 'Electron',
label: 'Nutrition Planner',
submenu: [
{
label: 'About ElectronReact',
label: 'About Nutrition Planner',
selector: 'orderFrontStandardAboutPanel:',
},
{ type: 'separator' },
{ label: 'Services', submenu: [] },
{ type: 'separator' },
{
label: 'Hide ElectronReact',
label: 'Hide Nutrition Planner',
accelerator: 'Command+H',
selector: 'hide:',
},
Expand Down Expand Up @@ -151,140 +151,13 @@ export default class MenuBuilder {
{ label: 'Bring All to Front', selector: 'arrangeInFront:' },
],
};
const subMenuHelp: MenuItemConstructorOptions = {
label: 'Help',
submenu: [
{
label: 'Learn More',
click() {
shell.openExternal('https://electronjs.org');
},
},
{
label: 'Documentation',
click() {
shell.openExternal(
'https://github.com/electron/electron/tree/main/docs#readme',
);
},
},
{
label: 'Community Discussions',
click() {
shell.openExternal('https://www.electronjs.org/community');
},
},
{
label: 'Search Issues',
click() {
shell.openExternal('https://github.com/electron/electron/issues');
},
},
],
};

const subMenuView =
process.env.NODE_ENV === 'development' ||
process.env.DEBUG_PROD === 'true'
? subMenuViewDev
: subMenuViewProd;

return [subMenuAbout, subMenuEdit, subMenuView, subMenuWindow, subMenuHelp];
}

buildDefaultTemplate() {
const templateDefault = [
{
label: '&File',
submenu: [
{
label: '&Open',
accelerator: 'Ctrl+O',
},
{
label: '&Close',
accelerator: 'Ctrl+W',
click: () => {
this.mainWindow.close();
},
},
],
},
{
label: '&View',
submenu:
process.env.NODE_ENV === 'development' ||
process.env.DEBUG_PROD === 'true'
? [
{
label: '&Reload',
accelerator: 'Ctrl+R',
click: () => {
this.mainWindow.webContents.reload();
},
},
{
label: 'Toggle &Full Screen',
accelerator: 'F11',
click: () => {
this.mainWindow.setFullScreen(
!this.mainWindow.isFullScreen(),
);
},
},
{
label: 'Toggle &Developer Tools',
accelerator: 'Alt+Ctrl+I',
click: () => {
this.mainWindow.webContents.toggleDevTools();
},
},
]
: [
{
label: 'Toggle &Full Screen',
accelerator: 'F11',
click: () => {
this.mainWindow.setFullScreen(
!this.mainWindow.isFullScreen(),
);
},
},
],
},
{
label: 'Help',
submenu: [
{
label: 'Learn More',
click() {
shell.openExternal('https://electronjs.org');
},
},
{
label: 'Documentation',
click() {
shell.openExternal(
'https://github.com/electron/electron/tree/main/docs#readme',
);
},
},
{
label: 'Community Discussions',
click() {
shell.openExternal('https://www.electronjs.org/community');
},
},
{
label: 'Search Issues',
click() {
shell.openExternal('https://github.com/electron/electron/issues');
},
},
],
},
];

return templateDefault;
return [subMenuAbout, subMenuEdit, subMenuView, subMenuWindow];
}
}
3 changes: 2 additions & 1 deletion src/renderer/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import GroupsPage from './pages/groups';
import ItemsPage from './pages/items';

Check failure on line 3 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

`./pages/items` import should occur after import of `@chakra-ui/react`
import PlansPage from './pages/plans';

Check failure on line 4 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

`./pages/plans` import should occur after import of `@chakra-ui/react`
import LogPage from './pages';

Check failure on line 5 in src/renderer/App.tsx

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

`./pages` import should occur after import of `@chakra-ui/react`

import { Provider as RxDbProvider } from 'rxdb-hooks';
import { useState, useEffect } from 'react';
import { addRxPlugin } from 'rxdb';
Expand All @@ -19,6 +18,7 @@ import {
VStack,
extendTheme,
type ThemeConfig,
ColorModeScript,
} from '@chakra-ui/react';
import '../../styles/style.scss';
import '../../styles/react-big-calendar.scss';
Expand Down Expand Up @@ -68,6 +68,7 @@ export default function App() {
return (
<Router>
<RxDbProvider db={database}>
<ColorModeScript initialColorMode={theme.config.initialColorMode} />
<ChakraProvider theme={theme}>
<VStack spacing={0} align="stretch" minH="100vh">
<MenuHStack />
Expand Down

0 comments on commit 5c0e8c1

Please sign in to comment.