Skip to content

Limit font size for quick tools #2002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions www/main/viewer/Slide/QuickTools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const QuickTools = ({ isMiscSlide }) => {
let payload;
let actionName;
let stateName;
const maxFontSize = 20;
const minFontSize = 1;

if (index > 0) {
stateName = `content${index}${action}`;
Expand All @@ -93,13 +95,21 @@ const QuickTools = ({ isMiscSlide }) => {
actionName = `set${convertToCamelCase(`${toolname}-${action}`, true)}`;
}

const currentFontSize = parseInt(userSettings[stateName], 10);

if (name === 'visibility') {
payload = !userSettings[stateName];
} else if (name === 'minus') {
payload = parseInt(userSettings[stateName], 10) - 1;
payload = currentFontSize > minFontSize ? currentFontSize - 1 : minFontSize;
} else if (name === 'plus') {
payload = parseInt(userSettings[stateName], 10) + 1;
payload = currentFontSize < maxFontSize ? currentFontSize + 1 : maxFontSize;
}

// If payload does not change, return null to prevent unnecessary state updates
if (payload === userSettings[stateName]) {
return null;
}

return {
actionName,
payload,
Expand All @@ -126,10 +136,10 @@ const QuickTools = ({ isMiscSlide }) => {
<i
className={getIconClassName(name, index, actionName)}
onClick={() => {
global.platform.ipc.send(
'update-global-setting',
JSON.stringify(createGlobalPlatformObj(name, toolName, index, actionName)),
);
const globalObj = createGlobalPlatformObj(name, toolName, index, actionName);
if (globalObj) {
global.platform.ipc.send('update-global-setting', JSON.stringify(globalObj));
}
}}
/>
</div>
Expand Down