feat(Switch): 支持圆角和线性形态 - #2640
Open
xy200303 wants to merge 3 commits into
Open
Conversation
8 tasks
Contributor
Author
|
已按要求补充组件侧实现,React 侧 实现要点:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤔 这个 PR 的性质是?
🔗 相关 Issue
Closes #2563
💡 需求背景和解决方案
为 Web Switch 的
shapeAPI 提供公共样式实现:circle保持现有默认胶囊样式不变;round采用圆角矩形轨道和 handle;line使用独立细轨道,保持 handle 的三种尺寸、hover、选中、loading、disabled 和按压状态。样式复用现有 Switch 的语义色和动画 token,不改变既有组件结构、焦点或键盘交互。
line形态下 label 由各框架的shapeAPI 实现负责不渲染;文档中已明确说明。🆚 方案对比
shape改变表单布局或缩小可点击区域l/default/s调整高度line的 label 由框架 API 层直接不渲染本方案的重点不是额外引入一套独立控件尺寸,而是在保持现有 Switch 布局和交互边界的前提下完成外观分层,降低各框架接入和后续主题定制的成本。
与现有方案的具体对比
已对照以下候选 PR 的实现 diff:#2604、#2606、#2611。
line单独定义固定宽度(39/32/26px)和一组 handle 尺寸l/default/s单独设置厚度shape类名契约,并针对三种 Web 尺寸分别设置轨道厚度和 handle 尺寸;移动端等待对应 API 契约明确后独立接入共同部分均采用现有 Switch 的 checked、unchecked、loading、disabled 语义色。本方案的重点是保持既有布局边界和按压反馈,同时让下游主题定制继续复用现有尺寸 token。
📝 更新日志
feat(Switch): 支持 round 和 line 两种 shape 外观
本条 PR 不需要纳入 Changelog
☑️ 请求合并前的自查清单
验证
pnpm run test(28 个测试文件,548 个测试通过)pnpm run typecheckpnpm exec stylelint style/web/components/switch/_index.less style/web/components/switch/_var.less --allow-empty-inputpnpm exec prettier --check docs/web/api/switch.md docs/web/api/switch.en-US.mdpnpm run lint:仓库基线有 738 个既有文件不符合当前 Prettier 规则;新增文档与 Switch 样式的针对性检查均通过。