Skip to content

Instantly share code, notes, and snippets.

View Evavic44's full-sized avatar
Always learning

Victor Eke Evavic44

Always learning
View GitHub Profile
@Evavic44
Evavic44 / CloudinaryVideoReel.md
Last active October 16, 2024 19:54
Cloudinary reel video implementation using Cloudinary React SDK
"use client";
import { useRef } from "react";
import { Cloudinary } from "@cloudinary/url-gen";
import {
  AdvancedVideo,
  AdvancedImage,
  lazyload,
  accessibility,
} from "@cloudinary/react";
@Evavic44
Evavic44 / ProgressCircle.tsx
Last active September 8, 2024 04:45
Animated progress bar circle with SVG
import { useEffect } from "react";
export default function ProgressBar() {
const scheme = "#BD2546"; // hardcode progress bar theme or make it dynamic
const progress = 78; // progress value
function handleProgress(value: number, circle: "track" | "progress") {
const track = 2 * 3.14 * 90;
const progress = track * ((100 - value) / 100);
return circle === "track" ? track : progress;

Custom Sanity Table Widget in PortableText using the @sanity/table plugin

install and add @sanity/table to plugins array in the sanity.config.ts file.

Sanity Table Preview

// TableWidget.tsx
import { TablePreview } from "@sanity/table";
import { PreviewProps } from "sanity";

Sanity YouTube Schema

import { defineField, defineType } from "sanity";
import { YoutubeWidget } from "@/app/components/shared/YoutubeWidget";
import { BiLogoYoutube } from "react-icons/bi";

export const youtube = defineType({
  name: "youtube",
  title: "Youtube",
@Evavic44
Evavic44 / useOnlineStatus.tsx
Created February 19, 2024 19:56
State hook for detecting online status
// Custom hook
import { useState, useEffect } from "react";
export function useOnlineStatus() {
const [isOnline, setIsOnline] = useState<boolean>(true);
useEffect(() => {
function handleOnline() {
setIsOnline(true);
}
@Evavic44
Evavic44 / Slider.md
Last active December 25, 2023 15:59
Before and after slider component

Slider Toggle Button

import { FormEvent } from "react";
import styles from "./ToggleButton.module.css";

type ToggleProps = {
  onToggle: (isChecked: boolean) => void;
};

export default function ToggleButton({ onToggle }: ToggleProps) {
@Evavic44
Evavic44 / dynamic-icon-react.md
Last active July 11, 2023 03:56
Snippet on how to dynamically import icons based on a string in React

First install the iconify library or follow this [guide][iconify]

npm install --save-dev @iconify/react

// using yarn
yarn add --dev @iconify/react

Next import the component from the iconify library

@Evavic44
Evavic44 / domain.js
Last active October 30, 2024 18:13
A list of popular email domains (TLDs) - 2023
const domains = [
"gmail.com",
"yahoo.com",
"hotmail.com",
"aol.com",
"hotmail.co.uk",
"hotmail.fr",
"msn.com",
"yahoo.fr",
"wanadoo.fr",
{
  "workbench.colorTheme": "Darker than One Dark Pro",
  "editor.minimap.enabled": false,
  "liveServer.settings.donotShowInfoMsg": true,
  "liveServer.settings.donotVerifyTags": true,
  "vsicons.dontShowNewVersionMessage": true,
  "editor.suggestSelection": "first",
  "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
  "workbench.startupEditor": "newUntitledFile",
@Evavic44
Evavic44 / Buymeacoffee.md
Last active January 7, 2025 21:47
Buymeacoffee widget React
import React, { useEffect } from "react";

export default function Buymeacoffee() {
	useEffect(() => {
		const script = document.createElement("script");
		const div = document.getElementById("supportByBMC");
		script.setAttribute("data-name", "BMC-Widget");
		script.src = "https://cdnjs.buymeacoffee.com/1.0.0/widget.prod.min.js";
		script.setAttribute("data-id", "evavic44");