Respect default font size preference from browsers
We encountered an issue where PolyGerrit was not respecting browser font preferences. Browser font preferences include both a default font size and a minimum font size. In the event that a font declared in px is smaller than the minimum font size, the size is increased to equal the minimum font size. However, if the font is declared in px and greater than the minimum, the preferred font size is not taken into account. Browsers' default font size is 16px [1], So instead of declaring the base font in px (previously 13px), this change makes it a percentage of the default font size. If the user has changed their default, this is taken into account. From this point, all other fonts will be declared in rems, which makes it easier to base the new size off of the base font size of the <html> tag, rather than ems which bases it on the container[2]. This allows us to declare font sizes in a way more similar to pixels, yet relative. A follow-up change will change all font size declaration to use rem from em for consistency. [1] https://stackoverflow.com/questions/29511983/is-the-default-font-size-of-every-browser-16px-why [2] https://webdesign.tutsplus.com/tutorials/comprehensive-guide-when-to-use-em-vs-rem--cms-23984 Bug: Issue 8157 Change-Id: I04ec2c861b2fb288ec7556dfb655d7feea9c9157
This commit is contained in:
@@ -35,7 +35,7 @@ limitations under the License.
|
||||
}
|
||||
.bigTitle {
|
||||
color: var(--primary-text-color);
|
||||
font-size: 1.75em;
|
||||
font-size: 1.75rem;
|
||||
text-decoration: none;
|
||||
}
|
||||
.bigTitle:hover {
|
||||
@@ -125,7 +125,7 @@ limitations under the License.
|
||||
}
|
||||
@media screen and (max-width: 50em) {
|
||||
.bigTitle {
|
||||
font-size: 14px;
|
||||
font-size: var(--font-size-large);
|
||||
font-family: var(--font-family-bold);
|
||||
}
|
||||
gr-search-bar,
|
||||
|
@@ -164,7 +164,7 @@ limitations under the License.
|
||||
color: #000;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
font-size: .8em;
|
||||
font-size: .8rem;
|
||||
height: 1.1em;
|
||||
margin-top: .1em;
|
||||
}
|
||||
@@ -195,7 +195,7 @@ limitations under the License.
|
||||
}
|
||||
.resolve label {
|
||||
color: #333;
|
||||
font-size: 12px;
|
||||
font-size: var(--font-size-small);
|
||||
}
|
||||
gr-confirm-dialog .main {
|
||||
background-color: #fef;
|
||||
|
@@ -48,7 +48,7 @@ limitations under the License.
|
||||
}
|
||||
.diffContainer {
|
||||
display: flex;
|
||||
font: 12px var(--monospace-font-family);
|
||||
font: var(--font-size-small) var(--monospace-font-family);
|
||||
@apply --diff-container-styles;
|
||||
}
|
||||
.diffContainer.hiddenscroll {
|
||||
@@ -101,7 +101,7 @@ limitations under the License.
|
||||
.lineNum,
|
||||
.content {
|
||||
/* Set font size based the user's diff preference. */
|
||||
font-size: var(--font-size, 12px);
|
||||
font-size: var(--font-size, var(--font-size-small));
|
||||
vertical-align: top;
|
||||
white-space: pre;
|
||||
}
|
||||
@@ -196,7 +196,7 @@ limitations under the License.
|
||||
background-color: #F9F9F9;
|
||||
color: #2A00FF;
|
||||
font-family: var(--monospace-font-family);
|
||||
font-size: var(--font-size, 12px);
|
||||
font-size: var(--font-size, var(--font-size-small));
|
||||
padding: 0.5em 0 0.5em 4em;
|
||||
}
|
||||
#sizeWarning {
|
||||
@@ -220,7 +220,7 @@ limitations under the License.
|
||||
td.blame {
|
||||
display: none;
|
||||
font-family: var(--font-family);
|
||||
font-size: var(--font-size, 12px);
|
||||
font-size: var(--font-size, var(--font-size-small));
|
||||
padding: 0 .5em;
|
||||
white-space: pre;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ limitations under the License.
|
||||
--button-color: var(--gr-button-color, var(--color-link));
|
||||
display: inline-block;
|
||||
font-family: var(--font-family-bold);
|
||||
font-size: 12px;
|
||||
font-size: var(--font-size-small);
|
||||
position: relative;
|
||||
}
|
||||
:host([hidden]) {
|
||||
|
@@ -36,6 +36,11 @@ limitations under the License.
|
||||
transition: none;
|
||||
}
|
||||
|
||||
/* Font sizes */
|
||||
--font-size-normal: 1rem;
|
||||
--font-size-small: .92rem;
|
||||
--font-size-large: 1.076rem;
|
||||
|
||||
/* Follow are a part of the design refresh */
|
||||
--color-link: #2a66d9;
|
||||
--color-link-tertiary: #000;
|
||||
|
@@ -17,7 +17,7 @@ limitations under the License.
|
||||
<template>
|
||||
<style>
|
||||
:host {
|
||||
font-size: 13px;
|
||||
font-size: var(--font-size-normal);
|
||||
}
|
||||
.topHeader,
|
||||
.groupHeader {
|
||||
@@ -64,7 +64,7 @@ limitations under the License.
|
||||
}
|
||||
@media only screen and (max-width: 50em) {
|
||||
:host {
|
||||
font-size: 14px;
|
||||
font-size: var(--font-size-large);
|
||||
}
|
||||
gr-change-list-item {
|
||||
flex-wrap: wrap;
|
||||
|
@@ -24,6 +24,12 @@ limitations under the License.
|
||||
|
||||
html {
|
||||
-webkit-text-size-adjust: none;
|
||||
/*
|
||||
* Default browser fonts are 16px. We want users with default settings to see
|
||||
* a base font of 13px. 13/16 = .8125. This needs to be in html because
|
||||
* can use rems based on this font-size throughout the app.
|
||||
*/
|
||||
font-size: .8125em;
|
||||
}
|
||||
html,
|
||||
body {
|
||||
@@ -36,7 +42,6 @@ body {
|
||||
* Work around this using font-size and font-family.
|
||||
*/
|
||||
-webkit-text-size-adjust: none;
|
||||
font-size: 13px;
|
||||
font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
Reference in New Issue
Block a user