Refactor components to simplify them
This commit is contained in:
parent
3cf5b14913
commit
077ed9d3bf
36 changed files with 202 additions and 216 deletions
33
src/index.ts
33
src/index.ts
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue