-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Folder structure, scripts and design
- Loading branch information
1 parent
30447f4
commit de7b78d
Showing
42 changed files
with
9,157 additions
and
560 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** | ||
* | ||
* @param {{show: boolean, theme: string}} props | ||
* @returns | ||
*/ | ||
function BadgeNew({ show, theme }) { | ||
if (!show) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<span className="badge" style={{ backgroundColor: theme }}> | ||
NEW | ||
</span> | ||
); | ||
} | ||
|
||
export default BadgeNew; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { cloneElement, useRef, useState, useEffect } from "react"; | ||
import styles from "@/styles/Thumbnail.module.css"; | ||
|
||
function LoadingImage({ children }) { | ||
const [loading, setLoading] = useState(true); | ||
const [width, setWidth] = useState(0); | ||
const [height, setHeight] = useState(0); | ||
const ref = useRef(); | ||
|
||
const handleLoad = () => setLoading(false); | ||
|
||
useEffect(() => { | ||
setWidth(Number(ref.current?.width)); | ||
setHeight(Number(ref.current?.height)); | ||
}, []); | ||
|
||
return ( | ||
<div style={{ position: "relative" }}> | ||
{loading && ( | ||
<span | ||
className={styles.skeleton} | ||
style={{ width: width, height: height }} | ||
></span> | ||
)} | ||
{cloneElement(children, { ref, onLoad: handleLoad })} | ||
</div> | ||
); | ||
} | ||
|
||
export default LoadingImage; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { memo } from "react"; | ||
import Link from "next/link"; | ||
import BadgeNew from "@/components/BagdeNew"; | ||
import styles from "@/styles/Thumbnail.module.css"; | ||
|
||
/** | ||
* | ||
* @param {{champion: IChampion}} props | ||
*/ | ||
function Thumbnail({ champion }) { | ||
return ( | ||
<div className={styles.thumbnail}> | ||
<Link href={`/champions/${champion.id}`}> | ||
<a> | ||
<BadgeNew show={champion.new} /> | ||
<div style={{ overflow: "hidden" }}> | ||
{" "} | ||
<img | ||
src={champion.thumbnail} | ||
alt={champion.name} | ||
loading="lazy" | ||
width="150" | ||
height="150" | ||
/> | ||
</div> | ||
<span className={styles.champion_name}>{champion.name}</span> | ||
</a> | ||
</Link> | ||
</div> | ||
); | ||
} | ||
|
||
export default memo(Thumbnail, (a, b) => a.champion.id === b.champion.id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useEffect, useState } from "react"; | ||
|
||
/** | ||
* | ||
* @param {string} src | ||
* @returns {string?} | ||
*/ | ||
function useVibrant(src) { | ||
const [color, setColor] = useState(); | ||
|
||
useEffect(() => { | ||
import("node-vibrant/dist/vibrant").then((module) => { | ||
const Vibrant = module.default; | ||
|
||
Vibrant.from(src, { quality: 1 }) | ||
.getPalette() | ||
.then((palette) => setColor(palette.Vibrant.hex)); | ||
}); | ||
}, [src]); | ||
|
||
return color; | ||
} | ||
|
||
export default useVibrant; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,9 @@ declare global { | |
thumbnail: string; | ||
}; | ||
} | ||
|
||
type Versions = { | ||
latest: string; | ||
previous: string; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,7 @@ | |
"compilerOptions": { | ||
"baseUrl": ".", | ||
"paths": { | ||
"@/*": ["src/*"], | ||
"@/public/*": ["public/*"] | ||
"@/*": ["*"] | ||
} | ||
} | ||
} |
Oops, something went wrong.