Skip to content

Commit 4d6271b

Browse files
committed
feat: Box shadow generator for tailwindcss
1 parent e4245c0 commit 4d6271b

File tree

8 files changed

+1018
-29
lines changed

8 files changed

+1018
-29
lines changed

components/BoxShadows/GenerateBoxShadow.js

Lines changed: 480 additions & 0 deletions
Large diffs are not rendered by default.

components/BoxShadows/tailwindColorPalette.js

Lines changed: 412 additions & 0 deletions
Large diffs are not rendered by default.

hooks/useOutsideClick.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React, { useEffect } from "react";
2+
3+
export const useOutsideClick = (ref, callback) => {
4+
useEffect(() => {
5+
const listener = (event) => {
6+
// DO NOTHING if the element being clicked is the target element or their children
7+
if (!ref.current || ref.current.contains(event.target)) {
8+
return;
9+
}
10+
callback(event);
11+
};
12+
13+
document.addEventListener("mousedown", listener);
14+
document.addEventListener("touchstart", listener);
15+
16+
return () => {
17+
document.removeEventListener("mousedown", listener);
18+
document.removeEventListener("touchstart", listener);
19+
};
20+
}, [ref, callback]);
21+
};

package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"qss": "^2.0.3",
4242
"react": "^17.0.2",
4343
"react-dom": "^17.0.2",
44+
"react-hot-toast": "^2.4.0",
4445
"react-icons": "^4.4.0",
4546
"react-rough-notation": "^1.0.1",
4647
"react-syntax-highlighter": "^15.4.5",

pages/boxshadows.js

Lines changed: 79 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from "react";
1+
import React, { useEffect, useRef, useState } from "react";
22
import Container from "@/components/Container";
33
import Link from "next/link";
44
import ProjectCard from "@/components/ProjectCard";
@@ -9,9 +9,17 @@ import { useRouter } from "next/router";
99

1010
import cards from "@/constants/boxshadows/cards";
1111
import Footer from "@/components/Footer";
12+
import { GenerateBoxShadow } from "@/components/BoxShadows/GenerateBoxShadow";
13+
import { useTheme } from "next-themes";
1214

