mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
Set a minimum value for fontSize setting (#3042)
Co-authored-by: Opender Singh <opender.singh@konghq.com>
This commit is contained in:
parent
1b718165d7
commit
ff1c70f437
@ -148,6 +148,10 @@ export const MIN_PANE_HEIGHT = 0.01;
|
|||||||
export const DEFAULT_PANE_WIDTH = 0.5;
|
export const DEFAULT_PANE_WIDTH = 0.5;
|
||||||
export const DEFAULT_PANE_HEIGHT = 0.5;
|
export const DEFAULT_PANE_HEIGHT = 0.5;
|
||||||
export const DEFAULT_SIDEBAR_WIDTH = 19;
|
export const DEFAULT_SIDEBAR_WIDTH = 19;
|
||||||
|
export const MIN_INTERFACE_FONT_SIZE = 8;
|
||||||
|
export const MAX_INTERFACE_FONT_SIZE = 24;
|
||||||
|
export const MIN_EDITOR_FONT_SIZE = 8;
|
||||||
|
export const MAX_EDITOR_FONT_SIZE = 24;
|
||||||
|
|
||||||
// Activities
|
// Activities
|
||||||
export type GlobalActivity = 'spec' | 'debug' | 'unittest' | 'home' | 'migration' | 'onboarding';
|
export type GlobalActivity = 'spec' | 'debug' | 'unittest' | 'home' | 'migration' | 'onboarding';
|
||||||
|
@ -17,6 +17,10 @@ import {
|
|||||||
isWindows,
|
isWindows,
|
||||||
UPDATE_CHANNEL_BETA,
|
UPDATE_CHANNEL_BETA,
|
||||||
UPDATE_CHANNEL_STABLE,
|
UPDATE_CHANNEL_STABLE,
|
||||||
|
MIN_INTERFACE_FONT_SIZE,
|
||||||
|
MAX_INTERFACE_FONT_SIZE,
|
||||||
|
MIN_EDITOR_FONT_SIZE,
|
||||||
|
MAX_EDITOR_FONT_SIZE,
|
||||||
} from '../../../common/constants';
|
} from '../../../common/constants';
|
||||||
import HelpTooltip from '../help-tooltip';
|
import HelpTooltip from '../help-tooltip';
|
||||||
import type { GlobalActivity, HttpVersion } from '../../../common/constants';
|
import type { GlobalActivity, HttpVersion } from '../../../common/constants';
|
||||||
@ -81,11 +85,22 @@ class General extends React.PureComponent<Props, State> {
|
|||||||
const el = e.currentTarget;
|
const el = e.currentTarget;
|
||||||
let value = el.type === 'checkbox' ? el.checked : el.value;
|
let value = el.type === 'checkbox' ? el.checked : el.value;
|
||||||
|
|
||||||
if (e.currentTarget.type === 'number') {
|
if (el.type === 'number') {
|
||||||
value = parseInt(value, 10);
|
value = parseInt(value, 10) || 0;
|
||||||
|
const min = parseInt(el.min, 10);
|
||||||
|
const max = parseInt(el.max, 10);
|
||||||
|
|
||||||
|
const moreThanMax = Number.isNaN(max) || value > max;
|
||||||
|
const lessThanMin = Number.isNaN(min) || value < min;
|
||||||
|
|
||||||
|
if (moreThanMax) {
|
||||||
|
value = max;
|
||||||
|
} else if (lessThanMin) {
|
||||||
|
value = min;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (e.currentTarget.value === '__NULL__') {
|
if (el.value === '__NULL__') {
|
||||||
value = null;
|
value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +116,7 @@ class General extends React.PureComponent<Props, State> {
|
|||||||
|
|
||||||
async _handleFontSizeChange(el: SyntheticEvent<HTMLInputElement>) {
|
async _handleFontSizeChange(el: SyntheticEvent<HTMLInputElement>) {
|
||||||
const settings = await this._handleUpdateSetting(el);
|
const settings = await this._handleUpdateSetting(el);
|
||||||
|
|
||||||
setFont(settings);
|
setFont(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,9 +296,9 @@ class General extends React.PureComponent<Props, State> {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{this.renderNumberSetting('Interface Font Size (px)', 'fontSize', '', {
|
{this.renderNumberSetting('Interface Font Size (px)', 'fontSize', '', {
|
||||||
min: 8,
|
min: MIN_INTERFACE_FONT_SIZE,
|
||||||
max: 20,
|
max: MAX_INTERFACE_FONT_SIZE,
|
||||||
onChange: this._handleFontSizeChange,
|
onBlur: this._handleFontSizeChange,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -310,8 +326,8 @@ class General extends React.PureComponent<Props, State> {
|
|||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
{this.renderNumberSetting('Editor Font Size (px)', 'editorFontSize', '', {
|
{this.renderNumberSetting('Editor Font Size (px)', 'editorFontSize', '', {
|
||||||
min: 8,
|
min: MIN_EDITOR_FONT_SIZE,
|
||||||
max: 20,
|
max: MAX_EDITOR_FONT_SIZE,
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user