Install usercss (#269)

install-usercss: restyle "Install style" button
This commit is contained in:
Rob Garrison 2017-12-01 17:43:01 -06:00 committed by tophf
parent 0eaee16f7e
commit 3c0b14a477
4 changed files with 90 additions and 8 deletions

View File

@ -426,19 +426,19 @@
"description": "Label for the button to import and overwrite current style"
},
"installButton": {
"message": "Install",
"message": "Install style",
"description": "Label for install button"
},
"installButtonInstalled": {
"message": "Installed",
"message": "Style installed",
"description": "Text displayed when the style is successfully installed"
},
"installButtonUpdate": {
"message": "Update",
"message": "Update style",
"description": "Label for update button"
},
"installButtonReinstall": {
"message": "Reinstall",
"message": "Reinstall style",
"description": "Label for reinstall button"
},
"installUpdate": {

View File

@ -57,6 +57,7 @@
<small class="meta-version"></small>
</h1>
<div class="actions">
<h2 class="installed" i18n-text="installButtonInstalled"></h2>
<button class="install" i18n-text="installButton"></button>
<label class="set-update-url">
<input type="checkbox">

View File

@ -114,9 +114,74 @@ h1 small {
}
.install {
padding: 1ex 1em;
font-family: Arial, "DejaVu Sans", Verdana, Geneva, sans-serif;
font-size: 14px;
background: linear-gradient(#666, #555);
color: white;
border-radius: 4px;
padding: 4px 38px 4px 10px;
position: relative;
display: inline-block;
text-shadow: 1px 1px 1px #333;
-webkit-appearance: none;
-moz-appearance: none;
border-style: none;
margin-bottom: 1ex;
cursor: pointer;
box-shadow: inset 0 -1px 0 0 hsl(0, 0%, 24%), inset 0 1px 0 0 hsl(0, 0%, 30%), inset 1px 0 0 0 hsl(0, 0%, 24%);
}
.install:before,
.install:after {
content: "";
vertical-align: middle;
box-sizing: border-box;
border-radius: 0 4px 4px 0;
position: absolute;
right: 0;
top: 0;
bottom: 0;
width: 30px;
}
.install:before {
background-image: linear-gradient(hsl(176, 44%, 40%), hsl(176, 50%, 35%));
box-shadow: inset 0 -1px 0 0 hsl(0, 0%, 24%), inset 0 1px 0 0 hsl(0, 0%, 30%), inset 1px 0 0 0 rgba(0, 0, 0, .3), inset -1px 0 0 0 hsl(0, 0%, 38%);
padding: 5px 8px;
}
.install:after {
background-image: url(../images/icon/16.png);
background-repeat: no-repeat;
background-position: center center;
}
.install:hover {
filter: brightness(1.1);
color: #eee;
text-shadow: none;
}
.install.reinstall:after {
background-color: #333;
filter: grayscale(100%);
}
.install.update:before,
.install.update:after {
filter: hue-rotate(-18deg) brightness(.7) contrast(2);
}
.install.installed,
h2.installed {
display: none;
}
h2.installed.active {
display: inline-block;
font-weight: bold;
margin-bottom: 1ex;
margin-top: 0;
}
.actions label input {
@ -431,3 +496,11 @@ li {
padding-bottom: unset;
}
}
/* Retina-specific stuff here */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
.install:after {
background-image: url(../images/icon/32.png);
background-size: 16px 16px;
}
}

View File

@ -82,6 +82,7 @@
document.title = `${installButtonLabel()} ${data.name}`;
$('.install').textContent = installButtonLabel();
$('.install').classList.add(installButtonClass());
$('.set-update-url').title = dup && dup.updateUrl && t('installUpdateFrom', dup.updateUrl) || '';
$('.meta-name').textContent = data.name;
$('.meta-version').textContent = data.version;
@ -111,7 +112,7 @@
$('.header').classList.add('meta-init');
$('.header').classList.remove('meta-init-error');
setTimeout(() => $('.lds-spinner').remove(), 1000);
setTimeout(() => $('.lds-spinner') && $('.lds-spinner').remove(), 1000);
showError('');
requestAnimationFrame(adjustCodeHeight);
@ -166,6 +167,12 @@
}
}
function installButtonClass() {
return installed ? 'installed' :
!dup ? 'install' :
versionTest > 0 ? 'update' : 'reinstall';
}
function installButtonLabel() {
return t(
installed ? 'installButtonInstalled' :
@ -190,8 +197,9 @@
$$('.warning')
.forEach(el => el.remove());
$('.install').disabled = true;
$('.install').classList.add('installed');
$('button.install').disabled = true;
$('button.install').classList.add('installed');
$('h2.installed').classList.add('active');
$('.set-update-url input[type=checkbox]').disabled = true;
$('.set-update-url').title = style.updateUrl ?
t('installUpdateFrom', style.updateUrl) : '';