1315
export default function BoxShadows() {
1416
const [visible, setVisible] = useState(false);
17+
const { theme, setTheme } = useTheme();
18+
const [mounted, setMounted] = useState(false);
19+
const scrollRef = useRef(null);
20+
21+
useEffect(() => setMounted(true), []);
22+
const executeScroll = () => scrollRef.current.scrollIntoView();
1523

1624
const onModalClick = () => {
1725
setVisible(!visible);
@@ -20,9 +28,14 @@ export default function BoxShadows() {
2028
return (
2129
<div>
2230
<Metadata />
23-
<CustomNav onModalClick={onModalClick} />
31+
<CustomNav
32+
setTheme={setTheme}
33+
theme={theme}
34+
mounted={mounted}
35+
onModalClick={onModalClick}
36+
/>
2437
<div className="light flex flex-col justify-center items-start mx-auto mb-16">
25-
<Header />
38+
<Header executeScroll={executeScroll} />
2639
{visible && <Modal onModalClick={onModalClick} />}
2740

2841
<div className="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 items-center w-full gap-y-20 mb-40">
@@ -43,7 +56,7 @@ export default function BoxShadows() {
4356
/>
4457
</>
4558
</div>
46-
59+
<GenerateBoxShadow ref={scrollRef} />
4760
<div className="w-full lg:max-w-2xl px-4 sm:mx-auto">
4861
<Contact />
4962
<Footer />
@@ -157,7 +170,7 @@ const Card = ({ shadow, name, vanillaCSS, customCSS }) => {
157170
);
158171
};
159172

160-
const Header = () => {
173+
const Header = ({ executeScroll }) => {
161174
return (
162175
<div className="mb-20 flex flex-col items-center justify-center w-full">
163176
<a
@@ -181,7 +194,7 @@ const Header = () => {
181194
A curated list of box shadows for TailwindCSS. Available in JIT 🚀 and
182195
vanilla CSS.
183196
</h2>
184-
<p className="prose text-gray-700 font-light dark:text-gray-400 mb-20 text-center mx-auto">
197+
<p className="prose text-gray-700 font-light dark:text-gray-400 text-center mx-auto">
185198
<span className="bg-gray-800 border border-gray-100 rounded-md px-1 py-1">
186199
🖱
187200
</span>{" "}
@@ -191,56 +204,93 @@ const Header = () => {
191204
</span>{" "}
192205
to bookmark this page.
193206
</p>{" "}
207+
<div className="w-full items-center max-w-sm mx-auto flex flex-row space-x-2 text-xs text-gray-500 font-light dark:text-gray-400 my-10">
208+
<div className="h-px w-full bg-slate-200 dark:bg-slate-700"></div>
209+
<p>or</p>
210+
<div className="h-px w-full bg-slate-200 dark:bg-slate-700"></div>
211+
</div>
212+
<button
213+
onClick={executeScroll}
214+
className="bg-black/90 px-4 py-2 rounded-md"
215+
>
216+
<div class=" animate-text-shimmer bg-clip-text text-transparent bg-[linear-gradient(110deg,#e2e8f0,45%,#1e293b,55%,#e2e8f0)] bg-[length:250%_100%]">
217+
Tailwind Box Shadow Generator
218+
</div>
219+
</button>
194220
</div>
195221
);
196222
};
197223

198-
const CustomNav = ({ onModalClick }) => {
224+
const CustomNav = ({ onModalClick, setTheme, theme, mounted }) => {
199225
return (
200-
<nav className="w-full h-16 bg-white border-b border-t border-gray-100 px-4 md:px-20 flex flex-row justify-between items-center">
201-
<Link href="/">
202-
<a>
203-
<Image
204-
src="/logo.png"
205-
className="h-full w-full rounded-md"
206-
width="40px"
207-
height="40px"
208-
/>
209-
</a>
210-
</Link>
226+
<nav className="w-full h-16 bg-white dark:bg-zinc-700 dark:border-0 border-b border-t border-gray-100 px-4 md:px-20 flex flex-row justify-between items-center">
227+
<div className="flex items-center space-x-2">
228+
<Link href="/">
229+
<a>
230+
<Image
231+
src="/logo.png"
232+
className="h-full w-full rounded-md"
233+
width="40px"
234+
height="40px"
235+
/>
236+
</a>
237+
</Link>
238+
</div>
211239
<div className="flex flex-row items-center">
240+
{" "}
212241
<a
213242
href="https://github.com/manuarora700/manuarora.in/blob/master/pages/boxshadows.js"
214243
target="__blank"
215244
className="text-gray-400 underline hidden sm:block text-sm font-normal mr-4"
216245
>
217246
Code? Here.
218247
</a>
248+
<button
249+
aria-label="Toggle Dark Mode"
250+
type="button"
251+
className="group rounded-full mr-4 bg-white/90 px-3 py-2 shadow-lg shadow-zinc-800/5 ring-1 ring-zinc-900/5 backdrop-blur transition dark:bg-zinc-900/90 dark:ring-teal-500/50 dark:hover:ring-white/20"
252+
onClick={() => setTheme(theme === "dark" ? "light" : "dark")}
253+
>
254+
{mounted && (
255+
<svg
256+
xmlns="http://www.w3.org/2000/svg"
257+
viewBox="0 0 24 24"
258+
fill="currentColor"
259+
stroke="currentColor"
260+
className="h-4 w-4 text-gray-800 dark:text-teal-500"
261+
>
262+
{theme === "dark" ? (
263+
<path
264+
strokeLinecap="round"
265+
strokeLinejoin="round"
266+
strokeWidth={2}
267+
d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"
268+
/>
269+
) : (
270+
<path
271+
strokeLinecap="round"
272+
strokeLinejoin="round"
273+
strokeWidth={2}
274+
d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"
275+
/>
276+
)}
277+
</svg>
278+
)}
279+
</button>
219280
<button
220281
onClick={onModalClick}
221282
className="text-white hidden sm:block border border-gray-700 bg-black text-sm font-normal rounded-md px-2 py-2 mr-4"
222283
>
223284
Custom CSS to JIT 🚀
224285
</button>
225-
{/* <a
226-
href="https://www.producthunt.com/posts/tailwind-box-shadows"
227-
target="__blank"
228-
className="text-[#EA532A] text-sm font-bold border border-[#EA532A] rounded-md px-2 py-2"
229-
>
230-
Upvote on ProductHunt
231-
</a> */}
232286
<a
233287
href="https://www.producthunt.com/posts/tailwind-box-shadows?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-tailwind-box-shadows"
234288
target="_blank"
235289
>
236290
<img
237291
src="https://api.producthunt.com/widgets/embed-image/v1/featured.svg?post_id=325075&theme=dark"
238292
alt="Tailwind Box Shadows - Curated list of box shadows for your cards to stand out | Product Hunt"
239-
// style={"width: 250px; height: 54px;"}
240-
// style={{ width: "250px", height: "54px" }}
241293
className="h-10 w-auto"
242-
// width="250"
243-
// height="54"
244294
/>
245295
</a>
246296
</div>

styles/globals.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,3 +172,8 @@ input[type="email"] {
172172
@apply mx-auto text-black font-light text-sm h-56 w-56 rounded-md bg-white flex items-center justify-center;
173173
}
174174
}
175+
176+
.pattern {
177+
background-color: #dfdbe5;
178+
background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%239C92AC' fill-opacity='0.4' fill-rule='evenodd'%3E%3Ccircle cx='3' cy='3' r='3'/%3E%3Ccircle cx='13' cy='13' r='3'/%3E%3C/g%3E%3C/svg%3E");
179+
}

tailwind.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module.exports = {
1919
animation: {
2020
blog: "blob 7s infinite",
2121
border: "border 4s ease infinite",
22+
"text-shimmer": "text-shimmer 2.5s ease-out infinite alternate",
2223
},
2324
keyframes: {
2425
blob: {
@@ -35,6 +36,12 @@ module.exports = {
3536
transform: "translate(0px, 0px) ",
3637
},
3738
},
39+
40+
"text-shimmer": {
41+
from: { backgroundPosition: "0 0" },
42+
to: { backgroundPosition: "-200% 0" },
43+
},
44+
3845
border: {
3946
"0%, 100%": { backgroundPosition: "0% 50%" },
4047
"50%": { backgroundPosition: "100% 50%" },

0 commit comments

Comments
 (0)