View State management with react and typescript
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 React, { createContext } from "react"; | |
export type RejectedFileType = { | |
rejectedFiles: any[]; | |
currentPage: number; | |
totalRecords: number; | |
sortByObject: Record<string, string> | |
loading: boolean; | |
error: string, |
View css
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
html { | |
max-width: 70ch; | |
padding: 3em 1em; | |
margin: auto; | |
line-height: 1.75; | |
font-size: 1.25em; | |
} | |
h1,h2,h3,h4,h5,h6 { |
View ++index.css
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
.gradient-bg-welcome { | |
background-color: #0f0e13; | |
background-image: radial-gradient( | |
at 0% 0%, | |
hsla(253, 16%, 7%, 1) 0, | |
transparent 50% | |
), | |
radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%), | |
radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%); | |
} |
View useElementPosition.js
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 { useEffect } from "react"; | |
import { useState } from "react"; | |
export default function useElementPosition(el) { | |
function getElement(x, y) { | |
return { | |
x, | |
y, | |
}; | |
} |
View GlobalContext.js
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 React, { createContext, useReducer, useContext } from "react"; | |
// Define the context | |
const GlobalStateContext = createContext(); | |
const GlobalDispatchContext = createContext(); | |
// Reducer | |
const globalReducer = (state, action) => { | |
switch (action.type) { | |
case "TOGGLE_THEME": { |
View Download Data From Console
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 filename = 'data.json'; | |
const jsonStr = JSON.stringify(JsonExport); | |
let element = document.createElement('a'); | |
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(jsonStr)); | |
element.setAttribute('download', filename); | |
element.style.display = 'none'; | |
document.body.appendChild(element); |
View HideReactSourceCode
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
scripts: { | |
"build": "GENERATE_SOURCEMAP=false react-scripts build" | |
} | |
# Netlify | |
CI=false npm run build |
View netlify.toml
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
[build] | |
command = "CI=false npm run build" | |
publish = "/build" | |
base = "/" | |
[[redirects]] | |
from = "/*" | |
to = "/index.html" | |
status = 200 |
View firebase Snipets
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
// Firebase Storage : | |
const handleUpload = () => { | |
const uploadTask = storage.ref(`images/${image.name}`).put(image); | |
uploadTask.on( | |
'state_changed', | |
(snapshot) => { | |
// Progress funciton | |
const progress = Math.round((snapshot.bytesTransferred / snapshot.totalBytes) * 100); |
NewerOlder