Skip to content

Instantly share code, notes, and snippets.

View Amit258012's full-sized avatar
🎯
Focusing

Amit Jahagirdar Amit258012

🎯
Focusing
View GitHub Profile
@Amit258012
Amit258012 / Firebase.jsx
Last active August 5, 2023 13:54
Firebase
// init services:
export const db = getFirestore(app);
// collection ref:
const colRef = collection(db, "data");
// get collection data
useEffect(() => {
const getData = async () => {
const data = await getDocs(colRef);
@Amit258012
Amit258012 / code Snippets.md
Last active July 29, 2023 09:48
Utils react code

If we navigate to new page then the scroll pos must be at start

    useEffect(() => {
		window.scrollTo(0, 0);
	}, [location]);
@Amit258012
Amit258012 / mixin.scss
Created July 29, 2023 09:26
scss mixin
@mixin sm {
@media only screen and (min-width: 640px) {
@content;
}
}
@mixin md {
@media only screen and (min-width: 768px) {
@content;
}
@Amit258012
Amit258012 / test.md
Last active July 29, 2023 04:54
Notes

Simple test

@Amit258012
Amit258012 / lazyLoadingImage.jsx
Created July 25, 2023 16:44
LazyLoading Image
import { LazyLoadImage } from "react-lazy-load-image-component";
import "react-lazy-load-image-component/src/effects/blur.css";
const Img = ({ src, className }) => {
return (
<LazyLoadImage
className={className || ""}
alt=""
effect="blur"
src={src}
@Amit258012
Amit258012 / useFetch.jsx
Last active July 29, 2023 08:28
Custom Hooks
import { useEffect, useState } from "react";
import { fetchDataFromApi } from "../utils/api";
const useFetch = (url) => {
const [data, setData] = useState(null);
const [loading, setLoading] = useState(null);
const [error, setError] = useState(null);
useEffect(() => {
setLoading("loading...");
setData(null);
{
data.meta.pagination.total > maxResultCount && (
<div className="flex gap-3 items-center justify-center my-16 md:my-0">
<button
className={`rounded py-2 px-4 bg-black text-white disabled:bg-gray-200 disabled:text-gray-500`}
disabled={pageIndex === 1}
onClick={() => setPageIndex(pageIndex - 1)}>
Previous
</button>
@Amit258012
Amit258012 / global.css
Created July 23, 2023 06:56
Tailwind setup
@import url("https://fonts.googleapis.com/css2?family=Lexend:wght@100;200;300;400;500;600;700;800;900&display=swap");
@tailwind base;
@tailwind components;
@tailwind utilities;
:root {
font-family: "Lexend", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
@Amit258012
Amit258012 / index.scss
Created July 23, 2023 06:53
Index.scss file for react
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 1;
font-weight: 500;
font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;