mirror of
https://github.com/element-hq/element-web
synced 2024-11-28 04:21:57 +03:00
Use a function to convert to rem.
This commit is contained in:
parent
d12ed333c1
commit
05d11fea69
2 changed files with 30 additions and 9 deletions
|
@ -24,6 +24,7 @@ import * as AvatarLogic from '../../../Avatar';
|
||||||
import SettingsStore from "../../../settings/SettingsStore";
|
import SettingsStore from "../../../settings/SettingsStore";
|
||||||
import AccessibleButton from '../elements/AccessibleButton';
|
import AccessibleButton from '../elements/AccessibleButton';
|
||||||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||||
|
import toRem from "../../../utils/rem";
|
||||||
|
|
||||||
export default createReactClass({
|
export default createReactClass({
|
||||||
displayName: 'BaseAvatar',
|
displayName: 'BaseAvatar',
|
||||||
|
@ -164,9 +165,9 @@ export default createReactClass({
|
||||||
const initialLetter = AvatarLogic.getInitialLetter(name);
|
const initialLetter = AvatarLogic.getInitialLetter(name);
|
||||||
const textNode = (
|
const textNode = (
|
||||||
<span className="mx_BaseAvatar_initial" aria-hidden="true"
|
<span className="mx_BaseAvatar_initial" aria-hidden="true"
|
||||||
style={{ fontSize: (width * 0.65) / 15 + "rem",
|
style={{ fontSize: toRem(width * 0.65),
|
||||||
width: width / 15 + "rem",
|
width: toRem(width),
|
||||||
lineHeight: height / 15 + "rem" }}
|
lineHeight: toRem(height) }}
|
||||||
>
|
>
|
||||||
{ initialLetter }
|
{ initialLetter }
|
||||||
</span>
|
</span>
|
||||||
|
@ -176,8 +177,8 @@ export default createReactClass({
|
||||||
alt="" title={title} onError={this.onError}
|
alt="" title={title} onError={this.onError}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
style={{
|
style={{
|
||||||
width: width/15 + "rem",
|
width: toRem(width),
|
||||||
height: height/15 + "rem"
|
height: toRem(height)
|
||||||
}} />
|
}} />
|
||||||
);
|
);
|
||||||
if (onClick != null) {
|
if (onClick != null) {
|
||||||
|
@ -207,8 +208,8 @@ export default createReactClass({
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
onError={this.onError}
|
onError={this.onError}
|
||||||
style={{
|
style={{
|
||||||
width: width/15 + "rem",
|
width: toRem(width),
|
||||||
height: height/15 + "rem"
|
height: toRem(height)
|
||||||
}}
|
}}
|
||||||
title={title} alt=""
|
title={title} alt=""
|
||||||
inputRef={inputRef}
|
inputRef={inputRef}
|
||||||
|
@ -221,8 +222,8 @@ export default createReactClass({
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
onError={this.onError}
|
onError={this.onError}
|
||||||
style={{
|
style={{
|
||||||
width: width/15 + "rem",
|
width: toRem(width),
|
||||||
height: height/15 + "rem"
|
height: toRem(height)
|
||||||
}}
|
}}
|
||||||
title={title} alt=""
|
title={title} alt=""
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
|
|
20
src/utils/rem.js
Normal file
20
src/utils/rem.js
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// converts a pixel value to rem.
|
||||||
|
export default function(pixel_val) {
|
||||||
|
return pixel_val / 15 + "rem"
|
||||||
|
}
|
Loading…
Reference in a new issue