Skip to content

Commit

Permalink
Added a proper icon and coloring for pomodoro attribute, enhanced don…
Browse files Browse the repository at this point in the history
…e file locator in context menu, slight visual enhancements on auto-suggest container, improved window size and positioning
  • Loading branch information
ransome1 committed Sep 25, 2023
1 parent ce96a2d commit 6c088aa
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 46 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Build & release
name: Prepare release
on:
push:
tags:
- '*'
jobs:
macos:
name: MacOS (Build & Release)
name: MacOS (Prepare release)
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
github_token: ${{ secrets.github_token }}
release: ${{ startsWith(github.ref, 'refs/tags/') }}
windows:
name: Windows (Build & Release)
name: Windows (Prepare release)
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -60,7 +60,7 @@ jobs:
github_token: ${{ secrets.github_token }}
release: ${{ startsWith(github.ref, 'refs/tags/') }}
linux:
name: Linux (Build & Release)
name: Linux (Prepare release)
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down
3 changes: 3 additions & 0 deletions assets/icons/tomato-duo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "cross-env NODE_ENV=development eslint . --ext .js,.jsx,.ts,.tsx",
"package": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build --publish never",
"mas": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build -m mas --universal --publish never",
"appimage": "ts-node ./.erb/scripts/clean.js dist && npm run build && electron-builder build -l appimage --universal --publish never",
"peggy": "peggy --format es --output ./src/main/modules/FilterLang/FilterLang.js ./src/main/modules/FilterLang/FilterLang.pegjs",
"rebuild": "electron-rebuild --parallel --types prod,dev,optional --module-dir release/app",
"start": "ts-node ./.erb/scripts/check-port-in-use.js && npm run start:renderer",
Expand Down Expand Up @@ -175,7 +176,7 @@
"x64"
]
},
"icon": "assets/icons/icon.icns",
"icon": "assets/icons/512x512.png",
"type": "distribution",
"hardenedRuntime": true,
"entitlements": "assets/mas/entitlements.mac.plist",
Expand Down
47 changes: 28 additions & 19 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,22 @@ const handleClosed = () => {
}

