From 82aa5ab1140929f730cbafc42560b8c7b53830ea Mon Sep 17 00:00:00 2001 From: Nicola <47360416+unsettledgames@users.noreply.github.com> Date: Mon, 31 Jan 2022 00:16:27 +0100 Subject: [PATCH] Fixed topbar css Aded InputComponents.js to take care (dynamically create, add events) of input elements. --- build.js | 2 +- css/_components.scss | 56 +++++++++++++++++++++++++++++++++ css/_main-menu.scss | 12 +++---- css/pixel-editor.scss | 1 + js/InputComponents.js | 59 +++++++++++++++++++++++++++++++++++ js/pixel-editor.js | 6 ++-- svg/check.svg | 10 ++++++ views/components/checkbox.hbs | 7 +++++ views/main-menu.hbs | 2 +- 9 files changed, 144 insertions(+), 11 deletions(-) create mode 100644 css/_components.scss create mode 100644 js/InputComponents.js create mode 100644 svg/check.svg create mode 100644 views/components/checkbox.hbs diff --git a/build.js b/build.js index 1172994..410972b 100644 --- a/build.js +++ b/build.js @@ -56,7 +56,7 @@ function compile_page(){ .pipe(handlebars({encoding: 'utf8', debug: true, bustCache: true}) .partials('./views/[!index]*.hbs').partials('./views/popups/*.hbs') - //.helpers({ svg: hb_svg }) + .partials('./views/components/*.hbs') .helpers('./helpers/**/*.js') .data({ projectSlug: 'pixel-editor', diff --git a/css/_components.scss b/css/_components.scss new file mode 100644 index 0000000..32bd510 --- /dev/null +++ b/css/_components.scss @@ -0,0 +1,56 @@ +.checkbox-holder { + position:relative; + width:15px; + height:15px; + display:block; + + .checkbox { + display: inline-block; + cursor: pointer; + padding-right: 1em; + + .box { + color: $basetext; + background: darken($basecolor, 5%); + border: none; + padding: 0.5rem; + border-radius: 0.5rem; + box-sizing: border-box; + margin-right: 0.5rem; + display: inline-block; + vertical-align: middle; + border: solid 2px $basecolor; + pointer-events: none; + + svg { + visibility: hidden; + width: 1em; + height: 1em; + display: block; + path { + fill: $basetext; + } + } + + } + + //checked + &.checked .box svg { + visibility: visible; + } + + label { + display: inline-block; + pointer-events: none; + } //hover label or box + + &:hover:not(.disabled){ + border-color: $basecolor; + } + + &.disabled { + cursor: not-allowed; + .box svg path {fill: $basetext;} + } + } +} \ No newline at end of file diff --git a/css/_main-menu.scss b/css/_main-menu.scss index b9c6532..73c5352 100644 --- a/css/_main-menu.scss +++ b/css/_main-menu.scss @@ -108,6 +108,11 @@ li#editor-info { display:inline; padding-right:20px; } + + .checkbox-holder { + display: inline; + } + input { margin-left:10px; background-color:darken($basecolor, 6%); @@ -122,12 +127,5 @@ li#editor-info { width:25px; height:15px; } - - input[type=checkbox] { - padding:1px; - width:20px; - height:20px; - background-color:darken($basecolor, 5%) !important; - } } } \ No newline at end of file diff --git a/css/pixel-editor.scss b/css/pixel-editor.scss index eb94914..4f24dae 100644 --- a/css/pixel-editor.scss +++ b/css/pixel-editor.scss @@ -2,6 +2,7 @@ @import 'general'; @import 'zindex'; @import 'shake'; +@import 'components'; @import 'help'; @import 'layers'; @import 'canvas'; diff --git a/js/InputComponents.js b/js/InputComponents.js new file mode 100644 index 0000000..bc75392 --- /dev/null +++ b/js/InputComponents.js @@ -0,0 +1,59 @@ +const InputComponents = (() => { + setInputEvents(); + + function setInputEvents() { + // Make the checkboxes toggleable + let checkboxes = document.getElementsByClassName("checkbox"); + for (let i=0; i + + + + diff --git a/views/components/checkbox.hbs b/views/components/checkbox.hbs new file mode 100644 index 0000000..531e98c --- /dev/null +++ b/views/components/checkbox.hbs @@ -0,0 +1,7 @@ +
+
+ + +
{{svg "check"}}
+
+
\ No newline at end of file diff --git a/views/main-menu.hbs b/views/main-menu.hbs index 18c03e9..1457cc1 100644 --- a/views/main-menu.hbs +++ b/views/main-menu.hbs @@ -69,7 +69,7 @@
  • \ No newline at end of file