-
Notifications
You must be signed in to change notification settings - Fork 486
feat: support classNames and styles #928
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该 PR 在 Tree 组件体系中引入了语义化样式与类名支持。新定义了 Changes
Sequence Diagram(s)sequenceDiagram
participant T as Tree Component
participant TP as TreeContext.Provider
participant N as TreeNode Component
T->>TP: 提供 styles 与 classNames
TP->>N: 分发更新后的上下文
N->>N: 应用 context 中的样式和类名
Possibly related PRs
Suggested reviewers
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/Tree.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. tests/Tree.spec.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/TreeNode.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. Tip ⚡🧪 Multi-step agentic review comment chat (experimental)
✨ Finishing Touches
🪧 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)
src/Tree.tsx (1)
1418-1419: 将样式和类名属性传递给上下文将
styles和treeClassNames(作为classNames)添加到上下文值中,使这些属性在组件树中的所有子组件都可以访问。建议为这些新属性添加单元测试,确保它们能正确地从 Tree 组件传递到 TreeNode 组件,并验证样式和类名应用得当。
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
src/Tree.tsx(3 hunks)src/TreeNode.tsx(6 hunks)tests/Tree.spec.tsx(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- src/TreeNode.tsx
- tests/Tree.spec.tsx
🔇 Additional comments (3)
src/Tree.tsx (3)
86-86: 定义了语义化类型SemanticName这个新增的类型标记了树组件中可以应用样式和类名的特定元素:项目图标、项目和项目标题。这为样式定制提供了类型安全的基础。
91-92: 添加了语义化样式和类名支持为
TreeProps接口添加了styles和classNames属性,允许根据语义名称映射自定义样式和类名。这增强了组件的样式定制能力。
1369-1370: 从 props 中解构新属性正确地从 props 中解构了
styles和classNames,并重命名classNames为treeClassNames以避免与内部变量冲突。
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #928 +/- ##
=======================================
Coverage 99.84% 99.84%
=======================================
Files 14 14
Lines 1274 1275 +1
Branches 383 393 +10
=======================================
+ Hits 1272 1273 +1
Misses 2 2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
建议每一项支持 函数方式设置,接收nodeData及level数据,如我的需求是 不同层级的 Node 需要不同的样式 |
Summary by CodeRabbit