[v2] Port additional CSS variable observation from PR #430
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- react, typescript
调研方向
Start in packages/graph-css-variables and read the current CSSVariablesLayerProps implementation and observer tests, then compare the reviewed behavior in PR #430. Add coverage for custom variable reads, updates, subscription changes, and equal-list updates; the issue also names apps/storybook/src/stories/plugins/cssVariables for the example. Done means the listed unit and browser cases, package documentation, and declarations meet the acceptance criteria.
由索引模型根据 Issue 内容生成。
描述
Goal
Port the additionalCSSVariables capability from #430 to the v2 branch so applications can observe their own CSS variables and use onChange to update custom graph components, such as group colors.
The target is @gravity-ui/graph-css-variables (packages/graph-css-variables), extracted in #402. Adapt the final reviewed behavior of #430 to the current v2 implementation.
Scope
- Add
additionalCSSVariablesto the publicCSSVariablesLayerProps. - Observe custom names alongside built-in variables, including initial reads and subsequent change notifications.
- Report custom values through
onChange; keep built-in graph color/constant mappings unchanged. Custom-only updates must not callgraph.setColors()orgraph.setConstants(). - Support replacing and clearing the list: newly added names become observable, removed names stop producing notifications, and unregistered names are filtered out.
- Apply subscription changes using the updated props and clean up the previous observation correctly.
- Preserve v2's proxy-based observation, unset-value handling, and
oldValuetracking. Cover variables that are initially unset and become defined later. - Keep the implementation and public exports in
graph-css-variables, with React usage through@gravity-ui/graph-react.
Carry over the notification-loop fix
The version of #430 reviewed at e0cf28109b70e9cff10d36ea8a6a2f5a2d9182bb compares the additional-variable array by reference. An inline array combined with a callback that updates React state causes repeated observer restarts and initial notifications while CSS remains unchanged.
See the confirmed reproduction and minimal fix.
Compare the variable list by contents, treating an omitted list as empty; the existing lodash/isEqual dependency is sufficient for the minimal fix. Replacing the list with an equal array must not restart observation or emit another initial notification.
Acceptance criteria
- Unit tests cover initial custom values, subsequent changes, built-in mapping preservation, filtering, list replacement/clearing, and cleanup.
- A regression test covers an equal new array and a React consumer with inline
additionalCSSVariablesand anonChangecallback that stores the received records in state. Notifications settle after the initial read and resume only for actual value or subscription changes. - Browser coverage with the real observer verifies custom-variable updates and the initially-unset → defined transition without regressing v2's existing unset-value behavior.
- Port the custom-variable Storybook example to
apps/storybook/src/stories/plugins/cssVariables, using v2 package imports. Changing the variable updates the existing group's color without replacing its component. - Update the package documentation and verify that the public prop is available through the published package declarations.
- The affected package's type checks, lint, tests, and relevant package-contract checks pass.
- 主要语言
- TypeScript
- 星标
- 145
- 派生
- 12
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 43
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
gravity-ui/graph 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
gravity-ui/graph#457 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 77/100
gravity-ui/graph#455 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
gravity-ui/graph#456 ·
维护者通常 1 天内回复
-
proposal
难度 5/5 一周以上 新手友好度 25/100
gravity-ui/graph#416 ·
维护者通常 1 天内回复
-
Graph root is not a containing block for absolutely positioned layers可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
gravity-ui/graph#414 ·
维护者通常 1 天内回复
相似的 Issue
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:ux-friction issue-rating: 🦞 diamond lobster no-stale P2
难度 2/5 1-3 小时 新手友好度 68/100
openclaw/openclaw#199885 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
-
feature needs-triage
难度 2/5 1-3 小时 新手友好度 78/100
BoardGamesEmpire/board-games-empire-backend#1306 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100
sequant-io/sequant#1689 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 80/100