Skip to content

Commit

Permalink
chore: update code
Browse files Browse the repository at this point in the history
  • Loading branch information
ErKeLost committed Jun 12, 2024
1 parent 25b4f0f commit caa87be
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 32 deletions.
31 changes: 21 additions & 10 deletions src/components/Benchmark/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Translate from "@docusaurus/Translate";
import Link from "@docusaurus/Link";
import React, { useState } from "react";
import clsx from "clsx";
import ShinyTextEx from "../MagicUi/shiny-text";
const BENChMARK_DATA = {
ColdStart: [
{
Expand All @@ -22,7 +23,7 @@ const BENChMARK_DATA = {
},
{
name: "Webpack",
time: 6.870,
time: 6.87,
},
],
HotStart: [
Expand Down Expand Up @@ -90,7 +91,7 @@ const BENChMARK_DATA = {
},
{
name: "Vite",
time: 1.660,
time: 1.66,
},
{
name: "Webpack",
Expand All @@ -100,15 +101,15 @@ const BENChMARK_DATA = {
HotBuild: [
{
name: "Farm",
time: 0.140,
time: 0.14,
},
{
name: "Rspack",
time: 0.515,
},
{
name: "Vite",
time: 1.650,
time: 1.65,
},
{
name: "Webpack",
Expand Down Expand Up @@ -156,7 +157,7 @@ export default function Benchmark() {
function PillTabs({ SCENE, children }) {
return (
<div>
<div className="inline-flex mb-4 items-center rounded-lg text-sm lg:text-base">
<div className="inline-flex w-full mb-4 items-center justify-center rounded-lg text-sm lg:text-base">
{SCENE.map((item, index) => {
return <Pill section={item} key={index}></Pill>;
})}
Expand All @@ -167,14 +168,21 @@ export default function Benchmark() {
}
return (
<>
<div ref={ref} className="flex">
<div ref={ref} className="flex mx-10">
{inView && (
<>
<div
className={`${styles.tabs} flex flex-col items-center my-4 z-1`}
>
<div className="flex h-20 w-full flex-1 items-center self-start lg:justify-end">
<div className="w-full">
<div className="block text-4xl font-semibold h-auto whitespace-pre-wrap bg-gradient-to-br from-[#ffaa40] from-35% to-[#9c40ff] bg-clip-text tracking-tighter text-transparent dark:drop-shadow-[0_5px_5px_rgba(0,0,0,0.8)]">
Performance Comparison
</div>
<div className="mt-6 mb-3 mx-6 text-center sm:text-lg text-gray-500 max-w-3xl">
Testing multiple different frameworks on the same benchmark
project.
</div>
<div className="flex h-20 w-full flex-1 items-center justify-center">
<div className="w-full my-8">
<PillTabs SCENE={SCENE}>
{performanceInfoList.map((info) => (
<div
Expand All @@ -200,12 +208,15 @@ export default function Benchmark() {
</div>
))}
</PillTabs>
<div className="font-bold cursor-pointer">

<div className="font-bold text-right cursor-pointer">
<Link
rel="stylesheet"
href="https://github.com/farm-fe/performance-compare"
>
<Translate>See benchmark details</Translate>
{/* <Translate>
</Translate> */}
<ShinyTextEx />
</Link>
</div>
</div>
Expand Down
49 changes: 49 additions & 0 deletions src/components/MagicUi/border-beam.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { cn } from "../../lib/utils";

interface BorderBeamProps {
className?: string;
size?: number;
duration?: number;
borderWidth?: number;
anchor?: number;
colorFrom?: string;
colorTo?: string;
delay?: number;
}

export default ({
className,
size = 200,
duration = 15,
anchor = 90,
borderWidth = 1.5,
colorFrom = "#ffaa40",
colorTo = "#9c40ff",
delay = 0,
}: BorderBeamProps) => {
return (
<div
style={
{
"--size": size,
"--duration": duration,
"--anchor": anchor,
"--border-width": borderWidth,
"--color-from": colorFrom,
"--color-to": colorTo,
"--delay": `-${delay}s`,
} as React.CSSProperties
}
className={cn(
"absolute z-10 inset-[0] rounded-[inherit] [border:calc(var(--border-width)*1px)_solid_transparent]",

// mask styles
"![mask-clip:padding-box,border-box] ![mask-composite:intersect] [mask:linear-gradient(transparent,transparent),linear-gradient(white,white)]",

// pseudo styles
"after:absolute after:aspect-square after:w-[calc(var(--size)*1px)] after:animate-border-beam after:[animation-delay:var(--delay)] after:[background:linear-gradient(to_left,var(--color-from),var(--color-to),transparent)] after:[offset-anchor:calc(var(--anchor)*1%)_50%] after:[offset-path:rect(0_auto_auto_0_round_calc(var(--size)*1px))]",
className,
)}
/>
);
};
24 changes: 9 additions & 15 deletions src/components/MagicUi/neon-gradient-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ const NeonGradientCard: React.FC<NeonGradientCardProps> = ({
borderSize = 0,
borderRadius = 20,
neonColors = {
firstColor: "#ff00aa",
secondColor: "#00FFF1",
firstColor: "#ffaa40",
secondColor: "#9c40ff",
},
...props
}) => {
Expand Down Expand Up @@ -117,7 +117,8 @@ const NeonGradientCard: React.FC<NeonGradientCardProps> = ({
"--card-content-radius": `${borderRadius - borderSize}px`,
"--pseudo-element-background-image": `linear-gradient(0deg, ${neonColors.firstColor}, ${neonColors.secondColor})`,
"--pseudo-element-width": `${dimensions.width + borderSize * 2}px`,
"--pseudo-element-height": `${dimensions.height + borderSize * 2}px`,
// "--pseudo-element-height": `${dimensions.height + borderSize * 2}px`,
"--pseudo-element-height": `22rem`,
"--after-blur": `${dimensions.width / 3}px`,
} as CSSProperties
}
Expand All @@ -130,23 +131,16 @@ const NeonGradientCard: React.FC<NeonGradientCardProps> = ({
<div
className={cn(
"relative h-full min-h-[inherit] w-full rounded-[var(--card-content-radius)] bg-gray-100 p-6",
// "before:absolute before:-left-[var(--border-size)] before:-top-[var(--border-size)] before:-z-10 before:block",
// "before:h-[var(--pseudo-element-height)] before:w-[var(--pseudo-element-width)] before:rounded-[var(--border-radius)] before:content-['']",
// "before:bg-[linear-gradient(0deg,var(--neon-first-color),var(--neon-second-color))] before:bg-[length:100%_200%]",
// "before:animate-backgroundPositionSpin",
"before:absolute before:top-[-var(--border-size)] before:left-0 before:right-0 before:z-[-10] before:block",
"before:h-[var(--pseudo-element-height)] before:w-full before:content-['']",
"before:bg-[var(--pseudo-element-background-image)] before:bg-[length:200%_100%]",
"before:animate-backgroundPositionSpin",
// "after:absolute after:-left-[var(--border-size)] after:-top-[var(--border-size)] after:-z-10 after:block",
// "after:h-[var(--pseudo-element-height)] after:w-[var(--pseudo-element-width)] after:rounded-[var(--border-radius)] after:blur-[var(--after-blur)] after:content-['']",
// "after:bg-[linear-gradient(0deg,var(--neon-first-color),var(--neon-second-color))] after:bg-[length:100%_200%] after:opacity-80",
// "after:animate-backgroundPositionSpin",
"after:absolute after:top-[-var(--border-size)] after:left-0 after:right-0 after:z-[-10] after:block",
"after:h-[var(--pseudo-element-height)] after:w-full after:content-['']",
"after:bg-[var(--pseudo-element-background-image)] after:bg-[length:200%_100%] after:blur-[var(--after-blur)] after:opacity-80",
"after:absolute after:-left-[var(--border-size)] after:-top-[var(--border-size)] after:-z-10 after:block",
"after:h-[var(--pseudo-element-height)] after:w-[var(--pseudo-element-width)] after:rounded-[var(--border-radius)] after:blur-[var(--after-blur)] after:content-['']",
"after:bg-[linear-gradient(0deg,var(--neon-first-color),var(--neon-second-color))] after:bg-[length:100%_200%] after:opacity-80",
"after:animate-backgroundPositionSpin",
"dark:bg-neutral-900",
// "dark:bg-transparent dark:before:bg-transparent dark:after:bg-transparent",
"navbar--fixed-top"
)}
>
{children}
Expand Down
56 changes: 56 additions & 0 deletions src/components/MagicUi/shiny-text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { ArrowRightIcon } from "lucide-react";
import { cn } from "../../lib/utils";
import { CSSProperties, FC, ReactNode } from "react";

interface AnimatedShinyTextProps {
children: ReactNode;
className?: string;
shimmerWidth?: number;
}

const ShinyText: FC<AnimatedShinyTextProps> = ({
children,
className,
shimmerWidth = 100,
}) => {
return (
<p
style={
{
"--shimmer-width": `${shimmerWidth}px`,
} as CSSProperties
}
className={cn(
"mx-auto max-w-md text-neutral-600/50 dark:text-neutral-400/50 ",

// Shimmer effect
"animate-shimmer bg-clip-text bg-no-repeat [background-position:0_0] [background-size:var(--shimmer-width)_100%] [transition:background-position_1s_cubic-bezier(.6,.6,0,1)_infinite]",

// Shimmer gradient
"bg-gradient-to-r from-transparent via-black/80 via-50% to-transparent dark:via-white/80",

className,
)}
>
{children}
</p>
);
};


export default function ShinyTextEx() {
return (
<div className="z-10 flex items-center justify-end">
<div
className={cn(
"group rounded-full border border-black/5 bg-neutral-100 text-base text-white transition-all ease-in hover:cursor-pointer hover:bg-neutral-200 dark:border-white/5 dark:bg-neutral-900 dark:hover:bg-neutral-800",
)}
>
<ShinyText className="inline-flex items-center justify-center px-4 py-1 transition ease-out hover:text-neutral-600 hover:duration-300 hover:dark:text-neutral-400">
<span>📈 See Benchmark Details</span>
<ArrowRightIcon className="ml-1 size-3 transition-transform duration-300 ease-in-out group-hover:translate-x-0.5" />
</ShinyText>
</div>
</div>
);
}
16 changes: 9 additions & 7 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import Particles from "../components/MagicUi/particles";
import NeonGradientCard from "../components/MagicUi/neon-gradient-card";
import { useTheme } from "next-themes";
import { useEffect, useState } from "react";
import BorderBeam from "../components/MagicUi/border-beam";
function HomepageHeader() {
const { siteConfig } = useDocusaurusContext();
return (
Expand Down Expand Up @@ -126,7 +127,7 @@ export default function Home() {

<div className="mb-10 max-w-md mx-auto w-full px-4 sm:px-6 lg:px-8max-w-6xl">
<div className={clsx(styles.buttons, "flex items-center gap-7")}>
<Link to="/docs/quick-start" style={{ textDecoration: "none", zIndex: 999 }}>
<Link to="/docs/quick-start" style={{ textDecoration: "none", zIndex: 99 }}>
<div
className={clsx(
styles.farmButton,
Expand All @@ -137,7 +138,7 @@ export default function Home() {
</div>
</Link>
<Link
style={{ marginLeft: "20px", textDecoration: "none", zIndex: 999 }}
style={{ marginLeft: "20px", textDecoration: "none", zIndex: 99 }}
to="/docs/why-farm"
>
<div
Expand All @@ -152,12 +153,13 @@ export default function Home() {
</div>
</div>

<NeonGradientCard className="w-full h-screen">
{/* <div className="block h-auto whitespace-pre-wrap bg-gradient-to-br from-[#ff2975] from-35% to-[#00FFF1] bg-clip-text tracking-tighter text-transparent dark:drop-shadow-[0_5px_5px_rgba(0,0,0,0.8)]">

<div className="relative rounded-xl">
<NeonGradientCard className="w-full mt-40">
<Benchmark />
</div> */}
<Benchmark />
</NeonGradientCard>
</NeonGradientCard>
<BorderBeam size={350} duration={18} delay={9} />
</div>
{/* <ParticlesApp /> */}
{/* <HomepageHeader /> */}
{/* <HomepageFeatures /> */}
Expand Down
6 changes: 6 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@ module.exports = {
},
animation: {
shimmer: "shimmer 8s infinite",
"border-beam": "border-beam calc(var(--duration)*1s) infinite linear",
backgroundPositionSpin:
"background-position-spin 3000ms infinite alternate",
},
keyframes: {
"border-beam": {
"100%": {
"offset-distance": "100%",
},
},
shimmer: {
"0%, 90%, 100%": {
"background-position": "calc(-100% - var(--shimmer-width)) 0",
Expand Down

0 comments on commit caa87be

Please sign in to comment.