Install-usercss: Style install button

This commit is contained in:
Rob Garrison 2017-11-30 13:38:33 -06:00
parent a79da0738e
commit 73a41b2e90
4 changed files with 73 additions and 7 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,7 +114,64 @@ 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: 6px 35px 6px 8px;
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;
}
.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(#0bb, #0aa);
border-left: 1px solid rgba(128, 128, 128, .4);
padding: 5px 8px;
}
.install:after {
background-image: url(../images/icon/16.png);
background-repeat: no-repeat;
background-position: center center;
}
.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;
}

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;
@ -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) : '';