Skip to content

Commit

Permalink
chore: Update react and js templates with cleaner comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjuaneight authored Jan 7, 2025
1 parent 307dbda commit 4bd04e9
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 18 deletions.
5 changes: 0 additions & 5 deletions templates/react/head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ type Data = {

/**
* HTML Head
* @component
*
* @param {ILocation} location router location info
*
* @returns {React.FC}
*/
const Head: React.FC<HeadProps> = ({ location }): React.FC => {
const {
Expand Down
11 changes: 4 additions & 7 deletions templates/react/images.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,11 @@ interface ImageProps {
/**
* Static Image Query
* Queries all images at a set max-width and allows filtering of specific image via props
* @component
*
* @param {string} alt alt text
* @param {string} filename image relative filename
* @param {object} imgStyle img styles
* @param {object} style wrapper container styles
*
* @returns {React.FC} <Image filename={string} alt={string} style={object} imgStyle={object} />
* @param alt alt text
* @param filename image relative filename
* @param imgStyle img styles
* @param style wrapper container styles
*/
const Image: React.FC<ImageProps> = ({
alt,
Expand Down
5 changes: 0 additions & 5 deletions templates/react/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ interface LayoutProps {

/**
* Main layout
* @component
*
* @param {LayoutProps} location router location info
*
* @returns {React.FC} <Layout location={location} />
*/
const Layout: React.FC<LayoutProps> = ({ children, location }): React.FC => (
<>
Expand Down
4 changes: 3 additions & 1 deletion templates/scripts/clipboard.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* eslint-disable quotes */
const clip = document.querySelector('button.clip-btn');

// create selection range for <code> element
/**
* Create selection range for <code> element.
*/
clip.addEventListener('click', () => {
const selection: Selection = window.getSelection();
const range: Range = document.createRange();
Expand Down
4 changes: 4 additions & 0 deletions templates/scripts/lazyload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ const imgs: NodeListOf<HTMLImageElement> = document.querySelectorAll(
'img[data-lazy="true"]'
);

/**
* IntersectionObserver API
*/
let observer = new IntersectionObserver((entries, self) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
Expand All @@ -15,6 +18,7 @@ let observer = new IntersectionObserver((entries, self) => {
});
});

// Observe all images with `data-lazy` attribute
if (imgs.length > 0) {
imgs.forEach(img => {
observer.observe(img);
Expand Down

0 comments on commit 4bd04e9

Please sign in to comment.