-
-
Notifications
You must be signed in to change notification settings - Fork 13
perf-test: add custom slider for box size control #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds a customizable box size slider to the perf-test page, allowing users to dynamically control the dimensions of animation boxes. The implementation includes visual slider styling and improves text truncation for animation labels.
- Added an interactive range slider with custom styling to control animation box dimensions
- Replaced static size values with dynamic state management using React hooks
- Improved animation name display with proper text truncation using CSS ellipsis
Reviewed Changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
perf-test/package.json | Updates package dependency to use local file reference |
perf-test/app/page.tsx | Implements slider functionality, state management, and text truncation |
perf-test/app/globals.css | Adds custom CSS styling for the range slider component |
@ROWELLI Hello, I cannot review due to build failure. Could you check the build? ![]() |
@ROWELLI If this updates the UI or its behavior, a new ui screenshot or video would be appreciated. Thanks. |
I’ve added the video to the first comment for reference. |
@ROWELLI Thanks. IMO, The current updated usage seems not very useful, since we can achieve the same result simply by adjusting the browser’s zoom level. I think, a more practical usage would be to adjust the grid cell size along with the content, allowing more items to be packed into a row as the content gets smaller. |
cc4a12a
to
abe2df4
Compare
abe2df4
to
c298eb5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perf-test/app/globals.css
Outdated
input[type="range"].slider { | ||
appearance: none; | ||
-webkit-appearance: none; | ||
-moz-appearance: none; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since modern browsers already recognize appearance
as a standard property, it’s not necessary to duplicate it with vendor prefixes. If everything works as expected, let’s simplify and keep only the standard declaration
perf-test/app/page.tsx
Outdated
|
||
slider.style.background = `linear-gradient(to right, #00deb5 0%, #00deb5 ${percent}%, #444 ${percent}%, #444 100%)`; | ||
} | ||
}, [size.width]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size.width
is already a state variable. Using useEffect only to compute derived values and manually update the DOM style is not ideal. Consider expressing this as reactive data through props or inline styles instead, so React handles the updates automatically.
Also directly manipulating the DOM style like sliderRef.style.background = ...
goes against React’s principles. This approach can conflict with React’s state-driven rendering, causing styles managed by state to be overridden or ignored. It also reduces code maintainability and makes UI updates less predictable. Instead the background can be controlled via React state or props.
c298eb5
to
64f432a
Compare
@nunomi0 is attempting to deploy a commit to the thorvg-web Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality looks good. Let's do some final minor code cleanup.
border-radius: 50%; | ||
border: none; | ||
cursor: pointer; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two styles look to indicate exactly the same
input[type="range"].slider::-webkit-slider-thumb,
input[type="range"].slider::-moz-range-thumb {
appearance: none;
width: 20px;
height: 20px;
background: #00deb5;
border-radius: 50%;
border: none;
cursor: pointer;
}
value={size.width} | ||
onChange={(e) => handleSliderChange(Number(e.target.value))} | ||
className="slider" | ||
style={sliderStyle} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style={{
background: `linear-gradient(to right, #00deb5 0%, #00deb5 ${percent}%, #444 ${percent}%, #444 100%)`,
}}
Please remove sliderStyle
variable
const [size, setSize] = useState(isMobile ? { width: 150, height: 150 } : { width: 180, height: 180 }); | ||
|
||
const minSize = 50; | ||
const maxSize = 180; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Constants declared inside a function are recreated on every render.
- Even though their values don’t change,
- they are repeatedly allocated and deallocated in memory.
Summary
This PR adds a box size slider to the
perf-test
page and improves the animation label rendering by truncating long names to fit within the box.Main Changes
input[type=range]
slider to control the width/height of each animation boxslider_layout.mov