initial commit

This commit is contained in:
2022-01-22 16:37:32 +01:00
commit a494abf762
6 changed files with 90 additions and 0 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@@ -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

8
.idea/modules.xml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/snippets.iml" filepath="$PROJECT_DIR$/.idea/snippets.iml" />
</modules>
</component>
</project>

8
.idea/snippets.iml generated Normal file
View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

22
bootstrap-nav-closer.js vendored Normal file
View File

@@ -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)
}
})
}

31
react-modules/ScrollTopButton.js vendored Normal file
View File

@@ -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 (
<i
className="bi bi-arrow-up-square scroll-top-btn text-info"
onClick={() => scrollToTop()}
style={{display: visible ? 'inline' : 'none'}}
/>
)
}

13
set-image-url.js Normal file
View File

@@ -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
}