Copy to clipboard button UI improvements

- Make the button size of the text
- Add tooltip

Bug: Issue 7997
Change-Id: Ifccb62dcfe984ad9c54e7b15fb2f2119b02c861f
This commit is contained in:
Viktar Donich 2017-12-18 15:21:58 -08:00
parent 4fdafe1396
commit e8bc56a822
4 changed files with 34 additions and 4 deletions

View File

@ -25,6 +25,9 @@ limitations under the License.
align-items: center; align-items: center;
display: flex; display: flex;
} }
gr-copy-clipboard {
padding-left: .5em;
}
</style> </style>
<div class="container"> <div class="container">
<template is="dom-if" if="[[_showWebLink]]"> <template is="dom-if" if="[[_showWebLink]]">
@ -35,7 +38,10 @@ limitations under the License.
[[_computeShortHash(commitInfo)]] [[_computeShortHash(commitInfo)]]
</template> </template>
<gr-copy-clipboard <gr-copy-clipboard
has-tooltip
button-title="Copy full SHA to clipboard"
hide-input hide-input
hide-label
text="[[commitInfo.commit]]"> text="[[commitInfo.commit]]">
</gr-copy-clipboard> </gr-copy-clipboard>
</div> </div>

View File

@ -36,18 +36,20 @@ limitations under the License.
flex-grow: 1; flex-grow: 1;
margin-right: .3em; margin-right: .3em;
} }
.hideInput { .hideInput,
.hideLabel label {
display: none; display: none;
} }
input { input {
font-family: var(--monospace-font-family); font-family: var(--monospace-font-family);
font-size: inherit; font-size: inherit;
} }
#button { #icon {
padding-left: .5em; height: 1.2em;
width: 1.2em;
} }
</style> </style>
<div class="text"> <div class$="text [[_computeLabelClass(hideLabel)]]">
<label>[[title]]</label> <label>[[title]]</label>
<input id="input" is="iron-input" <input id="input" is="iron-input"
class$="copyText [[_computeInputClass(hideInput)]]" class$="copyText [[_computeInputClass(hideInput)]]"
@ -57,7 +59,9 @@ limitations under the License.
readonly> readonly>
<gr-button id="button" <gr-button id="button"
link link
has-tooltip="[[hasTooltip]]"
class="copyToClipboard" class="copyToClipboard"
title="[[buttonTitle]]"
on-tap="_copyToClipboard"> on-tap="_copyToClipboard">
<iron-icon id="icon" icon="gr-icons:content-copy"></iron-icon> <iron-icon id="icon" icon="gr-icons:content-copy"></iron-icon>
</gr-button> </gr-button>

View File

@ -22,10 +22,19 @@
properties: { properties: {
text: String, text: String,
title: String, title: String,
buttonTitle: String,
hasTooltip: {
type: Boolean,
value: false,
},
hideInput: { hideInput: {
type: Boolean, type: Boolean,
value: false, value: false,
}, },
hideLabel: {
type: Boolean,
value: false,
},
}, },
focusOnCopy() { focusOnCopy() {
@ -36,6 +45,10 @@
return hideInput ? 'hideInput' : ''; return hideInput ? 'hideInput' : '';
}, },
_computeLabelClass(hideLabel) {
return hideLabel ? 'hideLabel' : '';
},
_handleInputTap(e) { _handleInputTap(e) {
e.preventDefault(); e.preventDefault();
Polymer.dom(e).rootTarget.select(); Polymer.dom(e).rootTarget.select();

View File

@ -78,5 +78,12 @@ limitations under the License.
flushAsynchronousOperations(); flushAsynchronousOperations();
assert.equal(getComputedStyle(element.$.input).display, 'none'); assert.equal(getComputedStyle(element.$.input).display, 'none');
}); });
test('hideLabel', () => {
assert.notEqual(getComputedStyle(element.$$('label')).display, 'none');
element.hideLabel = true;
flushAsynchronousOperations();
assert.equal(getComputedStyle(element.$$('label')).display, 'none');
});
}); });
</script> </script>