Skip to content

Modernize UI: light/dark themes, glassmorphism, and fluid animations - #3

Open
Jimmy-xuzimo wants to merge 1 commit into
Star-Moon10:mainfrom
Jimmy-xuzimo:feature/modern-ui-refresh
Open

Modernize UI: light/dark themes, glassmorphism, and fluid animations#3
Jimmy-xuzimo wants to merge 1 commit into
Star-Moon10:mainfrom
Jimmy-xuzimo:feature/modern-ui-refresh

Conversation

@Jimmy-xuzimo

Copy link
Copy Markdown

功能描述

在保留现有三栏布局(Sidebar + Workspace + AI Assistant)、DOM 结构与 class 命名的前提下,为学生档案管理系统带来一套现代化 UI 升级:默认浅色模式 + 深色/浅色一键切换、全局毛玻璃效果、流畅的微交互动画,并在现有青绿(Teal)政务风格基础上优化配色层次,保持「安全可信」的产品气质。

实现细节

新增文件

  • app/static/theme.js:主题切换与侧边栏折叠控制器。在 <head> 中提前加载(首帧渲染前应用 data-theme),偏好持久化到 localStorage,未手动选择时跟随系统 prefers-color-scheme;切换时挂载临时 .theme-transition 类实现 0.3s 全页面平滑过渡。严格遵循现有 CSP(script-src 'self'),无内联脚本。

修改文件

  • app/templates/index.html<html> 增加 data-theme="light";顶部导航栏右上角新增 #theme-toggle 深浅色切换按钮(月/日图标随主题切换);侧边栏新增 #sidebar-toggle 折叠按钮(展开/收起图标联动)。原有结构与 class 命名完全兼容。
  • app/templates/login.html:同步接入 data-themetheme.js,登录页支持主题切换。
  • app/static/app.css:全量重构(703 删 / 879 增)——
    • 主题系统:root 浅色(纯白/浅灰画布 #f5f8f7 + 青绿强调色)与 [data-theme="dark"] 深色(深蓝灰 #0f172a + 降饱和青绿 #3aa396 + 高对比文字),配套 color-scheme 声明。
    • 毛玻璃:顶栏 blur(16px) saturate(1.5)、侧边栏 blur(18px)、弹窗/卡片头部磨砂层,均含 -webkit-backdrop-filter 前缀与半透明底色降级。
    • 动画:视图切换淡入上浮(opacity 0→1 + translateY 8px→0, 0.25s ease-out);卡片悬停上浮 + 阴影扩散(-2px, 0.2s);表格行悬停背景渐变 + 左侧指示条滑入;按钮按压缩放(scale 0.97, 0.1s);侧边栏折叠宽度动画(0.3s cubic-bezier(0.4, 0, 0.2, 1));弹窗遮罩淡入 + 内容底部弹性滑入。
    • 视觉层次:subtle 渐变背景替代纯色、卡片 1px 细边框 + 微弱阴影、统计数字大字号 + 渐变文字。
    • 响应式:≤800px 侧边栏转抽屉式(含 backdrop)、移动端汉堡菜单、多断点网格降级。

测试结果

后端回归

  • pytest tests/92/92 通过(数据导入导出全量用例)

UI 功能测试(Playwright,桌面 1440×900)

测试项 结果
登录 → 主页加载
主题切换按钮可见、light↔dark 切换、刷新后持久化
深色画布 rgb(15,23,42) 生效
侧边栏折叠/展开(248px ↔ 76px 宽度动画)
视图切换(概览 → 学生档案,display/active 状态正确)
顶栏/侧边栏 backdrop-filter 毛玻璃生效
Console 无 JS/CSS 报错

响应式测试

  • 移动端 375×812:汉堡菜单 + 抽屉侧边栏开合正常、主题切换正常、无报错 ✅
  • 平板 768×1024:无横向溢出(scrollWidth = 768)✅

跨浏览器兼容性(Playwright)

  • Chromium:7/7 ✅
  • Firefox:7/7 ✅
  • WebKit:7/7 ✅(Playwright 截图机制自身注入的 <style>body{}</style> 会触发 CSP 拦截告警,与本次改动无关,已甄别排除)

测试环境:本地启动 uvicorn app.main:app,管理员账号全流程真实登录验证。

兼容性说明

  • 未改动任何后端代码与 app.js 业务逻辑,仅新增 theme.js 与静态资源版本参数(?v=20260902-1
  • backdrop-filter 提供 -webkit- 前缀;不支持该属性的浏览器自动降级为半透明底色

- Add theme toggle (top bar) with 0.3s smooth full-page transition,
  persisted in localStorage and following OS preference by default
- Add sidebar collapse toggle with 0.3s cubic-bezier width animation
- Apply backdrop-blur frosted glass to topbar, sidebar, and dialog headers
- Refresh color system: light canvas #f5f8f7 with teal accent; dark
  navy #0f172a with desaturated teal and high-contrast text
- Add view-enter fade/rise, card hover lift + shadow, table row hover
  indicator, button press scale, and modal spring-up animations
- Use gradient metric text and 1px borders + soft shadows for depth
- Preserve existing DOM structure and class names (new theme.js only)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant