app: Implement toggle button in app page

- revamp the old form submission model to enable/disable apps into a
  simple toggle button
- provide backwards compatibility when javascript is disabled

Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
This commit is contained in:
Alice Kile authored and Joseph Nuthalapati committed 2019-11-19 00:02:16 +05:30
1 parent 1504e182e4
commit ec62f331b8
4 files changed
+97 -21

No files matched your search

+43
View File
@@ -464,3 +464,46 @@ a.menu_link_active {
.names-domain-column {
width: 50%;
}
.toggle-button-container {
display: none;
flex-flow: row;
justify-content: flex-end;
}
.toggle-button-container .form-group {
display: none;
}
.toggle-button {
border-radius: 25px;
border: none;
width: 55px;
height: 25px;
background: #ccc;
position: relative;
}
.toggle-button::before {
content: '';
display: block;
height: 18px;
width: 18px;
border-radius: 100%;
background: #fff;
position: absolute;
top: 50%;
left: 6%;
transform: translateY(-50%);
}
.toggle-button--toggled {
background: #337ab7;
}
.toggle-button--toggled::before {
content: '';
position: absolute;
top: 50%;
left: 100%;
transform: translateY(-50%) translateX(-116%)
}
+18
View File
@@ -0,0 +1,18 @@
const appToggleForm = document.querySelector('#app-toggle')
const appToggleContainer = appToggleForm.parentElement
const appToggleInput = document.querySelector('#app-toggle-input')
const onSubmit = (e) => {
e.preventDefault
appToggleInput.checked = !appToggleInput.checked
appToggleForm.submit()
}
appToggleForm.addEventListener('submit', onSubmit)
/**
* if javascript is enabled, this script will run and show the toggle button
*/
appToggleContainer.style.display = 'flex';