mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
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:
1 parent
1504e182e4
commit
ec62f331b8
4 files changed
+97
-21
No files matched your search
@@ -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%)
|
||||
}
|
||||
|
||||
@@ -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';
|
||||
Reference in new issue
Block a user