-
-
Notifications
You must be signed in to change notification settings - Fork 329
feat: support classnames and styles #641
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Walkthrough本次更改为分页组件引入了更高的灵活性。Pager 组件的 Changes
Sequence Diagram(s)sequenceDiagram
participant U as 用户
participant P as Pagination组件
participant Pg as Pager组件
participant LI as <li>元素
U->>P: 提供自定义的classNames与styles
P->>Pg: 将classNames与styles传递到pagerProps
Pg->>LI: 应用自定义的class与内联样式
Poem
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
src/Pagination.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-react". (The package "eslint-plugin-react" 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:
The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs[email protected]_jest@29.7.0_@types[email protected][email protected]/node_modules/@umijs/fabric/dist/eslint.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. src/interface.tsOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-react". (The package "eslint-plugin-react" 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:
The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs[email protected]_jest@29.7.0_@types[email protected][email protected]/node_modules/@umijs/fabric/dist/eslint.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. src/Pager.tsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-react". (The package "eslint-plugin-react" 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:
The plugin "eslint-plugin-react" was referenced from the config file in ".eslintrc.js » /node_modules/.pnpm/@umijs[email protected]_jest@29.7.0_@types[email protected][email protected]/node_modules/@umijs/fabric/dist/eslint.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/index.test.tsx (1)
244-256
: 测试用例完整验证样式功能。测试用例验证了:
- 自定义类名 'custom-test' 正确应用
- 内联样式
color: red
正确应用建议添加以下测试场景:
- 多个样式属性的组合
- 动态样式变更
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
src/Pager.tsx
(3 hunks)src/Pagination.tsx
(2 hunks)src/interface.ts
(1 hunks)tests/index.test.tsx
(1 hunks)
🔇 Additional comments (6)
src/Pager.tsx (2)
11-11
: 接口扩展正确实现样式自定义。
style
属性的类型定义正确使用了 React 内置的CSSProperties
类型。
27-27
: 样式属性的解构和应用实现恰当。样式属性从 props 中解构并正确应用到
li
元素上。Also applies to: 59-59
src/interface.ts (2)
21-21
: 语义化类型定义清晰。
SemanticName
类型限定了有效值为 'item',为未来可能的扩展预留了空间。
24-25
: 样式和类名接口设计合理。使用
Partial<Record>
类型使得属性可选,同时保持了类型安全:
styles
确保了样式对象的类型安全classNames
正确定义了字符串类型的类名src/Pagination.tsx (2)
39-40
: 属性解构命名清晰。
classNames
重命名为paginationClassNames
避免了与内置classnames
工具的混淆。
337-339
: 样式属性正确传递给分页项。通过
pagerProps
对象将样式和类名属性传递给Pager
组件,实现了样式的定制化。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #641 +/- ##
=======================================
Coverage 99.03% 99.03%
=======================================
Files 3 3
Lines 310 310
Branches 139 139
=======================================
Hits 307 307
Misses 3 3 ☔ View full report in Codecov by Sentry. |
Summary by CodeRabbit
新功能
测试