Skip to content

Instantly share code, notes, and snippets.

@ihsaanb
ihsaanb / settings.json
Created February 14, 2026 02:59
VSCode Settings json
{
"debug.allowBreakpointsEverywhere": true,
"files.autoSave": "off",
"code-runner.defaultLanguage": "\"code-runner.defaultLanguage\": \"python\"",
"python.linting.pylintArgs": [
"--disable=all",
"--enable=F,E,unreachable,duplicate-key,unnecessary-semicolon,global-variable-not-assigned,unused-variable,binary-op-exception,bad-format-string,anomalous-backslash-in-string,bad-open-mode",
"--load-plugins",
"pylint_django"
],
@ihsaanb
ihsaanb / App.js
Created July 13, 2021 01:35
The Dark Light Mode App Structure :p
import logo from "./logo.svg";
import "./App.css";
import Global from "./components/DarkLight/global";
import Home from "./components/Home.jsx";
function App() {
return (
<Global>
<Home />
</Global>
);
@ihsaanb
ihsaanb / Home.jsx
Created July 13, 2021 01:23
Fetch Global State and Send a dispatch to change the state. Also use Emotion as a prop to distinguish if dark mode is on or off.
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { dark } from "../redux";
import { LIGHT, DARK } from "./DarkLight/theme";
/** @jsxRuntime classic /
/* @jsx jsx */
import styled from "@emotion/styled";
import { css, jsx } from "@emotion/react";
const Content = styled.div`
@ihsaanb
ihsaanb / global.js
Created July 13, 2021 00:38
Global wrapper connecting with state and changing classname based on it
import React from "react";
import { useSelector } from "react-redux";
const Global = ({ children }) => {
const isDark = useSelector((state) => state.changedark.isdark);
return <div className={isDark ? "dark" : "light"}>
{children}
</div>;
};
@ihsaanb
ihsaanb / index.js
Created July 13, 2021 00:23
React Render with Redux Store Provider
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import { Provider } from "react-redux";
import store from "./redux/store";
ReactDOM.render(
<Provider store={store}>
<React.StrictMode>
@ihsaanb
ihsaanb / index.css
Created July 12, 2021 23:58
Body dark and body light in css file
body .light {
background-color: #f4f4f4;
background: #f4f4f4;
color: #000;
transition: 250ms ease-in;
}
body .dark {
background-color: #242424;
background: #242424;
@ihsaanb
ihsaanb / theme.js
Created July 12, 2021 23:53
Themes for Dark Light Mode
export const LIGHT = {
background: "#f4f4f4",
textColor: "#000",
};
export const DARK = {
background: "#242424",
textColor: "#fff",
};