From 127b1d128bc7b5cc6a89f6ddfb6b0873c1654612 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Sun, 24 Oct 2021 11:09:43 +0200 Subject: [PATCH] Made checkboxes design --- public/html/settings.html | 8 +++++-- src/sass/settings.sass | 47 ++++++++++++++++++++++++++++++++++++++- src/ts/settings.ts | 15 ++++++++++--- 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/public/html/settings.html b/public/html/settings.html index 4aef602..f3cebfb 100644 --- a/public/html/settings.html +++ b/public/html/settings.html @@ -56,9 +56,13 @@
-

Discord RPC

+
+ Discord RPC - +
+ +
+

diff --git a/src/sass/settings.sass b/src/sass/settings.sass index 6b81faa..fd655ab 100644 --- a/src/sass/settings.sass +++ b/src/sass/settings.sass @@ -112,4 +112,49 @@ body background-color: #f1f4f9 font-size: 18px - cursor: pointer \ No newline at end of file + cursor: pointer + +.checkbox + display: inline-flex + align-items: center + + font-size: larger + + width: calc(100% - 24px) + height: 48px + padding: 0 12px + + border-radius: 12px + + cursor: pointer + + &:hover + background-color: #eff2ff + + .checkbox-mark + display: flex + + background-color: #e1e7ff + + border-radius: 16px + margin-left: auto + padding: 8px 16px + + &:hover + background-color: #657ef8 + + svg + filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(219deg) brightness(102%) contrast(104%) + + svg + height: 12px + width: 12px + +.checkbox-active + background-color: #eff2ff + + .checkbox-mark + background-color: #657ef8 + + svg + filter: invert(100%) sepia(0%) saturate(0%) hue-rotate(219deg) brightness(102%) contrast(104%) diff --git a/src/ts/settings.ts b/src/ts/settings.ts index cd627d3..dc000b2 100644 --- a/src/ts/settings.ts +++ b/src/ts/settings.ts @@ -29,16 +29,25 @@ $(() => { $(`.menu-item[anchor=${anchor}]`).addClass('menu-item-active'); }); + $('.checkbox').on('click', (e) => { + let item = $(e.target); + + while (!item.hasClass('checkbox')) + item = item.parent(); + + item.toggleClass('checkbox-active').trigger('classChange'); + }); + // Select the saved options in launcher.json on load $(`#voice-list option[value="${Genshinlib.lang.voice}"]`).prop('selected', true); $(`#language-list option[value="${Genshinlib.lang.launcher}"]`).prop('selected', true); if (Genshinlib.getConfig('rpc')) - $('#drpc').prop('checked', true); + $('#discord-rpc').addClass('checkbox-active'); - $('#drpc').on('change', () => { + $('#discord-rpc').on('classChange', () => { Genshinlib.updateConfig({ - rpc: $('#drpc').prop('checked') + rpc: $('#discord-rpc').hasClass('checkbox-active') }); ipcRenderer.send('rpc-toggle');