Skip to content

Instantly share code, notes, and snippets.

View sjns19's full-sized avatar

Sujan Shrestha sjns19

  • Kathmandu, Nepal
View GitHub Profile
@sjns19
sjns19 / Modal.css
Last active November 10, 2022 08:27
Demo CSS file for Modal system tutorial article at Medium
.modal {
position: fixed;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
top: 0;
left: 0;
z-index: 1;
@sjns19
sjns19 / Modal.js
Last active November 10, 2022 08:28
Demo JS file for Modal system tutorial article at Medium
let documentBody = document.body;
let Modal = undefined;
function createElement(name, classes, parent) {
let element = document.createElement(name);
element.className += classes;
if (parent) {
parent.appendChild(element);
@sjns19
sjns19 / style.css
Created November 18, 2021 13:12
This gist is used for a medium article
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
:root {
--background-color: #fff;
--text-color: #000;
--grey: #777;
@sjns19
sjns19 / index.js
Created November 18, 2021 13:10
This gist is used for a medium article
// Get the button that is used to toggle the dark mode
const themeBtn = document.getElementById("dark-mode-btn");
// Get the <html> element
const docEl = document.documentElement;
// Handling the click event
themeBtn.addEventListener("click", () => {
// Toggle the dark-theme class inside of the html element
docEl.classList.toggle("dark-theme");
// Set the dark theme value in user's browser.
@sjns19
sjns19 / style.css
Created November 18, 2021 13:09
This gist is used for a medium article
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html {
background-color: #fff;
color: #000;
font-family: sans-serif;
@sjns19
sjns19 / index.js
Last active January 5, 2022 10:47
This gist is used for a medium article
// Get the <link> element
const stylesheet = document.getElementById("main-style");
// Get the button that is used to toggle the dark mode
const themeBtn = document.getElementById("dark-mode-btn");
// Just an object literal that holds the file paths
const cssPath = {
light: "src/style.css",
dark: "src/style.dark.css",
};
@sjns19
sjns19 / style.dark.css
Created November 18, 2021 13:05
This gist is used for a medium article
* {
padding: 0;
margin: 0;
box-sizing: border-box;
html {
background-color: #000;
color: #fff;
font-family: sans-serif;
@sjns19
sjns19 / style.css
Created November 18, 2021 13:04
This gist is used for a medium article
* {
padding: 0;
margin: 0;
box-sizing: border-box;
}
html {
background-color: #fff;
color: #000;
font-family: sans-serif;