Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a043a21

Browse files
committed
Remove custom font size input
1 parent ab5b7d0 commit a043a21

File tree

2 files changed

+1
-72
lines changed

2 files changed

+1
-72
lines changed

src/components/views/settings/FontScalingPanel.tsx

-55
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,16 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// import React, { ChangeEvent } from "react";
1817
import React from "react";
1918

2019
import EventTilePreview from "../elements/EventTilePreview";
21-
// import Field from "../elements/Field";
22-
// import SettingsFlag from "../elements/SettingsFlag";
2320
import SettingsStore from "../../../settings/SettingsStore";
2421
import Slider from "../elements/Slider";
2522
import { FontWatcher } from "../../../settings/watchers/FontWatcher";
26-
// import { IValidationResult, IFieldState } from "../elements/Validation";
2723
import { Layout } from "../../../settings/enums/Layout";
2824
import { MatrixClientPeg } from "../../../MatrixClientPeg";
2925
import { SettingLevel } from "../../../settings/SettingLevel";
3026
import { _t } from "../../../languageHandler";
31-
// import { clamp } from "../../../utils/numbers";
3227
import SettingsSubsection from "./shared/SettingsSubsection";
3328

3429
interface IProps {}
@@ -96,27 +91,6 @@ export default class FontScalingPanel extends React.Component<IProps, IState> {
9691
await SettingsStore.setValue("baseFontSizeV3", null, SettingLevel.DEVICE, delta);
9792
};
9893

99-
// private onValidateFontSize = async ({ value }: Pick<IFieldState, "value">): Promise<IValidationResult> => {
100-
// const parsedSize = parseFloat(value!);
101-
// const min = FontWatcher.MIN_SIZE;
102-
// const max = FontWatcher.MAX_SIZE;
103-
//
104-
// if (isNaN(parsedSize)) {
105-
// return { valid: false, feedback: _t("settings|appearance|font_size_nan") };
106-
// }
107-
//
108-
// if (!(min <= parsedSize && parsedSize <= max)) {
109-
// return {
110-
// valid: false,
111-
// feedback: _t("settings|appearance|font_size_limit", { min, max }),
112-
// };
113-
// }
114-
//
115-
// SettingsStore.setValue("baseFontSizeV2", null, SettingLevel.DEVICE, parseInt(value!, 10));
116-
//
117-
// return { valid: true, feedback: _t("settings|appearance|font_size_valid", { min, max }) };
118-
// };
119-
12094
public render(): React.ReactNode {
12195
return (
12296
<SettingsSubsection
@@ -146,35 +120,6 @@ export default class FontScalingPanel extends React.Component<IProps, IState> {
146120
/>
147121
<div className="mx_FontScalingPanel_fontSlider_largeText">Aa</div>
148122
</div>
149-
150-
{/*<SettingsFlag*/}
151-
{/* name="useCustomFontSize"*/}
152-
{/* level={SettingLevel.ACCOUNT}*/}
153-
{/* onChange={(checked) => {*/}
154-
{/* this.setState({ useCustomFontSize: checked });*/}
155-
{/* if (!checked) {*/}
156-
{/* const size = parseInt(this.state.fontSize, 10);*/}
157-
{/* const clamped = clamp(size, FontWatcher.MIN_SIZE, FontWatcher.MAX_SIZE);*/}
158-
{/* if (clamped !== size) {*/}
159-
{/* this.onFontSizeChanged(clamped);*/}
160-
{/* }*/}
161-
{/* }*/}
162-
{/* }}*/}
163-
{/* useCheckbox={true}*/}
164-
{/*/>*/}
165-
166-
{/*<Field*/}
167-
{/* type="number"*/}
168-
{/* label={_t("settings|appearance|font_size")}*/}
169-
{/* autoComplete="off"*/}
170-
{/* placeholder={this.state.fontSize.toString()}*/}
171-
{/* value={this.state.fontSize.toString()}*/}
172-
{/* id="font_size_field"*/}
173-
{/* onValidate={this.onValidateFontSize}*/}
174-
{/* onChange={(value: ChangeEvent<HTMLInputElement>) => this.setState({ fontSize: value.target.value })}*/}
175-
{/* disabled={!this.state.useCustomFontSize}*/}
176-
{/* className="mx_AppearanceUserSettingsTab_checkboxControlledField"*/}
177-
{/*/>*/}
178123
</SettingsSubsection>
179124
);
180125
}

test/components/views/settings/FontScalingPanel-test.tsx

+1-17
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,15 @@ limitations under the License.
1515
*/
1616

1717
import React from "react";
18-
import { fireEvent, render, waitFor } from "@testing-library/react";
18+
import { render } from "@testing-library/react";
1919

2020
import * as TestUtils from "../../../test-utils";
2121
import FontScalingPanel from "../../../../src/components/views/settings/FontScalingPanel";
22-
import SettingsStore from "../../../../src/settings/SettingsStore";
2322

2423
describe("FontScalingPanel", () => {
2524
it("renders the font scaling UI", () => {
2625
TestUtils.stubClient();
2726
const { asFragment } = render(<FontScalingPanel />);
2827
expect(asFragment()).toMatchSnapshot();
2928
});
30-
31-
it("should clamp custom font size when disabling it", async () => {
32-
jest.spyOn(SettingsStore, "setValue").mockResolvedValue(undefined);
33-
TestUtils.stubClient();
34-
const { container, getByText } = render(<FontScalingPanel />);
35-
fireEvent.click(getByText("Use custom size"));
36-
await waitFor(() => {
37-
expect(container.querySelector("input[checked]")).toBeDefined();
38-
});
39-
fireEvent.change(container.querySelector("#font_size_field")!, { target: { value: "25" } });
40-
fireEvent.click(getByText("Use custom size"));
41-
await waitFor(() => {
42-
expect(container.querySelector("#font_size_field")).toHaveValue(21);
43-
});
44-
});
4529
});

0 commit comments

Comments
 (0)