feat(tab-bar): add liquid glass styles and capsule theme - #2650
Open
ChenXiaoming233 wants to merge 1 commit into
Open
feat(tab-bar): add liquid glass styles and capsule theme#2650ChenXiaoming233 wants to merge 1 commit into
ChenXiaoming233 wants to merge 1 commit into
Conversation
- add light and dark theme tokens for glass backgrounds, shadows, sheen, and selected states - implement layered glass materials with SVG backdrop-filter support and a readable CSS fallback - add the round capsule layout, shared selection indicator, and synchronized press feedback - preserve the existing tag layout and use translucent selected states with the glass effect - respect reduced-motion preferences and update the TabBar design and API documentation feat(tab-bar): 新增液态玻璃与共享胶囊样式 - 新增明暗主题下的玻璃背景、阴影、高光和选中态 Token - 实现分层玻璃材质、SVG backdrop-filter 接入及可读的 CSS 降级效果 - 新增圆角胶囊布局、共享选中指示器和同步按压反馈 - 保留原有 tag 布局,并为液态玻璃效果提供半透明选中态 - 适配 reduced-motion 偏好并更新 TabBar 设计与 API 文档 docs(tab-bar): complete the missing images - Complete the missing images
5 tasks
24 tasks
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
关联 PR
💡 需求背景和解决方案
为 Mobile TabBar 提供可跨组件框架复用的 Liquid Glass 公共样式,同时保持现有 TabBar 默认行为和 Classic tag 布局兼容。
通过 SVG Filter,实现逼近物理折射的 Glass 观感
通过 SVG Filter,我们可以构建一套接近真实玻璃成像过程的折射管线:
实现近似物理的 SVG 折射(
src/tab-bar/liquid-glass-map.ts):组件会根据 TabBar 的实际宽度、高度、圆角半径和设备像素比,动态生成两张纹理:
displacement map):根据超椭圆边界计算玻璃表面的法线与位移方向。中心区域偏移较弱,越靠近玻璃边缘偏移越明显,用于模拟光线穿过不同玻璃厚度时产生的折射。specular map):根据边缘距离和表面方向生成反射强度,模拟玻璃边缘及曲面朝向光源时出现的镜面高光。纹理使用 Canvas 编码为 PNG Data URL,再传入 SVG Filter,避免依赖外部图片资源。
新增 SVG Filter 渲染(
src/tab-bar/tab-bar.tsx):SVG Filter 内部由以下阶段组成:
feGaussianBlur对背景内容进行轻度模糊,减少折射后的像素锯齿。feImage加载位移纹理,并使用feDisplacementMap重新映射背景像素,产生随背景内容变化的动态折射。feColorMatrix调整折射区域的饱和度,补偿半透明材质造成的颜色损失。feComposite将高光纹理限制在有效玻璃区域,再通过多个feBlend将折射背景、边缘高光和表面反射组合起来。这样,我们得到的视觉效果并非固定的静态渐变或单纯的高斯模糊,而是会随着背景内容、容器尺寸和圆角形状变化,呈现具有空间关系的折射效果。
在不支持 SVG backdrop-filter、Canvas 等浏览器能力的环境下,材质会自动回退到”固态塑料“,使用分层 CSS 模糊效果确保基本的材质实现,并通过高光、阴影、渐变光晕等效果尽可能确保材质的质感品质。
平台兼容性 :
主要改动:
backdrop-filterfallback;组件端提供 SVG Filter 时自动关闭额外模糊层。round + capsule布局,提供共享移动胶囊、按压反馈等特性。round + tag布局,仅在 Glass 模式下切换材质和半透明选中背景。prefers-reduced-motion下关闭移动及缩放动画。液态玻璃 CSS 变量
(
style/mobile/components/tab-bar/_var.less)最终 API 实现与用法
效果图 与 Playground:
在此提供了 Classic 与 Capsule 两种主题分别处于 Normal / CSS Fallback / LiquidGlass 在深浅模式下的效果图;
同时,为能更直观地观察参数调整对 Glass 材质视觉效果带来的影响,此处提供两个 Playground 用于实践:
效果图:
Playground:
📝 更新日志
☑️ 本地验证
git diff --check☑️ 请求合并前的自查清单