const handleResize = () => {
if (!windowMaximized && mainWindow) {
if (mainWindow) {
const { width, height } = mainWindow.getBounds();
configStorage.set('windowDimensions', { width, height });
}
}

const handleMove = () => {
if (!windowMaximized && mainWindow) {
if (mainWindow) {
const { x, y } = mainWindow.getBounds();
configStorage.set('windowPosition', { x, y });
}
}

const handleUnmaximize = () => {
configStorage.set('windowMaximized', false)
configStorage.set('windowMaximized', false);
handleWindowSizeAndPosition();
}

const handleMaximize = () => {
Expand All @@ -66,6 +67,29 @@ const handleShow = () => {
}
}

const handleWindowSizeAndPosition = () => {
const isMaximized = configStorage.get('windowMaximized');
if(isMaximized) {
mainWindow.maximize();
return false;
}

const windowDimensions: { width: number; height: number } | null = configStorage.get('windowDimensions') as { width: number; height: number } | null;

console.log(windowDimensions)

if (windowDimensions) {
const { width, height } = windowDimensions;
mainWindow.setSize(width, height);

const windowPosition: { x: number; y: number } | null = configStorage.get('windowPosition') as { x: number; y: number } | null;
if (windowPosition) {
const { x, y } = windowPosition;
mainWindow.setPosition(x, y);
}
}
};

const createWindow = async() => {
mainWindow = new BrowserWindow({
width: 1280,
Expand All @@ -92,22 +116,7 @@ const createWindow = async() => {
});
}

if(windowMaximized) {
mainWindow.maximize();
} else {
const windowDimensions: { width: number; height: number } | null = configStorage.get('windowDimensions') as { width: number; height: number } | null;

if (windowDimensions) {
const { width, height } = windowDimensions;
mainWindow.setSize(width, height);

const windowPosition: { x: number; y: number } | null = configStorage.get('windowPosition') as { x: number; y: number } | null;
if (windowPosition) {
const { x, y } = windowPosition;
mainWindow.setPosition(x, y);
}
}
}
handleWindowSizeAndPosition();

mainWindow.loadURL(resolveHtmlPath('index.html'));
mainWindow
Expand Down
3 changes: 2 additions & 1 deletion src/main/tray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ function createTray() {
try {
const isDark = nativeTheme.shouldUseDarkColors;
const isMac = process.platform === 'darwin';
const isWindows = process.platform === 'win32';
const isTray = configStorage.get('tray');

tray?.destroy();
Expand All @@ -64,7 +65,7 @@ function createTray() {
const files = configStorage.get('files') as File[] || [];
const menu = Menu.buildFromTemplate(getMenuTemplate(files));

tray = new Tray((isDark || isMac) ? getAssetPath('icons/tray/darkTheme/tray.png') : getAssetPath('icons/tray/lightTheme/tray.png'));
tray = new Tray((isWindows) ? getAssetPath('icons/tray/lightTheme/tray.png') : getAssetPath('icons/tray/darkTheme/tray.png'));
tray.setContextMenu(menu);

return Promise.resolve('Tray created');
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/AutoSuggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const AutoSuggest = ({
const [matchPosition, setMatchPosition] = useState({ start: -1, end: -1 });

const handleSuggestionsFetchRequested = ({ value }) => {

const inputValue = value;
if (!inputValue) return;

Expand Down Expand Up @@ -94,6 +93,7 @@ const AutoSuggest = ({

const handleKeyDown = (event) => {
if (suggestions.length > 0) {

if (event.key === 'Enter') {
if (suggestions.length > 0 && selectedSuggestionIndex !== -1) {
event.stopPropagation();
Expand Down
16 changes: 9 additions & 7 deletions src/renderer/AutoSuggest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@
overflow-y: auto;
position: fixed;
z-index: 10;
margin-top: -0.4em;
padding: 0.75em 1em;
border-bottom-right-radius: $radius;
border-bottom-left-radius: $radius;
background: $lighter-grey;
margin-top: 2px;
padding: 1em;
display: block;
border-radius: $radius;
background-color: rgba(240, 240, 240, 0.5);
backdrop-filter: blur(5px);
ul {
padding: 0;
margin: 0;
list-style: none;
li {
float: left;
margin: 0 0.35em 0.35em 0;
margin: 0.15em 0.3em 0.15em 0;
}
}
}

.darkTheme {
.react-autosuggest__suggestions-container--open {
background: $darker-grey;
background-color: rgba(45, 45, 45, 0.5);
backdrop-filter: blur(5px);
}
}
.react-autosuggest__container {
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/Coloring.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@

*[data-todotxt-attribute^="pm"] {
--color1: white;
--color2: #FF3860;
--color2: #c00027;
button {
&.Mui-disabled {
color: white;
Expand All @@ -104,7 +104,7 @@
}
&.selected {
button {
background: darken(#FF3860, 25%);
background: darken(#c00027, 10%);
}
}
}
Expand All @@ -121,7 +121,7 @@

.darkTheme {

*[data-todotxt-attribute]:not([data-todotxt-attribute="priority"], [data-todotxt-attribute="projects"], [data-todotxt-attribute="contexts"], [data-todotxt-attribute="pm"]) {
*[data-todotxt-attribute]:not([data-todotxt-attribute="priority"], [data-todotxt-attribute="projects"], [data-todotxt-attribute="contexts"], [data-todotxt-attribute^="pm"]) {
--color1: #f0f0f0;
--color2: #5a5a5a;
&.selected {
Expand All @@ -130,6 +130,7 @@
}
}
}

*[data-todotxt-attribute="contexts"] {
--color1: #c5ede3;
--color2: #1e6251;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/ContextMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const ContextMenu = ({
{contextMenuItems.map((item) => (
<MenuItem key={item.id} onClick={() => handleContextMenuClick(item)}>
{item.id === 'changeDoneFilePath' ? (
<Tooltip title={item.doneFilePath}>
<Tooltip placement='right' arrow title={item.doneFilePath}>
<Button onClick={() => handleChangeDoneFilePath(item.index)} startIcon={<FileOpenIcon />}>
{item.label}
</Button>
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/DataGridRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Checkbox, ListItem, Button, Divider, Chip, Box } from '@mui/material';
import CircleChecked from '@mui/icons-material/CheckCircle';
import CircleUnchecked from '@mui/icons-material/RadioButtonUnchecked';
import VisibilityOffIcon from '@mui/icons-material/VisibilityOff';
import LocalPizzaIcon from '@mui/icons-material/LocalPizza';
import { handleFilterSelect } from './Shared';
import DatePickerInline from './DatePickerInline';
import { ReactComponent as TomatoIconDuo } from '../../assets/icons/tomato-duo.svg'
import './DataGridRow.scss';

const DataGridRow = React.memo(({
Expand Down Expand Up @@ -95,8 +95,8 @@ const DataGridRow = React.memo(({
</Button>
),
pm: (value, type) => (
<Button onClick={() => handleButtonClick(type, value)}>
<LocalPizzaIcon />
<Button className='pomodoro' onClick={() => handleButtonClick(type, value)}>
<TomatoIconDuo />
<Box>{value}</Box>
</Button>
),
Expand Down
12 changes: 9 additions & 3 deletions src/renderer/DataGridRow.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@
margin: 0;

}
}
}
&.pomodoro {
padding: 0;
svg {
font-size: 1.5em;
}
}
}
.MuiCheckbox-root {
padding: 0.35em 0.5em 0.35em 0.25em;
Expand Down Expand Up @@ -71,10 +77,10 @@
button {
.MuiChip-root {
background: darken($dark-grey, 10%);
}
}
}
&.group {
border: none;
}
}
}
}
3 changes: 2 additions & 1 deletion src/renderer/PomodoroPicker.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState, useEffect } from 'react';
import { FormControl, InputLabel, TextField } from '@mui/material';
import { Item } from 'jstodotxt';
import { ReactComponent as TomatoIconDuo } from '../../assets/icons/tomato-duo.svg'
import './PomodoroPicker.scss';

const PomodoraPicker = ({
Expand All @@ -27,7 +28,7 @@ const PomodoraPicker = ({
<FormControl id="pomodoroPicker">
<TextField
id="pomodoroPicker"
label="Pomodoro"
label=<TomatoIconDuo />
type="number"
onChange={handleChange}
value={pomodoro}
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/PomodoroPicker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
input {
width: 4em;
}
svg {
width: 2em;
height: 2em;
}
}
2 changes: 1 addition & 1 deletion src/renderer/Shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const attributeMapping = {
contexts: 'Contexts',
priority: 'Priority',
rec: 'Recurrence',
pm: 'Pomodoro timer',
pm: 'Pomodoro intervals',
created: 'Creation date',
completed: 'Completion date',
};
2 changes: 1 addition & 1 deletion src/renderer/TodoDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const TodoDialog = ({
}
ipcRenderer.send('writeTodoToFile', todoObject?.id, textFieldRef.current.value);
} catch (error) {
console.error(error);
console.error(error.message);
}
};

Expand Down

0 comments on commit 6c088aa

Please sign in to comment.