Major refactor of button styles

Declares several CSS variables for styling buttons throughout the app
and uses them.

Removes the concept of a 'tertiary' button -- primary and secondary have
the exact same styling, so all tertiary buttons are changed to secondary
buttons and the existing secondary button (only replyBtn) is changed to
a primary button.

Also removes some of the many ways to modify a button color and
background -- there is no need for mixins to specifically style various
attributes of the paper-button when the ability to apply any styles
directly to it (via @apply --gr-button) is already supported.

Change-Id: I19a4114764df80b06175032b228a6ec63b414089
This commit is contained in:
Kasper Nilsson
2018-04-17 09:08:47 +02:00
parent ae1542ca31
commit 6fa20d3b3d
16 changed files with 74 additions and 65 deletions

View File

@@ -244,11 +244,11 @@ limitations under the License.
background-color: var(--table-header-background-color); background-color: var(--table-header-background-color);
border-top: 1px solid var(--border-color); border-top: 1px solid var(--border-color);
height: 3rem; height: 3rem;
--paper-tabs-selection-bar-color: var(--color-link); --paper-tabs-selection-bar-color: var(--link-color);
} }
paper-tab { paper-tab {
max-width: 15rem; max-width: 15rem;
--paper-tab-ink: var(--color-link); --paper-tab-ink: var(--link-color);
} }
gr-thread-list, gr-thread-list,
gr-messages-list { gr-messages-list {
@@ -425,7 +425,7 @@ limitations under the License.
id="replyBtn" id="replyBtn"
class="reply" class="reply"
hidden$="[[!_loggedIn]]" hidden$="[[!_loggedIn]]"
secondary primary
disabled="[[_replyDisabled]]" disabled="[[_replyDisabled]]"
on-tap="_handleReplyTap">[[_replyButtonLabel]]</gr-button> on-tap="_handleReplyTap">[[_replyButtonLabel]]</gr-button>
</div> </div>

View File

@@ -178,7 +178,7 @@ limitations under the License.
display: none; display: none;
} }
label.show-hide { label.show-hide {
color: var(--color-link); color: var(--link-color);
cursor: pointer; cursor: pointer;
display: block; display: block;
font-size: var(--font-size-small); font-size: var(--font-size-small);
@@ -203,7 +203,7 @@ limitations under the License.
width: 15em; width: 15em;
} }
.reviewed label { .reviewed label {
color: var(--color-link); color: var(--link-color);
opacity: 0; opacity: 0;
justify-content: flex-end; justify-content: flex-end;
width: 100%; width: 100%;

View File

@@ -58,25 +58,25 @@ limitations under the License.
gr-button { gr-button {
min-width: 40px; min-width: 40px;
--gr-button: { --gr-button: {
background-color: var(--button-background-color, #f5f5f5);
color: var(--primary-text-color);
padding: .2em .85em; padding: .2em .85em;
@apply(--vote-chip-styles); @apply(--vote-chip-styles);
} }
--gr-button-background: var(--button-background-color, #f5f5f5);
--gr-button-color: var(--primary-text-color);
} }
iron-selector > gr-button.iron-selected.max { gr-button.iron-selected.max {
--button-background-color: var(--vote-color-max); --button-background-color: var(--vote-color-max);
} }
iron-selector > gr-button.iron-selected.positive { gr-button.iron-selected.positive {
--button-background-color: var(--vote-color-positive); --button-background-color: var(--vote-color-positive);
} }
iron-selector > gr-button.iron-selected.min { gr-button.iron-selected.min {
--button-background-color: var(--vote-color-min); --button-background-color: var(--vote-color-min);
} }
iron-selector > gr-button.iron-selected.negative { gr-button.iron-selected.negative {
--button-background-color: var(--vote-color-negative); --button-background-color: var(--vote-color-negative);
} }
iron-selector > gr-button.iron-selected.neutral { gr-button.iron-selected.neutral {
--button-background-color: var(--vote-color-neutral); --button-background-color: var(--vote-color-neutral);
} }
.placeholder { .placeholder {

View File

@@ -267,7 +267,7 @@ limitations under the License.
<template is="dom-if" if="[[canBeStarted]]"> <template is="dom-if" if="[[canBeStarted]]">
<gr-button <gr-button
link link
tertiary secondary
disabled="[[_isState(knownLatestState, 'not-latest')]]" disabled="[[_isState(knownLatestState, 'not-latest')]]"
class="action save" class="action save"
has-tooltip has-tooltip

View File

@@ -28,7 +28,6 @@ limitations under the License.
<style include="shared-styles"> <style include="shared-styles">
gr-button { gr-button {
margin-left: .5em; margin-left: .5em;
--gr-button-color: #212121;
} }
#actions { #actions {
margin-left: auto; margin-left: auto;
@@ -94,21 +93,25 @@ limitations under the License.
<gr-button <gr-button
id="replyBtn" id="replyBtn"
link link
secondary
class="action reply" class="action reply"
on-tap="_handleCommentReply">Reply</gr-button> on-tap="_handleCommentReply">Reply</gr-button>
<gr-button <gr-button
id="quoteBtn" id="quoteBtn"
link link
secondary
class="action quote" class="action quote"
on-tap="_handleCommentQuote">Quote</gr-button> on-tap="_handleCommentQuote">Quote</gr-button>
<gr-button <gr-button
id="ackBtn" id="ackBtn"
link link
secondary
class="action ack" class="action ack"
on-tap="_handleCommentAck">Ack</gr-button> on-tap="_handleCommentAck">Ack</gr-button>
<gr-button <gr-button
id="doneBtn" id="doneBtn"
link link
secondary
class="action done" class="action done"
on-tap="_handleCommentDone">Done</gr-button> on-tap="_handleCommentDone">Done</gr-button>
</div> </div>

View File

@@ -97,7 +97,6 @@ limitations under the License.
} }
.action { .action {
margin-left: 1em; margin-left: 1em;
--gr-button-color: #212121;
} }
.robotActions { .robotActions {
display: flex; display: flex;
@@ -249,6 +248,7 @@ limitations under the License.
<gr-button <gr-button
id="deleteBtn" id="deleteBtn"
link link
secondary
class$="action delete [[_computeDeleteButtonClass(_isAdmin, draft)]]" class$="action delete [[_computeDeleteButtonClass(_isAdmin, draft)]]"
on-tap="_handleCommentDelete"> on-tap="_handleCommentDelete">
(Delete) (Delete)
@@ -314,21 +314,35 @@ limitations under the License.
</label> </label>
</div> </div>
<div class="rightActions"> <div class="rightActions">
<gr-button link class="action cancel hideOnPublished" <gr-button
link
secondary
class="action cancel hideOnPublished"
on-tap="_handleCancel">Cancel</gr-button> on-tap="_handleCancel">Cancel</gr-button>
<gr-button link class="action discard hideOnPublished" <gr-button
link
secondary
class="action discard hideOnPublished"
on-tap="_handleDiscard">Discard</gr-button> on-tap="_handleDiscard">Discard</gr-button>
<gr-button link class="action edit hideOnPublished" <gr-button
link
secondary
class="action edit hideOnPublished"
on-tap="_handleEdit">Edit</gr-button> on-tap="_handleEdit">Edit</gr-button>
<gr-button link class="action save hideOnPublished" <gr-button
on-tap="_handleSave" link
disabled$="[[_computeSaveDisabled(_messageText, comment, resolved)]]">Save secondary
</gr-button> disabled$="[[_computeSaveDisabled(_messageText, comment, resolved)]]"
class="action save hideOnPublished"
on-tap="_handleSave">Save</gr-button>
</div> </div>
</div> </div>
<div class="robotActions" hidden$="[[!_showRobotActions]]"> <div class="robotActions" hidden$="[[!_showRobotActions]]">
<template is="dom-if" if="[[isRobotComment]]"> <template is="dom-if" if="[[isRobotComment]]">
<gr-button link class="action fix" <gr-button
link
secondary
class="action fix"
on-tap="_handleFix" on-tap="_handleFix"
disabled="[[robotButtonDisabled]]"> disabled="[[robotButtonDisabled]]">
Please Fix Please Fix

View File

@@ -28,7 +28,7 @@ limitations under the License.
display: flex; display: flex;
} }
gr-button.selected iron-icon { gr-button.selected iron-icon {
color: var(--color-link); color: var(--link-color);
} }
iron-icon { iron-icon {
height: 1.3rem; height: 1.3rem;

View File

@@ -164,7 +164,6 @@ limitations under the License.
.contextControl gr-button { .contextControl gr-button {
display: inline-block; display: inline-block;
text-decoration: none; text-decoration: none;
--gr-button-color: var(--deemphasized-text-color);
--gr-button: { --gr-button: {
padding: .2em; padding: .2em;
} }

View File

@@ -44,7 +44,7 @@ limitations under the License.
--gr-dropdown-item: { --gr-dropdown-item: {
background-color: transparent; background-color: transparent;
border: none; border: none;
color: var(--color-link); color: var(--link-color);
font-size: inherit; font-size: inherit;
text-transform: uppercase; text-transform: uppercase;
} }

View File

@@ -27,8 +27,8 @@ limitations under the License.
<style include="shared-styles"> <style include="shared-styles">
/* general styles for all buttons */ /* general styles for all buttons */
:host { :host {
--background-color: var(--gr-button-background, var(--view-background-color)); --background-color: var(--button-background-color, var(--default-button-background-color));
--button-color: var(--gr-button-color, var(--color-link)); --text-color: var(--default-button-text-color);
display: inline-block; display: inline-block;
font-family: var(--font-family-bold); font-family: var(--font-family-bold);
font-size: var(--font-size-small); font-size: var(--font-size-small);
@@ -46,7 +46,7 @@ limitations under the License.
-webkit-font-smoothing: initial; -webkit-font-smoothing: initial;
align-items: center; align-items: center;
background-color: var(--background-color); background-color: var(--background-color);
color: var(--button-color); color: var(--text-color);
display: flex; display: flex;
font-family: inherit; font-family: inherit;
justify-content: center; justify-content: center;
@@ -62,18 +62,26 @@ limitations under the License.
), var(--background-color); ), var(--background-color);
} }
/* Styles for raised buttons specifically */ :host([primary]) {
:host([primary][raised]), --background-color: var(--primary-button-background-color);
:host([secondary][raised]) { --text-color: var(--primary-button-text-color);
--background-color: var(--color-link); }
--button-color: var(--view-background-color); :host([link][primary]) {
--text-color: var(--primary-button-background-color);
}
:host([secondary]) {
--background-color: var(--secondary-button-text-color);
--text-color: var(--secondary-button-background-color);
}
:host([link][secondary]) {
--text-color: var(--secondary-button-text-color);
} }
/* Keep below color definition for primary/secondary so that this takes /* Keep below color definition for primary so that this takes precedence
precedence when disabled. */ when disabled. */
:host([disabled]) { :host([disabled]) {
--background-color: var(--table-subheader-background-color); --background-color: var(--table-subheader-background-color);
--button-color: var(--deemphasized-text-color); --text-color: var(--deemphasized-text-color);
cursor: default; cursor: default;
} }
@@ -86,9 +94,6 @@ limitations under the License.
:host([disabled][link]) { :host([disabled][link]) {
--background-color: transparent; --background-color: transparent;
} }
:host([link][tertiary]) {
--button-color: var(--color-link-tertiary);
}
/* Styles for the optional down arrow */ /* Styles for the optional down arrow */
:host:not([down-arrow]) .downArrow {display: none; } :host:not([down-arrow]) .downArrow {display: none; }

View File

@@ -31,21 +31,11 @@
value: false, value: false,
reflectToAttribute: true, reflectToAttribute: true,
}, },
raised: {
type: Boolean,
reflectToAttribute: true,
computed: '_isRaised(link)',
},
loading: { loading: {
type: Boolean, type: Boolean,
value: false, value: false,
reflectToAttribute: true, reflectToAttribute: true,
}, },
tertiary: {
type: Boolean,
value: false,
reflectToAttribute: true,
},
disabled: { disabled: {
type: Boolean, type: Boolean,
observer: '_disabledChanged', observer: '_disabledChanged',
@@ -81,10 +71,6 @@
tabindex: '0', tabindex: '0',
}, },
_isRaised(isLink) {
return !isLink;
},
_handleAction(e) { _handleAction(e) {
if (this.disabled) { if (this.disabled) {
e.preventDefault(); e.preventDefault();

View File

@@ -28,7 +28,7 @@ limitations under the License.
cursor: pointer; cursor: pointer;
} }
iron-icon.active { iron-icon.active {
fill: var(--color-link); fill: var(--link-color);
} }
</style> </style>
<button aria-label="Change star" on-tap="toggleStar"> <button aria-label="Change star" on-tap="toggleStar">

View File

@@ -48,7 +48,7 @@ limitations under the License.
@apply --label-style; @apply --label-style;
} }
label.editable { label.editable {
color: var(--color-link); color: var(--link-color);
cursor: pointer; cursor: pointer;
} }
#dropdown { #dropdown {

View File

@@ -27,7 +27,7 @@ limitations under the License.
background-color: var(--tooltip-background-color, #333); background-color: var(--tooltip-background-color, #333);
box-shadow: 0 1px 3px rgba(0, 0, 0, .3); box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
color: var(--view-background-color); color: #fff;
font-size: var(--font-size-small); font-size: var(--font-size-small);
position: absolute; position: absolute;
z-index: 1000; z-index: 1000;

View File

@@ -49,11 +49,13 @@ limitations under the License.
--font-size-small: .92rem; --font-size-small: .92rem;
--font-size-large: 1.076rem; --font-size-large: 1.076rem;
/* Follow are a part of the design refresh */ --link-color: #2a66d9;
--color-link: #2a66d9; --primary-button-background-color: var(--link-color);
--color-link-tertiary: #000; --primary-button-text-color: #fff;
/* 12% darker */ --secondary-button-background-color: #fff;
--color-button-hover: #0B47BA; --secondary-button-text-color: #212121;
--default-button-background-color: #fff;
--default-button-text-color: var(--link-color);
/* Used for both the old patchset header and for indicating that a particular /* Used for both the old patchset header and for indicating that a particular
change message was selected. */ change message was selected. */

View File

@@ -41,7 +41,7 @@ limitations under the License.
padding: 0; padding: 0;
} }
a { a {
color: var(--color-link); color: var(--link-color);
} }
input, input,
textarea, textarea,
@@ -98,8 +98,8 @@ limitations under the License.
border-color: transparent; border-color: transparent;
} }
paper-toggle-button { paper-toggle-button {
--paper-toggle-button-checked-bar-color: var(--color-link); --paper-toggle-button-checked-bar-color: var(--link-color);
--paper-toggle-button-checked-button-color: var(--color-link); --paper-toggle-button-checked-button-color: var(--link-color);
} }
strong { strong {
font-family: var(--font-family-bold); font-family: var(--font-family-bold);