Skip to content

Instantly share code, notes, and snippets.

View nirnejak's full-sized avatar
🎨
Crafting Interfaces

Jitendra Nirnejak nirnejak

🎨
Crafting Interfaces
View GitHub Profile
import Vue from 'vue'
import axios from 'axios'
import NProgress from 'nprogress'
import * as Sentry from '@sentry/browser'
if (process.env.NODE_ENV === 'production') {
axios.defaults.baseURL = 'https://api.myserver.com/api'
} else {
axios.defaults.baseURL = 'https://mystagingserver.herokuapp.com/api'
// axios.defaults.baseURL = 'http://localhost:3000/api'
/$$$$$$$$ /$$$$$$$$ /$$$$$$ /$$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$$ /$$$$$$$
|__ $$__/| $$_____/ /$$__ $$|__ $$__/ | $$__ $$ /$$__ $$ /$$__ $$ /$$__ $$| $$_____/| $$__ $$
| $$ | $$ | $$ \__/ | $$ | $$ \ $$| $$ \ $$| $$ \__/| $$ \__/| $$ | $$ \ $$
| $$ | $$$$$ | $$$$$$ | $$ | $$$$$$$/| $$$$$$$$| $$$$$$ | $$$$$$ | $$$$$ | $$ | $$
| $$ | $$__/ \____ $$ | $$ | $$____/ | $$__ $$ \____ $$ \____ $$| $$__/ | $$ | $$
| $$ | $$ /$$ \ $$ | $$ | $$ | $$ | $$ /$$ \ $$ /$$ \ $$| $$ | $$ | $$
| $$ | $$$$$$$$| $$$$$$/ | $$ | $$ | $$ | $$| $$$$$$/| $$$$$$/| $$$$$$$$| $$$$$$$/
|__/ |________/ \______/ |__/ |__/ |__/ |__/ \______/ \______/ |________/|_______/
import React from "react"
const useClickOutside = (ref, callback) => {
const handleClick = (e) => {
if (ref.current && !ref.current.contains(e.target)) {
callback()
}
}
React.useEffect(() => {
document.addEventListener("click", handleClick)
import React from "react"
import { navigate } from "gatsby"
import NProgress from "nprogress"
import PropTypes from "prop-types"
import { accountRegister, tokenCreate } from "../graphql/user"
const initialState = {
@nirnejak
nirnejak / vercel.zsh-theme
Created September 19, 2021 18:29
Vercel Zsh Theme(Modified)
local resetColor="%{$reset_color%}"
local logo="%{$fg_bold[white]%}▲$resetColor$resetColor"
# local hostname=`hostname`
local dir="%{$fg_bold[white]%}%c$resetColor$resetColor"
GIT_PROMPT_PREFIX="[%{$fg_bold[white]%}"
GIT_PROMPT_SUFFIX="$resetColor] "
GIT_PROMPT_DIRTY="%{$fg_bold[red]%}"
GIT_PROMPT_CLEAN="%{$fg_bold[green]%}"
import React from 'react'
function useWindowSize() {
const [windowSize, setWindowSize] = React.useState({
width: 0,
height: 0,
})
React.useEffect(() => {
const handler = () => {
import React from "react"
import PropTypes from "prop-types"
const initialState = {
isAuthenticated: false,
}
export const AuthContext = React.createContext(initialState)
@nirnejak
nirnejak / useUserTheme.ts
Created March 16, 2022 18:58
A React hook to detect dark/light mode.
import React from "react"
const useUserTheme = (): boolean => {
const [isDark, setIsDark] = React.useState(false)
React.useEffect(() => {
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", (event) => {
setIsDark(event.matches)
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
handleDarkmode(darkModeMediaQuery)
function handleDarkmode(e) {
const darkModeOn = e.matches; // true if dark mode is enabled
if (darkModeOn) {
// TODO: Set Dark Theme
} else {
const testObj = {
bankId: 13,
accounts: [
{ accountName: "abc", currentBalance: { cash: 2000 }, subAccounts: [] },
{
accountName: "bcd",
currentBalance: { cash: 5000 },
subAccounts: [
{
accountName: "efg",