Skip to content

Commit 04a927a

Browse files
committed
refactor: remove benchmark animation
1 parent 2ec3411 commit 04a927a

5 files changed

Lines changed: 14 additions & 95 deletions

File tree

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,6 @@
7070
"bump": "npx bumpp",
7171
"chromatic": "chromatic"
7272
},
73-
"dependencies": {
74-
"framer-motion": "^12.23.25"
75-
},
7673
"nano-staged": {
7774
"*.{md,mdx,json,css,less,scss}": "prettier --write",
7875
"*.{js,jsx,ts,tsx,mjs,cjs}": [
@@ -104,7 +101,6 @@
104101
"prettier": "~3.7.4",
105102
"react": "^18.3.1",
106103
"react-dom": "^18.3.1",
107-
"react-intersection-observer": "^10.0.0",
108104
"rimraf": "~6.1.2",
109105
"semver": "7.7.3",
110106
"simple-git-hooks": "^2.13.1",

pnpm-lock.yaml

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

rslib.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default defineConfig({
4343
],
4444
output: {
4545
target: 'web',
46-
externals: ['react', 'react-dom', 'react/jsx-runtime', 'framer-motion'],
46+
externals: ['react', 'react-dom', 'react/jsx-runtime'],
4747
filename: {
4848
js: '[name]/index.js',
4949
css: '[name]/index.css',

src/benchmark/ProgressBar.tsx

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import { motion } from 'framer-motion';
2-
import { useState } from 'react';
31
import styles from './ProgressBar.module.scss';
42

5-
export function formatTime(time: number, totalTime: number) {
6-
if (totalTime < 1000) {
3+
export function formatTime(time: number) {
4+
if (time < 1000) {
75
return `${time.toFixed(0)}ms`;
86
}
97
return `${(time / 1000).toFixed(2)}s`;
@@ -13,37 +11,24 @@ export function ProgressBar({
1311
value,
1412
max,
1513
desc,
16-
inView,
1714
}: {
1815
value: number;
1916
max: number;
2017
desc: string;
21-
inView: boolean;
2218
}) {
23-
const [elapsedTime, setElapsedTime] = useState(0);
24-
const TOTAL_TIME = value * 1000;
25-
const variants = {
26-
initial: { width: 0 },
27-
animate: { width: `${(value / max) * 100}%` },
28-
};
29-
30-
const formattedTime = formatTime(elapsedTime, TOTAL_TIME);
19+
const formattedTime = formatTime(value * 1000);
3120
return (
3221
<div className={styles.container}>
3322
<div className={styles.innerContainer}>
34-
{inView ? (
35-
<motion.div
36-
className={styles.bar}
37-
initial="initial"
38-
animate="animate"
39-
variants={variants}
40-
onUpdate={(latest: { width: string }) => {
41-
const width = Number.parseFloat(latest.width);
42-
setElapsedTime(width * max * 10);
43-
}}
44-
transition={{ duration: value, ease: 'linear' }}
45-
/>
46-
) : null}
23+
<div
24+
className={styles.bar}
25+
style={{ width: `${(value / max) * 100}%` }}
26+
// onUpdate={(latest: { width: string }) => {
27+
// const width = Number.parseFloat(latest.width);
28+
// setElapsedTime(width * max * 10);
29+
// }}
30+
// transition={{ duration: value, ease: 'linear' }}
31+
/>
4732
</div>
4833
<div className={styles.desc}>
4934
<span className={styles.time}>{formattedTime}</span> {desc}

src/benchmark/index.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useInView } from 'react-intersection-observer';
21
import { ProgressBar } from './ProgressBar';
32
import styles from './index.module.scss';
43

@@ -30,11 +29,8 @@ const findMaxTime = (data: BenchmarkData) => {
3029

3130
export function Benchmark({ data }: BenchmarkProps) {
3231
const maxTime = findMaxTime(data);
33-
const { ref, inView } = useInView({
34-
triggerOnce: true,
35-
});
3632
return (
37-
<div className={styles.root} ref={ref}>
33+
<div className={styles.root}>
3834
{Object.values(data).map(item => (
3935
<div key={item.label} className={styles.item}>
4036
<p className={styles.progressName}>{item.label}</p>
@@ -45,7 +41,6 @@ export function Benchmark({ data }: BenchmarkProps) {
4541
value={metric.time}
4642
max={maxTime}
4743
desc={metric.desc}
48-
inView={inView}
4944
/>
5045
))}
5146
</div>

0 commit comments

Comments
 (0)