Skip to content

Instantly share code, notes, and snippets.

@burakorkmez
Last active January 13, 2024 12:20
Show Gist options
  • Save burakorkmez/5ba4c1a910f396050a2ac2f229418f54 to your computer and use it in GitHub Desktop.
Save burakorkmez/5ba4c1a910f396050a2ac2f229418f54 to your computer and use it in GitHub Desktop.
Leetcode Clone
<>
<div className='absolute top-0 left-0 w-full h-full flex items-center justify-center bg-black bg-opacity-60'></div>
<div className='w-full sm:w-[450px] absolute top-[50%] left-[50%] translate-x-[-50%] translate-y-[-50%] flex justify-center items-center'>
<div className='relative w-full h-full mx-auto flex items-center justify-center'>
<div className='bg-white rounded-lg shadow relative w-full bg-gradient-to-b from-brand-orange to-slate-900 mx-6'>
<div className='flex justify-end p-2'>
<button
type='button'
className='bg-transparent rounded-lg text-sm p-1.5 ml-auto inline-flex items-center hover:bg-gray-800 hover:text-white text-white'
>
X
</button>
</div>
</div>
</div>
</div>
</>
<h1
className='text-2xl text-center text-gray-700 dark:text-gray-400 font-medium uppercase mt-10 mb-5'>
&ldquo; QUALITY OVER QUANTITY &rdquo; 👇
</h1>
<div className='relative overflow-x-auto mx-auto px-6 pb-10'>
<table className='text-sm text-left text-gray-500 dark:text-gray-400 sm:w-7/12 w-full max-w-[1200px] mx-auto'>
<thead className='text-xs text-gray-700 uppercase dark:text-gray-400 border-b '>
<tr>
<th scope='col' className='px-1 py-3 w-0 font-medium'>
Status
</th>
<th scope='col' className='px-6 py-3 w-0 font-medium'>
Title
</th>
<th scope='col' className='px-6 py-3 w-0 font-medium'>
Difficulty
</th>
<th scope='col' className='px-6 py-3 w-0 font-medium'>
Category
</th>
<th scope='col' className='px-6 py-3 w-0 font-medium'>
Solution
</th>
</tr>
</thead>
</table>
</div>
const LoadingSkeleton = () => {
return (
<div className='flex items-center space-x-12 mt-4 px-6'>
<div className='w-6 h-6 shrink-0 rounded-full bg-dark-layer-1'></div>
<div className='h-4 sm:w-52 w-32 rounded-full bg-dark-layer-1'></div>
<div className='h-4 sm:w-52 w-32 rounded-full bg-dark-layer-1'></div>
<div className='h-4 sm:w-52 w-32 rounded-full bg-dark-layer-1'></div>
<span className='sr-only'>Loading...</span>
</div>
);
};
import React from "react";
import { AiOutlineFullscreen, AiOutlineSetting } from "react-icons/ai";
type PreferenceNavProps = {};
const PreferenceNav: React.FC<PreferenceNavProps> = () => {
return (
<div className='flex items-center justify-between bg-dark-layer-2 h-11 w-full'>
<div className='flex items-center text-white'>
<button className='flex cursor-pointer items-center rounded focus:outline-none bg-dark-fill-3 text-dark-label-2 hover:bg-dark-fill-2 px-2 py-1.5 font-medium'>
<div className='flex items-center px-1'>
<div className='text-xs text-label-2 dark:text-dark-label-2'>JavaScript</div>
</div>
</button>
</div>
<div className='flex items-center m-2'>
<button className='preferenceBtn group'>
<div className='h-4 w-4 text-dark-gray-6 font-bold text-lg'>
<AiOutlineSetting />
</div>
<div className='preferenceBtn-tooltip'>Settings</div>
</button>
<button className='preferenceBtn group'>
<div className='h-4 w-4 text-dark-gray-6 font-bold text-lg'>
<AiOutlineFullscreen />
</div>
<div className='preferenceBtn-tooltip'>Full Screen</div>
</button>
</div>
</div>
);
};
export default PreferenceNav;
import { AiFillLike, AiFillDislike } from "react-icons/ai";
import { BsCheck2Circle } from "react-icons/bs";
import { TiStarOutline } from "react-icons/ti";
type ProblemDescriptionProps = {};
const ProblemDescription: React.FC<ProblemDescriptionProps> = () => {
return (
<div className='bg-dark-layer-1'>
{/* TAB */}
<div className='flex h-11 w-full items-center pt-2 bg-dark-layer-2 text-white overflow-x-hidden'>
<div className={"bg-dark-layer-1 rounded-t-[5px] px-5 py-[10px] text-xs cursor-pointer"}>
Description
</div>
</div>
<div className='flex px-0 py-4 h-[calc(100vh-94px)] overflow-y-auto'>
<div className='px-5'>
{/* Problem heading */}
<div className='w-full'>
<div className='flex space-x-4'>
<div className='flex-1 mr-2 text-lg text-white font-medium'>1. Two Sum</div>
</div>
<div className='flex items-center mt-3'>
<div
className={`text-olive bg-olive inline-block rounded-[21px] bg-opacity-[.15] px-2.5 py-1 text-xs font-medium capitalize `}
>
Easy
</div>
<div className='rounded p-[3px] ml-4 text-lg transition-colors duration-200 text-green-s text-dark-green-s'>
<BsCheck2Circle />
</div>
<div className='flex items-center cursor-pointer hover:bg-dark-fill-3 space-x-1 rounded p-[3px] ml-4 text-lg transition-colors duration-200 text-dark-gray-6'>
<AiFillLike />
<span className='text-xs'>120</span>
</div>
<div className='flex items-center cursor-pointer hover:bg-dark-fill-3 space-x-1 rounded p-[3px] ml-4 text-lg transition-colors duration-200 text-green-s text-dark-gray-6'>
<AiFillDislike />
<span className='text-xs'>2</span>
</div>
<div className='cursor-pointer hover:bg-dark-fill-3 rounded p-[3px] ml-4 text-xl transition-colors duration-200 text-green-s text-dark-gray-6 '>
<TiStarOutline />
</div>
</div>
{/* Problem Statement(paragraphs) */}
<div className='text-white text-sm'>
<p className='mt-3'>
Given an array of integers <code>nums</code> and an integer <code>target</code>, return
<em>indices of the two numbers such that they add up to</em> <code>target</code>.
</p>
<p className='mt-3'>
You may assume that each input would have <strong>exactly one solution</strong>, and you
may not use thesame element twice.
</p>
<p className='mt-3'>You can return the answer in any order.</p>
</div>
{/* Examples */}
<div className='mt-4'>
{/* Example 1 */}
<div>
<p className='font-medium text-white '>Example 1: </p>
<div className='example-card'>
<pre>
<strong className='text-white'>Input: </strong> nums = [2,7,11,15], target = 9{" "}
<br />
<strong>Output:</strong> [0,1] <br />
<strong>Explanation:</strong>Because nums[0] + nums[1] == 9, we return [0, 1].
</pre>
</div>
</div>
{/* Example 2 */}
<div>
<p className='font-medium text-white '>Example 2: </p>
<div className='example-card'>
<pre>
<strong className='text-white'>Input: </strong> nums = [3,2,4], target = 6{" "}
<br />
<strong>Output:</strong> [1,2] <br />
<strong>Explanation:</strong>Because nums[1] + nums[2] == 6, we return [1, 2].
</pre>
</div>
</div>
{/* Example 3 */}
<div>
<p className='font-medium text-white '>Example 3: </p>
<div className='example-card'>
<pre>
<strong className='text-white'>Input: </strong> nums = [3,3], target = 6
<br />
<strong>Output:</strong> [0,1] <br />
</pre>
</div>
</div>
</div>
{/* Constraints */}
<div className='my-5'>
<div className='text-white text-sm font-medium'>Constraints:</div>
<ul className='text-white ml-5 list-disc'>
<li className='mt-2'>
<code>2 ≤ nums.length ≤ 10</code>
</li>
<li className='mt-2'>
<code>-10 ≤ nums[i] ≤ 10</code>
</li>
<li className='mt-2'>
<code>-10 ≤ target ≤ 10</code>
</li>
<li className='mt-2 text-sm'>
<strong>Only one valid answer exists.</strong>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
);
};
export default ProblemDescription;
export type Problem = {
id: string;
title: string;
difficulty: string;
category: string;
order: number;
videoId?: string;
};
export const problems: Problem[] = [
{
id: "two-sum",
title: "Two Sum",
difficulty: "Easy",
category: "Array",
order: 1,
videoId: "8-k1C6ehKuw",
},
{
id: "reverse-linked-list",
title: "Reverse Linked List",
difficulty: "Hard",
category: "Linked List",
order: 2,
videoId: "",
},
{
id: "jump-game",
title: "Jump Game",
difficulty: "Medium",
category: "Dynamic Programming",
order: 3,
videoId: "",
},
{
id: "valid-parentheses",
title: "Valid Parentheses",
difficulty: "Easy",
category: "Stack",
order: 4,
videoId: "xty7fr-k0TU",
},
{
id: "search-a-2d-matrix",
title: "Search a 2D Matrix",
difficulty: "Medium",
category: "Binary Search",
order: 5,
videoId: "ZfFl4torNg4",
},
{
id: "container-with-most-water",
title: "Container With Most Water",
difficulty: "Medium",
category: "Two Pointers",
order: 6,
videoId: "",
},
{
id: "merge-intervals",
title: "Merge Intervals",
difficulty: "Medium",
category: "intervals",
order: 7,
videoId: "",
},
{
id: "maximum-depth-of-binary-tree",
title: "Maximum Depth of Binary Tree",
difficulty: "Easy",
category: "Tree",
order: 8,
videoId: "4qYTqOiRMoM",
},
{
id: "best-time-to-buy-and-sell-stock",
title: "Best Time to Buy and Sell Stock",
difficulty: "Easy",
category: "Array",
order: 9,
videoId: "",
},
{
id: "subsets",
title: "Subsets",
difficulty: "Medium",
category: "Backtracking",
order: 10,
videoId: "",
},
];
<tfoot className='fixed top-0 left-0 h-screen w-screen flex items-center justify-center ' >
<div className='bg-black z-10 opacity-70 top-0 left-0 w-screen h-screen absolute'></div>
<div className='w-full z-50 h-full px-6 relative max-w-4xl'>
<div className='w-full h-full flex items-center justify-center relative'>
<div className='w-full relative'>
<IoClose fontSize={"35"} className='cursor-pointer absolute -top-16 right-0' />
<YouTube videoId={"xty7fr-k0TU"} loading='lazy' iframeClassName='w-full min-h-[500px]' />
</div>
</div>
</div>
</tfoot>
<form className='space-y-6 px-6 lg:px-8 pb-4 sm:pb-6 xl:pb-8'>
<h3 className='text-xl font-medium text-white'>Reset Password</h3>
<p className='text-sm text-white '>
Forgotten your password? Enter your e-mail address below, and we&apos;ll send you an e-mail allowing you
to reset it.
</p>
<div>
<label htmlFor='email' className='text-sm font-medium block mb-2 text-gray-300'>
Your email
</label>
<input
type='email'
name='email'
id='email'
className='border-2 outline-none sm:text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 bg-gray-600 border-gray-500 placeholder-gray-400 text-white'
placeholder='name@company.com'
/>
</div>
<button
type='submit'
className={`w-full text-white focus:ring-4 focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center
bg-brand-orange hover:bg-brand-orange-s `}
>
Reset Password
</button>
</form>
import { BsCheckLg, BsChevronDown } from "react-icons/bs";
import { IoClose } from "react-icons/io5";
const EDITOR_FONT_SIZES = ["12px", "13px", "14px", "15px", "16px", "17px", "18px"];
const SettingsModal: React.FC = () => {
const dropdownIsOpen = true;
return (
<div className='text-white z-40'>
<div aria-modal='true' role='dialog' className='fixed inset-0 overflow-y-auto z-modal'>
<div className='flex min-h-screen items-center justify-center px-4'>
{/* overlay */}
<div className='opacity-100' onClick={() => {}}>
<div className='fixed inset-0 bg-gray-8 opacity-60'></div>
</div>
<div className='my-8 inline-block min-w-full transform rounded-[13px] text-left transition-all bg-overlay-3 md:min-w-[420px] shadow-level4 shadow-lg p-0 bg-[rgb(40,40,40)] w-[600px] !overflow-visible opacity-100 scale-100'>
{/* setting header */}
<div className='flex items-center border-b px-5 py-4 text-lg font-medium border-dark-divider-border-2'>
Settings
<button className='ml-auto cursor-pointer rounded transition-all' onClick={() => {}}>
<IoClose />
</button>
</div>
<div className='px-6 pt-4 pb-6'>
<div className='mt-6 flex justify-between first:mt-0'>
<div className='w-[340px]'>
<h3 className=' text-base font-medium'>Font size</h3>
<h3 className='text-label-3 mt-1.5'>
Choose your preferred font size for the code editor.
</h3>
</div>
<div className='w-[170px]'>
<div className='relative'>
<button
onClick={() => {}}
className='flex cursor-pointer items-center rounded px-3 py-1.5 text-left focus:outline-none whitespace-nowrap bg bg-dark-fill-3 hover:bg-dark-fill-2 active:bg-dark-fill-3 w-full justify-between'
type='button'
>
14px
<BsChevronDown />
</button>
{/* Show dropdown for fontsizes */}
{dropdownIsOpen && (
<ul
className='absolute mt-1 max-h-56 overflow-auto rounded-lg p-2 z-50 focus:outline-none shadow-lg w-full bg-dark-layer-1'
style={{
filter: "drop-shadow(rgba(0, 0, 0, 0.04) 0px 1px 3px) drop-shadow(rgba(0, 0, 0, 0.12) 0px 6px 16px)",
}}
>
{EDITOR_FONT_SIZES.map((fontSize, idx) => (
<SettingsListItem
key={idx}
fontSize={fontSize}
selectedOption={"14px"}
/>
))}
</ul>
)}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
);
};
export default SettingsModal;
interface SettingsListItemProps {
fontSize: string;
selectedOption: string;
}
const SettingsListItem: React.FC<SettingsListItemProps> = ({ fontSize, selectedOption }) => {
return (
<li className='relative flex h-8 cursor-pointer select-none py-1.5 pl-2 text-label-2 dark:text-dark-label-2 hover:bg-dark-fill-3 rounded-lg'>
<div className={`flex h-5 flex-1 items-center pr-2 ${selectedOption === fontSize ? "font-medium" : ""}`}>
<div className='whitespace-nowrap'>{fontSize}</div>
</div>
<span
className={`text-blue dark:text-dark-blue flex items-center pr-2 ${
selectedOption === fontSize ? "visible" : "invisible"
}`}
>
<BsCheckLg />
</span>
</li>
);
};
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./app/**/*.{js,ts,jsx,tsx}",
"./pages/**/*.{js,ts,jsx,tsx}",
"./components/**/*.{js,ts,jsx,tsx}",
// Or if using `src` directory:
"./src/**/*.{js,ts,jsx,tsx}",
],
theme: {
extend: {
colors: {
"dark-layer-1": "rgb(40,40,40)",
"dark-layer-2": "rgb(26,26,26)",
"dark-label-2": "rgba(239, 241, 246, 0.75)",
"dark-divider-border-2": "rgb(61, 61, 61)",
"dark-fill-2": "hsla(0,0%,100%,.14)",
"dark-fill-3": "hsla(0,0%,100%,.1)",
"dark-gray-6": "rgb(138, 138, 138)",
"dark-gray-7": "rgb(179, 179, 179)",
"gray-8": "rgb(38, 38, 38)",
"dark-gray-8": "rgb(219, 219, 219)",
"brand-orange": "rgb(255 161 22)",
"brand-orange-s": "rgb(193, 122, 15)",
"dark-yellow": "rgb(255 192 30)",
"dark-pink": "rgb(255 55 95)",
olive: "rgb(0, 184, 163)",
"dark-green-s": "rgb(44 187 93)",
"dark-blue-s": "rgb(10 132 255)",
},
},
},
plugins: [],
};
const [time, setTime] = useState<number>(0);
const formatTime = (time: number): string => {
const hours = Math.floor(time / 3600);
const minutes = Math.floor((time % 3600) / 60);
const seconds = time % 60;
return `${hours < 10 ? "0" + hours : hours}:${minutes < 10 ? "0" + minutes : minutes}:${
seconds < 10 ? "0" + seconds : seconds
}`;
};
const handleClockClick = () => {
setShowTimer(true);
};
useEffect(() => {
let intervalId: NodeJS.Timeout;
if (showTimer) {
intervalId = setInterval(() => {
setTime((time) => time + 1);
}, 1000);
}
return () => clearInterval(intervalId);
}, [showTimer]);
<svg
xmlns='http://www.w3.org/2000/svg'
viewBox='0 0 24 24'
width='1em'
height='1em'
fill='currentColor'
className='h-6 w-6'
>
<path
fillRule='evenodd'
d='M12 4a9 9 0 110 18 9 9 0 010-18zm0 2a7 7 0 100 14 7 7 0 000-14zm0 1.634a1 1 0 01.993.883l.007.117-.001 3.774 2.111 1.162a1 1 0 01.445 1.253l-.05.105a1 1 0 01-1.254.445l-.105-.05-2.628-1.447a1 1 0 01-.51-.756L11 13V8.634a1 1 0 011-1zM16.235 2.4a1 1 0 011.296-.269l.105.07 4 3 .095.08a1 1 0 01-1.19 1.588l-.105-.069-4-3-.096-.081a1 1 0 01-.105-1.319zM7.8 2.4a1 1 0 01-.104 1.319L7.6 3.8l-4 3a1 1 0 01-1.296-1.518L2.4 5.2l4-3a1 1 0 011.4.2z'
clipRule='evenodd'
></path>
</svg>;
<!-- Topbar -->
<nav className='relative flex h-[50px] w-full shrink-0 items-center px-5 bg-dark-layer-1 text-dark-gray-7'>
<div className={`flex w-full items-center justify-between max-w-[1200px] mx-auto`}>
<Link href='/' className='h-[22px] flex-1'>
<img src='/logo-full.png' alt='Logo' className='h-full' />
</Link>
<div className='flex items-center space-x-4 flex-1 justify-end'>
<div>
<a
href='https://www.buymeacoffee.com/burakorkmezz'
target='_blank'
rel='noreferrer'
className='bg-dark-fill-3 py-1.5 px-3 cursor-pointer rounded text-brand-orange hover:bg-dark-fill-2'
>
Premium
</a>
</div>
<Link href='/auth'>
<button className='bg-dark-fill-3 py-1 px-2 cursor-pointer rounded '>Sign In</button>
</Link>
</div>
</div>
</nav>
<!-- **************************** -->
<!-- User Email Wrapper-->
<div
className='absolute top-10 left-2/4 -translate-x-2/4 mx-auto bg-dark-layer-1 text-brand-orange p-2 rounded shadow-lg z-40 group-hover:scale-100 scale-0
transition-all duration-300 ease-in-out'
>
<p className='text-sm'>{user.email}</p>
</div>
<!-- **************************** -->
@tichif
Copy link

tichif commented Aug 1, 2023

@jduhking @Akxai Grab it from the git repository

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment