commit a494abf762cb352e803b220f8f230c91a014e63d Author: vikingowl Date: Sat Jan 22 16:37:32 2022 +0100 initial commit diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..d24fde5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/snippets.iml b/.idea/snippets.iml new file mode 100644 index 0000000..c956989 --- /dev/null +++ b/.idea/snippets.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/bootstrap-nav-closer.js b/bootstrap-nav-closer.js new file mode 100644 index 0000000..0f5d6b7 --- /dev/null +++ b/bootstrap-nav-closer.js @@ -0,0 +1,22 @@ +export const bootstrapNavCloser = () => { + const closeNav = (navSelector) => { + const nav = document.getElementById(navSelector) + if (nav) { + if (nav.classList.contains('show')) { + nav.classList.remove('show') + } + } + } + + document.addEventListener('click', (e) => { + const nav = document.querySelector('.navbar-toggler').dataset['bsTarget'].substring(1) + + if (e.target.attributes.id) { + if (!e.target.attributes.id.textContent.matchAll([nav, 'dropdown'])) { + closeNav(nav) + } + } else { + closeNav(nav) + } + }) +} \ No newline at end of file diff --git a/react-modules/ScrollTopButton.js b/react-modules/ScrollTopButton.js new file mode 100644 index 0000000..1a73fbc --- /dev/null +++ b/react-modules/ScrollTopButton.js @@ -0,0 +1,31 @@ +import React, {useState} from 'react' + +export const ScrollTopButton = () => { + const [visible, setVisible] = useState(false) + + const toggleVisible = () => { + const scrolled = document.documentElement.scrollTop + if (scrolled > 300) { + setVisible(true) + } else if (scrolled <= 300) { + setVisible(false) + } + } + + const scrollToTop = () => { + window.scrollTo({ + top: 0, + behavior: 'smooth' + }) + } + + window.addEventListener('scroll', toggleVisible) + + return ( + scrollToTop()} + style={{display: visible ? 'inline' : 'none'}} + /> + ) +} \ No newline at end of file diff --git a/set-image-url.js b/set-image-url.js new file mode 100644 index 0000000..a8e4024 --- /dev/null +++ b/set-image-url.js @@ -0,0 +1,13 @@ +export const setImage = (image, folder= '/images') => { + if (image.charAt(0) !== '/') { + image = '/' + image + } + if (folder.charAt(0) !== '/') { + folder = '/' + folder + } + if (folder.charAt(folder.length - 1) === '/') { + folder = folder.slice(0, -1) + } + + return '' + process.env.PUBLIC_URL + folder + image +} \ No newline at end of file