Skip to content

Instantly share code, notes, and snippets.

@shindigira
shindigira / index.html
Created January 8, 2025 09:31
sleeek menu animation
<nav>
<button id="trigger" aria-label="Menu Toggle">
<span></span><span></span><span></span>
</button>
<ul id='links' aria-expanded="false">
<li>
<a href="/">Home</a>
</li>
<li>

NPM Commands, Scripts, Life-cycle Phases

The following describes the behaviour of several npm commands, particularly w.r.t. the scripts that are run in each, for NPM version 6.5.0.

npm build <other-package-folder>

  1. npm run preinstall
  2. link binaries (node-gyp)
  3. for each bin command in other package:
@shindigira
shindigira / ANSI.md
Created March 1, 2024 21:25 — forked from fnky/ANSI.md
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Routing Demo</title>
<script type="module" defer>
import PageRouter from "./page-router.js";
import RouterLink from "./router-link.js";
@shindigira
shindigira / Sidebar.jsx
Created July 1, 2023 17:12 — forked from nimone/Sidebar.jsx
Retractable Sidebar Component purely in ReactJS and TailwindCSS
import { MoreVertical, ChevronLast, ChevronFirst } from "lucide-react"
import { useContext, createContext, useState } from "react"
const SidebarContext = createContext()
export default function Sidebar({ children }) {
const [expanded, setExpanded] = useState(true)
return (
<aside className="h-screen">
@layer base {
main {
@apply container max-w-2xl mx-auto my-10 px-4 lg:px-0;
}
h1,
h2,
h3,
h4,
@shindigira
shindigira / Carousel.jsx
Created June 22, 2023 17:53 — forked from nimone/Carousel.jsx
Build a carousel component like instagram purely in ReactJS and TailwindCSS
@shindigira
shindigira / remove-rubber-band-web-apps-ios
Created June 4, 2023 08:37 — forked from amolk/remove-rubber-band-web-apps-ios
Remove rubberband scrolling from web apps on mobile safari (iOS)
<!DOCTYPE html>
<html>
<head>
<title>Remove rubberband scrolling from web apps on mobile safari (iOS)</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta id="extViewportMeta" name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
<style>
html, body {margin: 0; padding: 0; overflow: hidden}
@shindigira
shindigira / useTypingEffect.ts
Created May 29, 2023 17:15
ChatGPT Typing Effect as a React Hook
import { useState, useEffect } from 'react';
const useTypingEffect = (value: string) => {
const [text, setText] = useState('');
const [isAnimating, setIsAnimating] = useState(true);
useEffect(() => {

Demo

Context

useViewportScroll is a great way to create a parallax effect as the page scrolls. In some cases however, we only want to scroll when an element is in the viewport area.

So for example, if we have a "landscape" scene, and want to animate the Sun object only when it's in view, we start with our useViewportScroll implementation:

function Sun(props) {
 const { scrollY, scrollYProgress } = useViewportScroll();