UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
✨ feat: Add grid and dot pattern (#4)
Dillion Vermad89099959180
diff --git a/app/(docs)/components/page.tsx b/app/(docs)/components/page.tsxindex ebd6347b..111bc7a8 100644--- a/app/(docs)/components/page.tsx+++ b/app/(docs)/components/page.tsx@@ -12,7 +12,7 @@ export const metadata = constructMetadata({export default async function ComponentPage() {const posts = allComponents- .filter((post) => post.date && post.published)+ .filter((post) => post.date <= new Date().toISOString() && post.published).sort((a, b) => {return compareDesc(new Date(a.date), new Date(b.date));});@@ -36,7 +36,7 @@ export default async function ComponentPage() {<FadeIn key={post._id} delay={index * 0.1}><articlekey={post._id}- className="group relative flex grow flex-col overflow-hidden rounded-xl border hover:border-gray-300 dark:border-gray-800 dark:hover:border-gray-700 transition-all duration-300"+ className="group relative flex grow flex-col w-full h-full overflow-hidden rounded-xl border hover:border-gray-300 dark:border-gray-800 dark:hover:border-gray-700 transition-all duration-300">{post.video && (<div className="overflow-hidden">@@ -50,7 +50,7 @@ export default async function ComponentPage() {/></div>)}- <div className="flex grow flex-col p-3">+ <div className="flex flex-1 justify-end flex-col p-3"><h2>{post.title}</h2>{/* {post.date && (<p className="text-sm text-gray-500">diff --git a/config/docs.ts b/config/docs.tsindex 36eb244b..300e865d 100644--- a/config/docs.ts+++ b/config/docs.ts@@ -22,7 +22,9 @@ export const docsConfig: DocsConfig = {{title: "Components",items: allComponents- .filter((post) => post.date && post.published)+ .filter(+ (post) => post.date <= new Date().toISOString() && post.published+ ).sort((a, b) => {return compareDesc(new Date(a.date), new Date(b.date));})diff --git a/content/components/dot-pattern.mdx b/content/components/dot-pattern.mdxnew file mode 100644index 00000000..2e755176--- /dev/null+++ b/content/components/dot-pattern.mdx@@ -0,0 +1,49 @@+---+title: Dot Pattern+date: 2023-07-20+summary: A background dot pattern made with SVGs, fully customizable using Tailwind CSS.+author: dillionverma+published: true+video: https://cdn.magicuikit.com/dot-pattern.mp4+---++<ComponentPreview name="dot-pattern-demo" />++<Steps>++<Step>++## Installation++Copy and page the following code into your project.++```text+components/magicui/dot-pattern.tsx+```++<ComponentSource name="dot-pattern" />++</Step>++</Steps>++## Examples++### Linear Gradient++<ComponentPreview name="dot-pattern-linear-gradient" />++## Props++### Dot Pattern++| Prop | Type | Description | Default |+| --------- | ------ | ----------------------------- | ------- |+| width | any | Width of the dot pattern | 16 |+| height | any | Height of the dot pattern | 16 |+| x | any | X position of the dot | 0 |+| y | any | Y position of the dot | 0 |+| cx | any | X position of the circle | 1 |+| cy | any | Y position of the circle | 1 |+| cr | any | Radius of the circle | 1 |+| className | string | Class name of the dot pattern | - |diff --git a/content/components/grid-pattern.mdx b/content/components/grid-pattern.mdxnew file mode 100644index 00000000..24514797--- /dev/null+++ b/content/components/grid-pattern.mdx@@ -0,0 +1,51 @@+---+title: Grid Pattern+date: 2023-07-18+summary: A background grid pattern made with SVGs, fully customizable using Tailwind CSS.+author: dillionverma+published: true+video: https://cdn.magicuikit.com/grid-pattern.mp4+---++<ComponentPreview name="grid-pattern-demo" />++<Steps>++<Step>++## Installation++Copy and page the following code into your project.++```text+components/magicui/grid-pattern.tsx+```++<ComponentSource name="grid-pattern" />++</Step>++</Steps>++## Examples++### Linear Gradient++<ComponentPreview name="grid-pattern-linear-gradient" />++### Dashed Stroke++<ComponentPreview name="grid-pattern-dashed" />++## Props++### GridPattern++| Prop | Type | Description | Default |+| --------------- | ------ | --------------------------------------------- | ------- |+| width | number | Width of the pattern | 40 |+| height | number | Height of the pattern | 40 |+| x | number | X offset of the pattern | -1 |+| y | number | Y offset of the pattern | -1 |+| squares | number | X Y coordinates of filled squares as 2D array | [] |+| strokeDasharray | string | Stroke dash array for the pattern | 0 |diff --git a/registry/components/example/dot-pattern-demo.tsx b/registry/components/example/dot-pattern-demo.tsxnew file mode 100644index 00000000..0ff50e60--- /dev/null+++ b/registry/components/example/dot-pattern-demo.tsx@@ -0,0 +1,23 @@+"use client";++import { cn } from "@/lib/utils";+import DotPattern from "@/registry/components/magicui/dot-pattern";+import RadialGradient from "@/registry/components/magicui/radial-gradient";++const DotPatternDemo = () => {+ return (+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background overflow-hidden">+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-black dark:text-white z-10">+ Dot Pattern+ </p>+ <DotPattern+ className={cn(+ "[mask-image:radial-gradient(200px_circle_at_center,white,transparent)]"+ )}+ />+ <RadialGradient from="rgba(120,119,198,0.3)" to="rgba(0,0,0,0.0)" />+ </div>+ );+};++export default DotPatternDemo;diff --git a/registry/components/example/dot-pattern-linear-gradient.tsx b/registry/components/example/dot-pattern-linear-gradient.tsxnew file mode 100644index 00000000..631bd568--- /dev/null+++ b/registry/components/example/dot-pattern-linear-gradient.tsx@@ -0,0 +1,33 @@+"use client";++import { cn } from "@/lib/utils";+import DotPattern from "@/registry/components/magicui/dot-pattern";+import LinearGradient from "@/registry/components/magicui/linear-gradient";++const DotPatternDemo2 = () => {+ return (+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background overflow-hidden">+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-black dark:text-white z-10">+ Dot Pattern+ </p>+ <DotPattern+ width={20}+ height={20}+ cx={1}+ cy={1}+ cr={1}+ className={cn(+ "absolute w-full h-full inset-0 fill-white/20",+ "[mask-image:linear-gradient(to_bottom_right,white,transparent,transparent)] "+ )}+ />+ <LinearGradient+ to="rgba(120,119,198,0.3)"+ from="rgba(0,0,0,0.0)"+ direction="bottom right"+ />+ </div>+ );+};++export default DotPatternDemo2;diff --git a/registry/components/example/grid-pattern-dashed.tsx b/registry/components/example/grid-pattern-dashed.tsxnew file mode 100644index 00000000..1b07e694--- /dev/null+++ b/registry/components/example/grid-pattern-dashed.tsx@@ -0,0 +1,29 @@+"use client";++import { cn } from "@/lib/utils";+import GridPattern from "@/registry/components/magicui/grid-pattern";+import RadialGradient from "@/registry/components/magicui/radial-gradient";++const GridPatternDashed = () => {+ return (+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background overflow-hidden">+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-black dark:text-white z-10">+ Grid Pattern+ </p>+ <GridPattern+ width={30}+ height={30}+ x={-1}+ y={-1}+ strokeDasharray={"4 2"}+ className={cn(+ "absolute w-full h-full inset-0 stroke-white/10 fill-white/10",+ "[mask-image:radial-gradient(300px_circle_at_center,white,transparent)]"+ )}+ />+ <RadialGradient from="rgba(120,119,198,0.3)" to="rgba(0,0,0,0.0)" />+ </div>+ );+};++export default GridPatternDashed;diff --git a/registry/components/example/grid-pattern-demo.tsx b/registry/components/example/grid-pattern-demo.tsxnew file mode 100644index 00000000..e61f22dd--- /dev/null+++ b/registry/components/example/grid-pattern-demo.tsx@@ -0,0 +1,32 @@+"use client";++import { cn } from "@/lib/utils";+import GridPattern from "@/registry/components/magicui/grid-pattern";+import RadialGradient from "@/registry/components/magicui/radial-gradient";++const GridPatternDemo = () => {+ return (+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background overflow-hidden">+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-black dark:text-white z-10">+ Grid Pattern+ </p>+ <GridPattern+ squares={[+ [4, 4],+ [5, 1],+ [8, 2],+ [6, 6],+ [10, 5],+ [13, 3],+ ]}+ className={cn(+ "[mask-image:radial-gradient(200px_circle_at_center,white,transparent)]",+ "skew-y-12 inset-x-0 inset-y-[-30%] h-[200%]"+ )}+ />+ <RadialGradient from="rgba(120,119,198,0.3)" to="rgba(0,0,0,0.0)" />+ </div>+ );+};++export default GridPatternDemo;diff --git a/registry/components/example/grid-pattern-linear-gradient.tsx b/registry/components/example/grid-pattern-linear-gradient.tsxnew file mode 100644index 00000000..3647bcdf--- /dev/null+++ b/registry/components/example/grid-pattern-linear-gradient.tsx@@ -0,0 +1,40 @@+"use client";++import { cn } from "@/lib/utils";+import GridPattern from "@/registry/components/magicui/grid-pattern";+import LinearGradient from "@/registry/components/magicui/linear-gradient";++const GridPatternDemo2 = () => {+ return (+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background overflow-hidden">+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-black dark:text-white z-10">+ Grid Pattern+ </p>+ <GridPattern+ width={20}+ height={20}+ x={-1}+ y={-1}+ // squares={[+ // [4, 4],+ // [5, 1],+ // [8, 2],+ // [6, 6],+ // [10, 5],+ // [13, 3],+ // ]}+ className={cn(+ "absolute w-full h-full inset-0 stroke-white/10 fill-white/10",+ "[mask-image:linear-gradient(to_bottom_right,white,transparent,transparent)] "+ )}+ />+ <LinearGradient+ to="rgba(120,119,198,0.3)"+ from="rgba(0,0,0,0.0)"+ direction="bottom right"+ />+ </div>+ );+};++export default GridPatternDemo2;diff --git a/registry/components/example/linear-gradient-demo.tsx b/registry/components/example/linear-gradient-demo.tsxindex 1b8f1074..8fd5bff0 100644--- a/registry/components/example/linear-gradient-demo.tsx+++ b/registry/components/example/linear-gradient-demo.tsx@@ -3,7 +3,7 @@ import LinearGradient from "@/registry/components/magicui/linear-gradient";export default function LinearGradientDemo() {return (<div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background">- <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-white z-10">+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-black dark:text-white z-10">Linear Gradient</p><LinearGradient />diff --git a/registry/components/example/magic-card-demo.tsx b/registry/components/example/magic-card-demo.tsxindex ec562ff1..e9b082e5 100644--- a/registry/components/example/magic-card-demo.tsx+++ b/registry/components/example/magic-card-demo.tsx@@ -7,7 +7,7 @@ export default function MagicCardWithGradient() {return (<MagicContainerclassName={- "grid w-full lg:grid-cols-2 grid-cols-1 gap-4 min-h-[500px] lg:min-h-[250px]"+ "flex flex-col gap-4 h-[500px] lg:h-[250px] w-full lg:flex-row"}><MagicCard className="cursor-pointer shadow-2xl flex flex-col justify-center items-center overflow-hidden bg-background p-6">diff --git a/registry/components/example/meteors-demo.tsx b/registry/components/example/meteors-demo.tsxindex 994a49ee..df846020 100644--- a/registry/components/example/meteors-demo.tsx+++ b/registry/components/example/meteors-demo.tsx@@ -4,7 +4,7 @@ export default function MeteorDemo() {return (<div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background overflow-hidden"><Meteors />- <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-white z-10">+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-black dark:text-white z-10">Meteors</p><div className="pointer-events-none h-full absolute inset-0 bg-[radial-gradient(circle_at_50%_120%,rgba(120,119,198,0.3),rgba(255,255,255,0))]" />diff --git a/registry/components/example/radial-gradient-demo.tsx b/registry/components/example/radial-gradient-demo.tsxindex 1374006b..ccd22ca7 100644--- a/registry/components/example/radial-gradient-demo.tsx+++ b/registry/components/example/radial-gradient-demo.tsx@@ -3,7 +3,7 @@ import RadialGradient from "@/registry/components/magicui/radial-gradient";export default function RadialGradientDemo() {return (<div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background">- <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-white z-10">+ <p className="text-5xl font-medium tracking-tighter whitespace-nowrap text-black dark:text-white z-10">Radial Gradient</p><RadialGradient />diff --git a/registry/components/magicui/dot-pattern.tsx b/registry/components/magicui/dot-pattern.tsxnew file mode 100644index 00000000..cced0121--- /dev/null+++ b/registry/components/magicui/dot-pattern.tsx@@ -0,0 +1,55 @@+import { cn } from "@/lib/utils";+import { useId } from "react";++interface DotPatternProps {+ width?: any;+ height?: any;+ x?: any;+ y?: any;+ cx?: any;+ cy?: any;+ cr?: any;+ className?: string;+ [key: string]: any;+}+export function DotPattern({+ width = 16,+ height = 16,+ x = 0,+ y = 0,+ cx = 1,+ cy = 1,+ cr = 1,+ className,+ ...props+}: DotPatternProps) {+ const id = useId();++ return (+ <svg+ aria-hidden="true"+ className={cn(+ "absolute w-full h-full inset-0 fill-gray-400/30",+ className+ )}+ {...props}+ >+ <defs>+ <pattern+ id={id}+ width={width}+ height={height}+ patternUnits="userSpaceOnUse"+ patternContentUnits="userSpaceOnUse"+ x={x}+ y={y}+ >+ <circle id="pattern-circle" cx={cy} cy={cy} r={cr} />+ </pattern>+ </defs>+ <rect width="100%" height="100%" strokeWidth={0} fill={`url(#${id})`} />+ </svg>+ );+}++export default DotPattern;diff --git a/registry/components/magicui/grid-pattern.tsx b/registry/components/magicui/grid-pattern.tsxindex 95b9ff74..8dc8a557 100644--- a/registry/components/magicui/grid-pattern.tsx+++ b/registry/components/magicui/grid-pattern.tsx@@ -1,24 +1,38 @@+import { cn } from "@/lib/utils";import { useId } from "react";-export function GridPattern({- width,- height,- x,- y,- squares,- ...props-}: {+interface GridPatternProps {width?: any;height?: any;x?: any;y?: any;- squares?: any;+ squares?: Array<[x: number, y: number]>;+ strokeDasharray?: any;+ className?: string;[key: string]: any;-}) {+}++export function GridPattern({+ width = 40,+ height = 40,+ x = -1,+ y = -1,+ strokeDasharray = 0,+ squares,+ className,+ ...props+}: GridPatternProps) {const id = useId();return (- <svg aria-hidden="true" {...props}>+ <svg+ aria-hidden="true"+ className={cn(+ "absolute w-full h-full inset-0 stroke-gray-400/30 fill-gray-400/30",+ className+ )}+ {...props}+ ><defs><patternid={id}@@ -28,20 +42,24 @@ export function GridPattern({x={x}y={y}>- <path d={`M.5 ${height}V.5H${width}`} fill="none" />+ <path+ d={`M.5 ${height}V.5H${width}`}+ fill="none"+ strokeDasharray={strokeDasharray}+ /></pattern></defs><rect width="100%" height="100%" strokeWidth={0} fill={`url(#${id})`} />{squares && (<svg x={x} y={y} className="overflow-visible">- {squares.map(([x, y]: [x: any, y: any]) => (+ {squares.map(([x, y]) => (<rectstrokeWidth="0"key={`${x}-${y}`}- width={width + 1}- height={height + 1}- x={x * width}- y={y * height}+ width={width - 1}+ height={height - 1}+ x={x * width + 1}+ y={y * height + 1}/>))}</svg>diff --git a/registry/components/magicui/magic-card.tsx b/registry/components/magicui/magic-card.tsxindex 93d92ffc..d0a2c594 100644--- a/registry/components/magicui/magic-card.tsx+++ b/registry/components/magicui/magic-card.tsx@@ -109,6 +109,13 @@ const MagicContainer = ({ children, className }: MagicContainerProps) => {};interface MagicCardProps {+ /**+ * @default div+ * @type React.ElementType+ * @description+ * The component to render the card as+ * */+ as?: React.ElementType;/*** @default ""* @type string@@ -191,6 +198,7 @@ interface MagicCardProps {}const MagicCard = ({+ as: Component = "div", // Default to 'div' if no component is passedclassName,children,size = 600,@@ -209,7 +217,7 @@ const MagicCard = ({"after:pointer-events-none after:absolute after:w-full after:h-full after:rounded-[var(--border-radius)] after:top-0 after:left-0 after:duration-500 after:transition-opacity after:bg-[radial-gradient(var(--mask-size)_circle_at_var(--mouse-x)_var(--mouse-y),var(--border-color),transparent_40%)] after:z-[1]";return (- <div+ <Componentstyle={{"--border-radius": `${borderRadius}px`,@@ -221,7 +229,7 @@ const MagicCard = ({} as CSSProperties}className={cn(- "relative rounded-[var(--border-radius)] overflow-hidden",+ "relative w-full h-full rounded-[var(--border-radius)] overflow-hidden",isolated && [borderStyles, "after:opacity-0 after:hover:opacity-100"],isolated &&spotlight && [@@ -241,7 +249,7 @@ const MagicCard = ({>{children}</div>- </div>+ </Component>);};diff --git a/registry/components/magicui/retro-grid.tsx b/registry/components/magicui/retro-grid.tsxnew file mode 100644index 00000000..f70471bd--- /dev/null+++ b/registry/components/magicui/retro-grid.tsx@@ -0,0 +1,43 @@+"use client";++import { cn } from "@/lib/utils";++const RetroGrid = ({ className }) => {+ const gridStyle = {+ width: "100%",+ height: "600px",+ overflow: "hidden",+ zIndex: 10,+ perspective: "450px",+ };++ // const gridFadeStyle = {+ // width: "100%",+ // height: "100%",+ // // position: "absolute",+ // zIndex: 11,+ // background:+ // "radial-gradient(circle at 50% 50%, rgba(120,119,198,0.3) 0%, rgba(0, 0, 0, 0.6) 80%)",+ // };++ const gridLinesStyle = {+ backgroundImage:+ "linear-gradient(to right, rgba(255, 255, 255, 0.3) 1px, transparent 0), linear-gradient(to bottom, rgba(255, 255, 255, 0.3) 1px, transparent 0)",+ backgroundSize: "40px 40px",+ backgroundRepeat: "repeat",+ transformOrigin: "100% 0 0",+ };++ return (+ <div className={cn("overflow-hidden", className)}>+ <div style={gridStyle}>+ <div+ className="w-screen h-screen animate-grid"+ style={gridLinesStyle}+ />+ </div>+ </div>+ );+};++export default RetroGrid;diff --git a/registry/index.tsx b/registry/index.tsxindex f143c356..a7ce164e 100644--- a/registry/index.tsx+++ b/registry/index.tsx@@ -22,6 +22,16 @@ const ui: Registry = {type: "components:ui",files: ["registry/components/magicui/meteors.tsx"],},+ "grid-pattern": {+ name: "grid-pattern",+ type: "components:ui",+ files: ["registry/components/magicui/grid-pattern.tsx"],+ },+ "dot-pattern": {+ name: "dot-pattern",+ type: "components:ui",+ files: ["registry/components/magicui/dot-pattern.tsx"],+ },};const example: Registry = {@@ -57,6 +67,46 @@ const example: Registry = {() => import("@/registry/components/example/meteors-demo")),},+ "grid-pattern-demo": {+ name: "grid-pattern-demo",+ type: "components:example",+ files: ["registry/components/example/grid-pattern-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/grid-pattern-demo")+ ),+ },+ "grid-pattern-linear-gradient": {+ name: "grid-pattern-linear-gradient",+ type: "components:example",+ files: ["registry/components/example/grid-pattern-linear-gradient.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/grid-pattern-linear-gradient")+ ),+ },+ "grid-pattern-dashed": {+ name: "grid-pattern-dashed",+ type: "components:example",+ files: ["registry/components/example/grid-pattern-dashed.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/grid-pattern-dashed")+ ),+ },+ "dot-pattern-demo": {+ name: "dot-pattern-demo",+ type: "components:example",+ files: ["registry/components/example/dot-pattern-demo.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/dot-pattern-demo")+ ),+ },+ "dot-pattern-linear-gradient": {+ name: "dot-pattern-linear-gradient",+ type: "components:example",+ files: ["registry/components/example/dot-pattern-linear-gradient.tsx"],+ component: React.lazy(+ () => import("@/registry/components/example/dot-pattern-linear-gradient")+ ),+ },};export const registry: Registry = {diff --git a/tailwind.config.js b/tailwind.config.tssimilarity index 86%rename from tailwind.config.jsrename to tailwind.config.tsindex 247ecde0..467ca9d5 100644--- a/tailwind.config.js+++ b/tailwind.config.ts@@ -1,4 +1,6 @@const colors = require("tailwindcss/colors");+import { type Config } from "tailwindcss";+/** @type {import('tailwindcss').Config} */module.exports = {@@ -63,15 +65,16 @@ module.exports = {"accordion-up": "accordion-up 0.2s ease-out",gradient: "gradient 8s linear infinite",meteor: "meteor 5s linear infinite",+ grid: "grid 15s linear infinite",},keyframes: {"accordion-down": {- from: { height: 0 },+ from: { height: "0" },to: { height: "var(--radix-accordion-content-height)" },},"accordion-up": {from: { height: "var(--radix-accordion-content-height)" },- to: { height: 0 },+ to: { height: "0" },},gradient: {to: {@@ -79,15 +82,19 @@ module.exports = {},},meteor: {- "0%": { transform: "rotate(215deg) translateX(0)", opacity: 1 },- "70%": { opacity: 1 },+ "0%": { transform: "rotate(215deg) translateX(0)", opacity: "1" },+ "70%": { opacity: "1" },"100%": {transform: "rotate(215deg) translateX(-500px)",- opacity: 0,+ opacity: "0",},},+ grid: {+ "0%": { transform: "rotateX(45deg) translateY(-50%)" },+ "100%": { transform: "rotateX(45deg) translateY(0)" },+ },},},},plugins: [require("tailwindcss-animate"), require("@tailwindcss/typography")],-};+} satisfies Config;