Break out font size settings to a separate component
This commit is contained in:
parent
d743e3d1d6
commit
4ad32b16ea
7 changed files with 601 additions and 148 deletions
38
test/components/views/settings/FontScalingPanel-test.tsx
Normal file
38
test/components/views/settings/FontScalingPanel-test.tsx
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { mount } from "enzyme";
|
||||
|
||||
import '../../../skinned-sdk';
|
||||
import * as TestUtils from "../../../test-utils";
|
||||
import _FontScalingPanel from '../../../../src/components/views/settings/FontScalingPanel';
|
||||
|
||||
const FontScalingPanel = TestUtils.wrapInMatrixClientContext(_FontScalingPanel);
|
||||
|
||||
import * as randomstring from "matrix-js-sdk/src/randomstring";
|
||||
// @ts-expect-error: override random function to make results predictable
|
||||
randomstring.randomString = () => "abdefghi";
|
||||
|
||||
describe('FontScalingPanel', () => {
|
||||
it('renders the font scaling UI', () => {
|
||||
TestUtils.stubClient();
|
||||
const wrapper = mount(
|
||||
<FontScalingPanel />,
|
||||
);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
});
|
|
@ -0,0 +1,307 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`FontScalingPanel renders the font scaling UI 1`] = `
|
||||
<Wrapper>
|
||||
<FontScalingPanel>
|
||||
<div
|
||||
className="mx_SettingsTab_section mx_FontScalingPanel"
|
||||
>
|
||||
<span
|
||||
className="mx_SettingsTab_subheading"
|
||||
>
|
||||
Font size
|
||||
</span>
|
||||
<EventTilePreview
|
||||
avatarUrl={null}
|
||||
className="mx_FontScalingPanel_fontSlider_preview"
|
||||
displayName={null}
|
||||
layout="group"
|
||||
message="Hey you. You're the best!"
|
||||
userId={null}
|
||||
>
|
||||
<div
|
||||
className="mx_FontScalingPanel_fontSlider_preview mx_GroupLayout mx_EventTilePreview_loader"
|
||||
>
|
||||
<Spinner
|
||||
h={32}
|
||||
w={32}
|
||||
>
|
||||
<div
|
||||
className="mx_Spinner"
|
||||
>
|
||||
<div
|
||||
aria-label="Loading..."
|
||||
className="mx_Spinner_icon"
|
||||
style={
|
||||
Object {
|
||||
"height": 32,
|
||||
"width": 32,
|
||||
}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Spinner>
|
||||
</div>
|
||||
</EventTilePreview>
|
||||
<div
|
||||
className="mx_FontScalingPanel_fontSlider"
|
||||
>
|
||||
<div
|
||||
className="mx_FontScalingPanel_fontSlider_smallText"
|
||||
>
|
||||
Aa
|
||||
</div>
|
||||
<Slider
|
||||
disabled={false}
|
||||
displayFunc={[Function]}
|
||||
onSelectionChange={[Function]}
|
||||
value={15}
|
||||
values={
|
||||
Array [
|
||||
13,
|
||||
14,
|
||||
15,
|
||||
16,
|
||||
18,
|
||||
]
|
||||
}
|
||||
>
|
||||
<div
|
||||
className="mx_Slider"
|
||||
>
|
||||
<div>
|
||||
<div
|
||||
className="mx_Slider_bar"
|
||||
>
|
||||
<hr
|
||||
onClick={[Function]}
|
||||
/>
|
||||
<div
|
||||
className="mx_Slider_selection"
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_selectionDot"
|
||||
style={
|
||||
Object {
|
||||
"left": "calc(-0.55em + 50%)",
|
||||
}
|
||||
}
|
||||
/>
|
||||
<hr
|
||||
style={
|
||||
Object {
|
||||
"width": "50%",
|
||||
}
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className="mx_Slider_dotContainer"
|
||||
>
|
||||
<Dot
|
||||
active={true}
|
||||
disabled={false}
|
||||
key="13"
|
||||
label=""
|
||||
onClick={[Function]}
|
||||
>
|
||||
<span
|
||||
className="mx_Slider_dotValue"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_dot mx_Slider_dotActive"
|
||||
/>
|
||||
<div
|
||||
className="mx_Slider_labelContainer"
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_label"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</Dot>
|
||||
<Dot
|
||||
active={true}
|
||||
disabled={false}
|
||||
key="14"
|
||||
label=""
|
||||
onClick={[Function]}
|
||||
>
|
||||
<span
|
||||
className="mx_Slider_dotValue"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_dot mx_Slider_dotActive"
|
||||
/>
|
||||
<div
|
||||
className="mx_Slider_labelContainer"
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_label"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</Dot>
|
||||
<Dot
|
||||
active={true}
|
||||
disabled={false}
|
||||
key="15"
|
||||
label=""
|
||||
onClick={[Function]}
|
||||
>
|
||||
<span
|
||||
className="mx_Slider_dotValue"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_dot mx_Slider_dotActive"
|
||||
/>
|
||||
<div
|
||||
className="mx_Slider_labelContainer"
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_label"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</Dot>
|
||||
<Dot
|
||||
active={false}
|
||||
disabled={false}
|
||||
key="16"
|
||||
label=""
|
||||
onClick={[Function]}
|
||||
>
|
||||
<span
|
||||
className="mx_Slider_dotValue"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_dot"
|
||||
/>
|
||||
<div
|
||||
className="mx_Slider_labelContainer"
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_label"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</Dot>
|
||||
<Dot
|
||||
active={false}
|
||||
disabled={false}
|
||||
key="18"
|
||||
label=""
|
||||
onClick={[Function]}
|
||||
>
|
||||
<span
|
||||
className="mx_Slider_dotValue"
|
||||
onClick={[Function]}
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_dot"
|
||||
/>
|
||||
<div
|
||||
className="mx_Slider_labelContainer"
|
||||
>
|
||||
<div
|
||||
className="mx_Slider_label"
|
||||
/>
|
||||
</div>
|
||||
</span>
|
||||
</Dot>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Slider>
|
||||
<div
|
||||
className="mx_FontScalingPanel_fontSlider_largeText"
|
||||
>
|
||||
Aa
|
||||
</div>
|
||||
</div>
|
||||
<SettingsFlag
|
||||
level="account"
|
||||
name="useCustomFontSize"
|
||||
onChange={[Function]}
|
||||
useCheckbox={true}
|
||||
>
|
||||
<StyledCheckbox
|
||||
checked={false}
|
||||
className=""
|
||||
disabled={false}
|
||||
onChange={[Function]}
|
||||
>
|
||||
<span
|
||||
className="mx_Checkbox "
|
||||
>
|
||||
<input
|
||||
checked={false}
|
||||
disabled={false}
|
||||
id="checkbox_abdefghi"
|
||||
onChange={[Function]}
|
||||
type="checkbox"
|
||||
/>
|
||||
<label
|
||||
htmlFor="checkbox_abdefghi"
|
||||
>
|
||||
<div
|
||||
className="mx_Checkbox_background"
|
||||
>
|
||||
<img
|
||||
src="image-file-stub"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
Use custom size
|
||||
</div>
|
||||
</label>
|
||||
</span>
|
||||
</StyledCheckbox>
|
||||
</SettingsFlag>
|
||||
<Field
|
||||
autoComplete="off"
|
||||
className="mx_FontScalingPanel_customFontSizeField"
|
||||
disabled={true}
|
||||
element="input"
|
||||
id="font_size_field"
|
||||
label="Font size"
|
||||
onChange={[Function]}
|
||||
onValidate={[Function]}
|
||||
placeholder="15"
|
||||
type="number"
|
||||
validateOnBlur={true}
|
||||
validateOnChange={true}
|
||||
validateOnFocus={true}
|
||||
value="15"
|
||||
>
|
||||
<div
|
||||
className="mx_Field mx_Field_input mx_FontScalingPanel_customFontSizeField"
|
||||
>
|
||||
<input
|
||||
autoComplete="off"
|
||||
disabled={true}
|
||||
id="font_size_field"
|
||||
label="Font size"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
onFocus={[Function]}
|
||||
placeholder="15"
|
||||
type="number"
|
||||
value="15"
|
||||
/>
|
||||
<label
|
||||
htmlFor="font_size_field"
|
||||
>
|
||||
Font size
|
||||
</label>
|
||||
</div>
|
||||
</Field>
|
||||
</div>
|
||||
</FontScalingPanel>
|
||||
</Wrapper>
|
||||
`;
|
Loading…
Add table
Add a link
Reference in a new issue