Files
gerrit/polygerrit-ui/app/elements/shared/gr-button/gr-button.html
Becky Siegel d450a9eb57 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
2018-01-27 00:29:32 +00:00

116 lines
3.7 KiB
HTML

<!--
Copyright (C) 2016 The Android Open Source Project
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.
-->
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../../behaviors/gr-tooltip-behavior/gr-tooltip-behavior.html">
<link rel="import" href="../../../behaviors/keyboard-shortcut-behavior/keyboard-shortcut-behavior.html">
<link rel="import" href="../../../bower_components/paper-button/paper-button.html">
<link rel="import" href="../../../styles/shared-styles.html">
<dom-module id="gr-button">
<template strip-whitespace>
<style include="shared-styles">
/* general styles for all buttons */
:host {
--background-color: var(--gr-button-background, #fff);
--button-color: var(--gr-button-color, var(--color-link));
display: inline-block;
font-family: var(--font-family-bold);
font-size: var(--font-size-small);
position: relative;
}
:host([hidden]) {
display: none;
}
:host([no-uppercase]) paper-button {
text-transform: none;
}
paper-button {
/* paper-button sets this to anti-aliased, which appears different than
roboto-medium elsewhere. */
-webkit-font-smoothing: initial;
align-items: center;
background-color: var(--background-color);
color: var(--button-color);
display: flex;
font-family: inherit;
justify-content: center;
margin: var(--margin, 0);
min-width: var(--border, 0);
padding: var(--padding, 5px 10px);
@apply --gr-button;
}
paper-button:hover {
background: linear-gradient(
rgba(0, 0, 0, .12),
rgba(0, 0, 0, .12)
), var(--background-color);
}
/* Styles for raised buttons specifically */
:host([primary][raised]),
:host([secondary][raised]) {
--background-color: var(--color-link);
--button-color: #fff;
}
/* Keep below color definition for primary/secondary so that this takes
precedence when disabled. */
:host([disabled]) {
--background-color: #eaeaea;
--button-color: #a8a8a8;
cursor: default;
}
/* Styles for link buttons specifically */
:host([link]) {
--background-color: transparent;
--margin: 0;
--padding: 5px 4px;
}
:host([disabled][link]) {
--background-color: transparent;
}
:host([link][tertiary]) {
--button-color: var(--color-link-tertiary);
}
/* Styles for the optional down arrow */
:host:not([down-arrow]) .downArrow {display: none; }
:host([down-arrow]) .downArrow {
border-top: .36em solid #ccc;
border-left: .36em solid transparent;
border-right: .36em solid transparent;
margin-bottom: .05em;
margin-left: .5em;
transition: border-top-color 200ms;
}
:host([down-arrow]) paper-button:hover .downArrow {
border-top-color: #666;
}
</style>
<paper-button
raised="[[!link]]"
disabled="[[_computeDisabled(disabled, loading)]]"
tabindex="-1">
<slot></slot>
<i class="downArrow"></i>
</paper-button>
</template>
<script src="gr-button.js"></script>
</dom-module>