about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/packs
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-10-31 18:25:34 +0100
committerGitHub <noreply@github.com>2022-10-31 18:25:34 +0100
commit968f34300681d8082cf2f824722a3945fc604b2d (patch)
tree910675cc3b8d9022f65bcfa9bee1acee6af8d0e4 /app/javascript/flavours/glitch/packs
parent371563b0e249b6369e04709fb974a8e57413529f (diff)
parent1fe4e5e38c17a726e6aea5d6033139653e89a379 (diff)
Merge pull request #1876 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/javascript/flavours/glitch/packs')
-rw-r--r--app/javascript/flavours/glitch/packs/about.js23
-rw-r--r--app/javascript/flavours/glitch/packs/public.js32
-rw-r--r--app/javascript/flavours/glitch/packs/settings.js25
3 files changed, 48 insertions, 32 deletions
diff --git a/app/javascript/flavours/glitch/packs/about.js b/app/javascript/flavours/glitch/packs/about.js
deleted file mode 100644
index ef17fdea4..000000000
--- a/app/javascript/flavours/glitch/packs/about.js
+++ /dev/null
@@ -1,23 +0,0 @@
-import 'packs/public-path';
-import loadPolyfills from 'flavours/glitch/load_polyfills';
-
-function loaded() {
-  const TimelineContainer = require('flavours/glitch/containers/timeline_container').default;
-  const React             = require('react');
-  const ReactDOM          = require('react-dom');
-  const mountNode         = document.getElementById('mastodon-timeline');
-
-  if (mountNode !== null) {
-    const props = JSON.parse(mountNode.getAttribute('data-props'));
-    ReactDOM.render(<TimelineContainer {...props} />, mountNode);
-  }
-}
-
-function main() {
-  const ready = require('flavours/glitch/ready').default;
-  ready(loaded);
-}
-
-loadPolyfills().then(main).catch(error => {
-  console.error(error);
-});
diff --git a/app/javascript/flavours/glitch/packs/public.js b/app/javascript/flavours/glitch/packs/public.js
index ae1899638..843fd5163 100644
--- a/app/javascript/flavours/glitch/packs/public.js
+++ b/app/javascript/flavours/glitch/packs/public.js
@@ -12,7 +12,6 @@ function main() {
   const { messages } = getLocale();
   const React = require('react');
   const ReactDOM = require('react-dom');
-  const Rellax = require('rellax');
   const { createBrowserHistory } = require('history');
 
   const scrollToDetailedStatus = () => {
@@ -90,12 +89,6 @@ function main() {
       scrollToDetailedStatus();
     }
 
-    const parallaxComponents = document.querySelectorAll('.parallax');
-
-    if (parallaxComponents.length > 0 ) {
-      new Rellax('.parallax', { speed: -1 });
-    }
-
     delegate(document, '#registration_user_password_confirmation,#registration_user_password', 'input', () => {
       const password = document.getElementById('registration_user_password');
       const confirmation = document.getElementById('registration_user_password_confirmation');
@@ -146,8 +139,31 @@ function main() {
     });
   });
 
+  const toggleSidebar = () => {
+    const sidebar = document.querySelector('.sidebar ul');
+    const toggleButton = document.querySelector('.sidebar__toggle__icon');
+
+    if (sidebar.classList.contains('visible')) {
+      document.body.style.overflow = null;
+      toggleButton.setAttribute('aria-expanded', false);
+    } else {
+      document.body.style.overflow = 'hidden';
+      toggleButton.setAttribute('aria-expanded', true);
+    }
+
+    toggleButton.classList.toggle('active');
+    sidebar.classList.toggle('visible');
+  };
+
   delegate(document, '.sidebar__toggle__icon', 'click', () => {
-    document.querySelector('.sidebar ul').classList.toggle('visible');
+    toggleSidebar();
+  });
+
+  delegate(document, '.sidebar__toggle__icon', 'keydown', e => {
+    if (e.key === ' ' || e.key === 'Enter') {
+      e.preventDefault();
+      toggleSidebar();
+    }
   });
 
   // Empty the honeypot fields in JS in case something like an extension
diff --git a/app/javascript/flavours/glitch/packs/settings.js b/app/javascript/flavours/glitch/packs/settings.js
index 4c85f6556..31c88b2b5 100644
--- a/app/javascript/flavours/glitch/packs/settings.js
+++ b/app/javascript/flavours/glitch/packs/settings.js
@@ -7,8 +7,31 @@ import 'cocoon-js-vanilla';
 function main() {
   const { delegate } = require('@rails/ujs');
 
+  const toggleSidebar = () => {
+    const sidebar = document.querySelector('.sidebar ul');
+    const toggleButton = document.querySelector('.sidebar__toggle__icon');
+
+    if (sidebar.classList.contains('visible')) {
+      document.body.style.overflow = null;
+      toggleButton.setAttribute('aria-expanded', false);
+    } else {
+      document.body.style.overflow = 'hidden';
+      toggleButton.setAttribute('aria-expanded', true);
+    }
+
+    toggleButton.classList.toggle('active');
+    sidebar.classList.toggle('visible');
+  };
+
   delegate(document, '.sidebar__toggle__icon', 'click', () => {
-    document.querySelector('.sidebar ul').classList.toggle('visible');
+    toggleSidebar();
+  });
+
+  delegate(document, '.sidebar__toggle__icon', 'keydown', e => {
+    if (e.key === ' ' || e.key === 'Enter') {
+      e.preventDefault();
+      toggleSidebar();
+    }
   });
 }