This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 828
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4424 from JorikSchellekens/joriks/font-scaling-sl…
…ider Font scaling settings and slider
- Loading branch information
Showing
28 changed files
with
764 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
Copyright 2020 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. | ||
*/ | ||
|
||
.mx_Slider { | ||
position: relative; | ||
margin: 0px; | ||
flex-grow: 1; | ||
} | ||
|
||
.mx_Slider_dotContainer { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
} | ||
|
||
.mx_Slider_bar { | ||
display: flex; | ||
box-sizing: border-box; | ||
position: absolute; | ||
height: 1em; | ||
width: 100%; | ||
padding: 0 0.5em; // half the width of a dot. | ||
align-items: center; | ||
} | ||
|
||
.mx_Slider_bar > hr { | ||
width: 100%; | ||
height: 0.4em; | ||
background-color: $slider-background-color; | ||
border: 0; | ||
} | ||
|
||
.mx_Slider_selection { | ||
display: flex; | ||
align-items: center; | ||
width: calc(100% - 1em); // 2 * half the width of a dot | ||
height: 1em; | ||
position: absolute; | ||
pointer-events: none; | ||
} | ||
|
||
.mx_Slider_selectionDot { | ||
position: absolute; | ||
width: 1.1em; | ||
height: 1.1em; | ||
background-color: $slider-selection-color; | ||
border-radius: 50%; | ||
box-shadow: 0 0 6px lightgrey; | ||
z-index: 10; | ||
} | ||
|
||
.mx_Slider_selection > hr { | ||
margin: 0; | ||
border: 0.2em solid $slider-selection-color; | ||
} | ||
|
||
.mx_Slider_dot { | ||
height: 1em; | ||
width: 1em; | ||
border-radius: 50%; | ||
background-color: $slider-background-color; | ||
z-index: 0; | ||
} | ||
|
||
.mx_Slider_dotActive { | ||
background-color: $slider-selection-color; | ||
} | ||
|
||
.mx_Slider_dotValue { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
color: $slider-background-color; | ||
} | ||
|
||
// The following is a hack to center the labels without adding | ||
// any width to the slider's dots. | ||
.mx_Slider_labelContainer { | ||
width: 1em; | ||
} | ||
|
||
.mx_Slider_label { | ||
position: relative; | ||
width: fit-content; | ||
left: -50%; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
res/css/views/settings/tabs/user/_AppearanceUserSettingsTab.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright 2020 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. | ||
*/ | ||
|
||
.mx_AppearanceUserSettingsTab_fontSlider, | ||
.mx_AppearanceUserSettingsTab_themeSection .mx_Field, | ||
.mx_AppearanceUserSettingsTab_fontScaling .mx_Field { | ||
@mixin mx_Settings_fullWidthField; | ||
} | ||
|
||
.mx_AppearanceUserSettingsTab_fontSlider { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
padding: 15px; | ||
background: $font-slider-bg-color; | ||
border-radius: 10px; | ||
font-size: 10px; | ||
margin-top: 24px; | ||
margin-bottom: 24px; | ||
} | ||
|
||
.mx_AppearanceUserSettingsTab_fontSlider_smallText { | ||
font-size: 15px; | ||
padding-right: 20px; | ||
padding-left: 5px; | ||
} | ||
|
||
.mx_AppearanceUserSettingsTab_fontSlider_largeText { | ||
font-size: 18px; | ||
padding-left: 20px; | ||
padding-right: 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
Copyright 2020 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 dis from './dispatcher/dispatcher'; | ||
import SettingsStore, {SettingLevel} from './settings/SettingsStore'; | ||
|
||
export class FontWatcher { | ||
static MIN_SIZE = 13; | ||
static MAX_SIZE = 20; | ||
|
||
constructor() { | ||
this._dispatcherRef = null; | ||
} | ||
|
||
start() { | ||
this._setRootFontSize(SettingsStore.getValue("fontSize")); | ||
this._dispatcherRef = dis.register(this._onAction); | ||
} | ||
|
||
stop() { | ||
dis.unregister(this._dispatcherRef); | ||
} | ||
|
||
_onAction = (payload) => { | ||
if (payload.action === 'update-font-size') { | ||
this._setRootFontSize(payload.size); | ||
} | ||
}; | ||
|
||
_setRootFontSize = (size) => { | ||
const fontSize = Math.max(Math.min(FontWatcher.MAX_SIZE, size), FontWatcher.MIN_SIZE); | ||
|
||
if (fontSize != size) { | ||
SettingsStore.setValue("fontSize", null, SettingLevel.Device, fontSize); | ||
} | ||
document.querySelector(":root").style.fontSize = fontSize + "px"; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.