feat(number-animation): Add NumberAnimation component
PR
PR Checklist
增加NumberAnimation 组件 Please check if your PR fulfills the following requirements:
- [ ] The commit message follows our Commit Message Guidelines
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
PR Type
What kind of change does this PR introduce?
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
- [ ] Yes
- [ ] No
Other information
Summary by CodeRabbit
-
New Features
- Introduced a Number Animation component for PC, enabling animated transitions between numeric values with customizable duration, precision, and thousand separators.
- Added support for programmatically starting the animation and handling completion events.
- Provided multiple demo examples showcasing basic usage, precision control, separator customization, and event handling.
- Added new menu entry and documentation for the Number Animation component in both Chinese and English.
-
Bug Fixes
- None.
-
Documentation
- Added multilingual documentation and structured demo metadata for the Number Animation component.
-
Style
- Introduced new styles and variables for number animation, including font size, weight, and spacing.
-
Tests
- Added automated tests to verify basic functionality, precision, separator formatting, and event handling for the Number Animation component.
-
Chores
- Updated package configuration and dependencies to include the new Number Animation component.
Walkthrough
This update introduces a new Number Animation component for Vue, including its core implementation, renderless logic, styles, documentation, demos, and tests. The component animates numeric values with customizable precision, separators, and duration, and emits a finish event upon completion. Supporting files include configuration and documentation in both English and Chinese, multiple Vue demo examples, Playwright and Vitest tests, and integration into the package and menu systems. Styling is handled with new LESS files, and the component is registered in the build and module configuration for PC mode usage.
Changes
| File(s) | Change Summary |
|---|---|
packages/vue/src/number-animation/index.ts, src/index.ts, src/pc.vue, package.json |
Added new NumberAnimation Vue component, its entry point, PC template, and package metadata. |
packages/renderless/src/number-animation/index.ts, vue.ts |
Introduced renderless logic for number animation, including state management, animation control, and formatting. |
packages/theme/src/number-animation/index.less, vars.less |
Added LESS styles and variable mixins for number animation component appearance. |
examples/sites/demos/apis/number-animation.js |
Added API configuration describing NumberAnimation component properties, events, and methods. |
examples/sites/demos/pc/app/number-animation/basic-usage.vue, basic-usage-composition-api.vue, finish-events.vue, finish-events-composition-api.vue, precision.vue, precision-composition-api.vue, separator.vue, separator-composition-api.vue |
Added Vue demo components showing various NumberAnimation usages (basic, event, precision, separator) with both Options and Composition API. |
examples/sites/demos/pc/app/number-animation/basic-usage.spec.ts, finish-events.spec.ts, precision.spec.ts, separator.spec.ts |
Added Playwright tests for each NumberAnimation demo to verify correct behavior and output. |
examples/sites/demos/pc/app/number-animation/webdoc/number-animation.en.md, number-animation.cn.md, number-animation.js |
Added English and Chinese documentation and structured demo metadata for NumberAnimation. |
examples/sites/demos/pc/menus.js |
Added NumberAnimation to the data display section of the component menu. |
packages/modules.json |
Registered NumberAnimation component and template for PC mode in module configuration. |
packages/vue/package.json |
Added dependency on @opentiny/vue-number-animation package. |
packages/vue/src/number-animation/__tests__/number-animation.test.tsx |
Added empty Vitest test suite for NumberAnimation (PC Mode). |
packages/theme/src/table/index.less, vars.less |
Updated table styles and variables to use new icon border color variable. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant NumberAnimationComponent
participant RenderlessLogic
participant UI
User->>NumberAnimationComponent: Clicks Play Button
NumberAnimationComponent->>RenderlessLogic: play()
RenderlessLogic->>RenderlessLogic: Animate value from 'from' to 'to'
RenderlessLogic->>NumberAnimationComponent: Update animated value
NumberAnimationComponent->>UI: Display formatted value
RenderlessLogic-->>NumberAnimationComponent: Emit 'finish' event on completion
NumberAnimationComponent->>UI: Show finish message/modal (if handled)
Poem
In the garden of numbers, a new dance begins,
With commas and decimals, the animation spins.
From zero to millions, the digits parade,
Precision and style in every cascade.
Click "播放" to start, watch numbers take flight,
As rabbits and coders both cheer with delight!
🐇✨ 1, 2, 3... the magic is bright!
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
examples/sites/demos/pc/app/number-animation/basic-usage-composition-api.vue
Oops! Something went wrong! :(
ESLint: 8.57.1
ESLint couldn't find the plugin "eslint-plugin-vue".
(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm install eslint-plugin-vue@latest --save-devThe plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".
If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
examples/sites/demos/pc/app/number-animation/basic-usage.spec.ts
Oops! Something went wrong! :(
ESLint: 8.57.1
ESLint couldn't find the plugin "eslint-plugin-vue".
(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm install eslint-plugin-vue@latest --save-devThe plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".
If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
examples/sites/demos/pc/app/number-animation/basic-usage.vue
Oops! Something went wrong! :(
ESLint: 8.57.1
ESLint couldn't find the plugin "eslint-plugin-vue".
(The package "eslint-plugin-vue" was not found when loaded as a Node module from the directory "".)
It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
npm install eslint-plugin-vue@latest --save-devThe plugin "eslint-plugin-vue" was referenced from the config file in ".eslintrc.js » @antfu/eslint-config » @antfu/eslint-config-vue".
If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
- 18 others
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Generate unit testing code for this file.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai generate unit testing code for this file.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and generate unit testing code.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
Walkthrough
The PR introduces a new NumberAnimation component to the tiny-vue library. This component allows for animated transitions between numerical values, with customizable properties such as duration, precision, and separators. It includes various demos and tests to showcase its functionality.
Changes
| Files | Summary |
|---|---|
examples/sites/demos/apis/number-animation.js |
Added API documentation for the NumberAnimation component. |
examples/sites/demos/pc/app/number-animation/*.vue |
Added demo files for different usage scenarios of the NumberAnimation component. |
examples/sites/demos/pc/app/number-animation/*.spec.ts |
Added test files for the NumberAnimation component demos. |
examples/sites/demos/pc/app/number-animation/webdoc/*.md |
Added documentation files for the NumberAnimation component in both Chinese and English. |
examples/sites/demos/pc/app/number-animation/webdoc/number-animation.js |
Added demo configuration for the NumberAnimation component. |
examples/sites/demos/pc/menus.js |
Updated menu configuration to include NumberAnimation. |
packages/modules.json |
Updated module configuration to include NumberAnimation. |
packages/renderless/src/number-animation/index.ts |
Added renderless logic for the NumberAnimation component. |
packages/renderless/src/number-animation/vue.ts |
Added Vue-specific logic for the NumberAnimation component. |
packages/theme/src/number-animation/*.less |
Added theme styles for the NumberAnimation component. |
packages/theme/src/table/*.less |
Updated table styles to include new color variables. |
packages/vue/package.json |
Updated package configuration to include NumberAnimation. |
packages/vue/src/number-animation/*.ts |
Added Vue component logic and configuration for NumberAnimation. |
packages/vue/src/number-animation/src/pc.vue |
Added Vue template for the NumberAnimation component. |
[e2e-test-warn] The component to be tested is missing.
The title of the Pull request should look like "fix(vue-renderless): [action-menu, alert] fix xxx bug".
Please make sure you've read our contributing guide