Skip to content

Commit 61dd0bb

Browse files
bhawesh96catarak
authored andcommitted
[WIP] Set min & max limits on font-size (#716)
* Set min & max limits on font-size Disable the font-size setting button when extremum is reached. References #689 * handle case for user input to input field, also add min and max for indentation amount
1 parent 0f7e9d8 commit 61dd0bb

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

client/modules/IDE/components/Preferences.jsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ class Preferences extends React.Component {
2525
if (Number.isNaN(value)) {
2626
value = 16;
2727
}
28+
if (value > 36) {
29+
value = 36;
30+
}
31+
if (value < 8) {
32+
value = 8;
33+
}
2834
this.props.setFontSize(value);
2935
}
3036

@@ -33,6 +39,12 @@ class Preferences extends React.Component {
3339
if (Number.isNaN(value)) {
3440
value = 2;
3541
}
42+
if (value > 6) {
43+
value = 6;
44+
}
45+
if (value < 0) {
46+
value = 0;
47+
}
3648
this.props.setIndentation(value);
3749
}
3850

@@ -106,6 +118,7 @@ class Preferences extends React.Component {
106118
className="preference__minus-button"
107119
onClick={() => this.props.setFontSize(this.props.fontSize - 2)}
108120
aria-label="decrease font size"
121+
disabled={this.props.fontSize <= 8}
109122
>
110123
<InlineSVG src={minusUrl} alt="Decrease Font Size" />
111124
<h6 className="preference__label">Decrease</h6>
@@ -125,6 +138,7 @@ class Preferences extends React.Component {
125138
className="preference__plus-button"
126139
onClick={() => this.props.setFontSize(this.props.fontSize + 2)}
127140
aria-label="increase font size"
141+
disabled={this.props.fontSize >= 36}
128142
>
129143
<InlineSVG src={plusUrl} alt="Increase Font Size" />
130144
<h6 className="preference__label">Increase</h6>
@@ -136,6 +150,7 @@ class Preferences extends React.Component {
136150
className="preference__minus-button"
137151
onClick={() => this.props.setIndentation(this.props.indentationAmount - 2)}
138152
aria-label="decrease indentation amount"
153+
disabled={this.props.indentationAmount <= 0}
139154
>
140155
<InlineSVG src={minusUrl} alt="DecreaseIndentation Amount" />
141156
<h6 className="preference__label">Decrease</h6>
@@ -155,6 +170,7 @@ class Preferences extends React.Component {
155170
className="preference__plus-button"
156171
onClick={() => this.props.setIndentation(this.props.indentationAmount + 2)}
157172
aria-label="increase indentation amount"
173+
disabled={this.props.indentationAmount >= 6}
158174
>
159175
<InlineSVG src={plusUrl} alt="IncreaseIndentation Amount" />
160176
<h6 className="preference__label">Increase</h6>

client/styles/abstracts/_placeholders.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,17 @@
128128
& g {
129129
fill: getThemifyVariable('modal-button-color');
130130
}
131-
&:hover {
131+
&:enabled:hover {
132132
background-color: getThemifyVariable('button-background-hover-color');
133133
color: getThemifyVariable('button-hover-color');
134134
& g {
135135
fill: getThemifyVariable('button-hover-color');
136136
}
137137
}
138+
&:disabled:hover {
139+
cursor: not-allowed;
140+
background-color: getThemifyVariable('modal-button-background-color');
141+
}
138142
}
139143
}
140144

0 commit comments

Comments
 (0)