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
const navbar = document.querySelector(".navbar"), | |
sectionKelas = document.querySelectorAll(".section-kelas"); | |
// initialize IntersectionObserver | |
const io = new IntersectionObserver((entries) => { | |
// entries are array of element e.g: [<div></div>, <p></p>] | |
// loop through the element | |
entries.forEach((entry) => { | |
// assign the data set attribute | |
const kelas = entry.target.dataset.kelas; |
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
export const capsLetter = (str) => str.split(' ').map(l => l.slice(0, 1).toUpperCase() + l.slice(1)).join(' ') |
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
import { useCallback, useEffect, useState, } from 'react' | |
type Theme = 'dark' | 'light' | |
export default function useTheme(){ | |
const [theme, setTheme] = useState<Theme>('light') | |
const changeTheme = useCallback((payload: Theme) => { | |
return () => { | |
setTheme(payload) |
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
module.exports = { | |
content: ['./src/**/*.{js,jsx,ts,tsx}', './public/index.html'], | |
darkMode: 'class', | |
theme: { | |
extend: {}, | |
} | |
plugins: [] | |
} |
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
import Image from "next/image" | |
export function ImageComponent(){ | |
return ( | |
<figure className="relative w-40 h-40 md:w-80 md:h-80"> | |
<Image lazy layout="fill" /> | |
</figure> | |
) | |
} |
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
export async function httpreq(fn: () => Promise<any>): Promise<[any, any]> { | |
try { | |
const res = await fn() | |
return [res, null] | |
} catch(err) { | |
return [null, err] | |
} | |
} | |
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
export const toElipsis = (str: string, range?: = 10): string => { | |
return str.slice(0, range) + '...' | |
} | |
// usage | |
const elipsis = toElipsis("Please mister, call me Robin, I will be your company while at your trip to Mongo Island", 44) | |
console.info(elipsis) // -> 'Please mister, call me robin, I will be your...' |
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
{ | |
"recommendations": [ | |
"bradlc.vscode-tailwindcss", | |
"eamodio.gitlens", | |
"dbaeumer.vscode-eslint", | |
"usernamehw.errorlens", | |
"vscode-icons-team.vscode-icons", | |
"mintlify.document", | |
"esbenp.prettier-vscode", | |
"mikestead.dotenv", |
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
module.exports = { | |
semi: false, | |
tabWidth: 2, | |
printWidth: 120, | |
singleQuote: true, | |
jsxSingleQuote: true, | |
trailingComma: 'none', | |
arrowParens: 'always', | |
endOfLine: 'auto', | |
} |
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
type Value = Record<string, unknown> | |
export const arrayObjSearch = <T extends Value>(arr: Array<T>, key: keyof Array<T>[0], target: string): T | null => { | |
if (!key) throw new TypeError('You should provide what key to find') | |
if (arr.length === 0) return null | |
let i = 0 | |
do { | |
const source = arr[i][key] |
OlderNewer