Refactor components to simplify them

This commit is contained in:
Andras Schmelczer 2022-09-21 14:40:44 +02:00
parent 3cf5b14913
commit 077ed9d3bf
No known key found for this signature in database
GPG key ID: 0EA1BC97D0AB076E
36 changed files with 202 additions and 216 deletions

View file

@ -1,5 +1,3 @@
import '../static/no-change/og-image.jpg';
import '../static/no-change/robots.txt';
import '../static/no-change/404.html';
import '../static/no-change/favicons/android-chrome-192x192.png';
import '../static/no-change/favicons/android-chrome-512x512.png';
@ -8,32 +6,15 @@ import '../static/no-change/favicons/favicon-16x16.png';
import '../static/no-change/favicons/favicon-32x32.png';
import '../static/no-change/favicons/favicon.ico';
import '../static/no-change/favicons/site.webmanifest';
import '../static/no-change/og-image.jpg';
import '../static/no-change/robots.txt';
import { create as createPortfolio } from './data/portfolio';
import { addSupportForTabNavigation } from './helper/add-support-for-tab-navigation';
import { removeUnnecessaryOutlines } from './helper/remove-unnecessary-outlines';
import { scrollToFragment } from './helper/scroll-to-fragment';
import './styles.scss';
import { create } from './data/portfolio';
const addSupportForTabNavigation = () =>
document.addEventListener('keydown', (e) => {
if (e.key === ' ') {
(document.activeElement as HTMLElement)?.click();
e.preventDefault();
}
});
const removeUnnecessaryOutlines = () =>
document.addEventListener('click', () =>
(document.activeElement as HTMLElement).blur?.()
);
// it might be necessary when the page takes too long to load
const scrollToFragment = () => {
if (location.hash) {
document.getElementById(location.hash.slice(1))?.scrollIntoView();
}
};
addSupportForTabNavigation();
removeUnnecessaryOutlines();
create();
createPortfolio().forEach((e) => e.attachToDOM(document.body));
scrollToFragment();