fix(support-chat): simplify legacy h5 styles

This commit is contained in:
t
2026-08-30 19:37:08 +08:00
parent a27c44ee60
commit c39094156c
3 changed files with 46 additions and 34 deletions
+3 -3
View File
@@ -59,9 +59,9 @@ svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round
.close-button:hover { color: #e5484d; border-color: rgba(229,72,77,.15); background: rgba(229,72,77,.075); box-shadow: 0 7px 18px rgba(229,72,77,.09); }
.close-button:hover svg { transform: scale(.88); }
.chat-content { position: relative; min-height: 0; flex: 1; display: grid; grid-template-rows: minmax(0, 1fr) auto; overflow: hidden; background: linear-gradient(180deg, #f8faff 0%, #f5f8fd 55%, #f2f6fb 100%); }
.chat-content { position: relative; min-height: 0; flex: 1; display: flex; flex-direction: column; overflow: hidden; background: linear-gradient(180deg, #f8faff 0%, #f5f8fd 55%, #f2f6fb 100%); }
.chat-content::before { content: ""; position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; background: rgba(36, 117, 252, .025); }
.message-scroller { position: relative; z-index: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; padding: 20px 18px 24px; overscroll-behavior: contain; scroll-behavior: smooth; background: transparent; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.message-scroller { position: relative; z-index: 1; min-height: 0; flex: 1; overflow-x: hidden; overflow-y: auto; padding: 20px 18px 24px; background: transparent; }
.message-scroller::-webkit-scrollbar { width: 10px; }
.message-scroller::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: var(--border); background-clip: padding-box; }
.load-more { height: 30px; margin: 0 auto 14px; padding: 0 13px; display: block; border: 1px solid #e3eaf3; border-radius: 999px; color: var(--muted-foreground); background: #fff; box-shadow: 0 6px 18px rgba(15,23,42,.06); font-size: 12px; cursor: pointer; }
@@ -163,7 +163,7 @@ svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round
.dialog-card h2 { margin: 0; font-size: 18px; line-height: 26px; font-weight: 600; }
.dialog-card header p { margin: 6px 0 0; color: var(--muted-foreground); font-size: 13px; line-height: 20px; }
.dialog-close { position: absolute; top: 12px; right: 12px; }
.quick-list { max-height: 60vh; margin-top: 16px; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; overflow-y: auto; }
.quick-list { max-height: 60vh; margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; overflow-y: auto; }
.quick-item { height: 44px; min-width: 0; padding: 0 12px; overflow: hidden; border: 1px solid var(--border); border-radius: 12px; color: var(--foreground); background: var(--background); font-size: 14px; font-weight: 500; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.quick-item:hover { color: var(--theme); border-color: rgba(var(--theme-rgb), .4); background: rgba(var(--theme-rgb), .05); }
.quick-empty { padding: 28px 0 8px; color: var(--muted-foreground); text-align: center; font-size: 13px; }
+17 -17
View File
@@ -1,15 +1,15 @@
:root { color-scheme: light dark; font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif; color: #101828; background: #f5f7fc; font-synthesis: none; }
* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { min-height: 100vh; min-height: 100svh; overflow-x: hidden; background: #f5f7fc; }
body { min-height: 100vh; overflow-x: hidden; background: #f5f7fc; }
button { font: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.demo-app { position: relative; min-height: 100vh; min-height: 100svh; overflow: hidden; background: radial-gradient(circle at 8% 8%, rgba(37,99,235,.13), transparent 30%), radial-gradient(circle at 92% 14%, rgba(109,93,252,.12), transparent 28%), #f5f7fc; }
.demo-header { position: relative; z-index: 2; border-bottom: 1px solid rgba(255,255,255,.84); background: rgba(255,255,255,.76); box-shadow: 0 6px 24px rgba(15,23,42,.035); backdrop-filter: blur(20px) saturate(1.2); }
.demo-header__inner { width: min(1120px, calc(100% - 40px)); min-height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.demo-app { position: relative; min-height: 100vh; overflow: hidden; background: #f5f7fc; }
.demo-header { position: relative; z-index: 2; border-bottom: 1px solid #e8edf5; background: #fff; box-shadow: 0 6px 24px rgba(15,23,42,.035); }
.demo-header__inner { width: calc(100% - 40px); max-width: 1120px; min-height: 72px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.demo-brand { display: flex; align-items: center; gap: 12px; }
.demo-brand__mark { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(145deg,#4f7df3,#6d5dfc); box-shadow: 0 10px 24px rgba(61,105,235,.24); }
.demo-brand__mark { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 14px; color: #fff; background: #2475fc; box-shadow: 0 10px 24px rgba(61,105,235,.24); }
.demo-brand__mark svg { width: 20px; height: 20px; }
.demo-brand > span:last-child { display: flex; flex-direction: column; }
.demo-brand strong { font-size: 15px; line-height: 21px; }
@@ -18,37 +18,37 @@ svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round
.demo-status i { width: 8px; height: 8px; border-radius: 50%; background: #24b47e; box-shadow: 0 0 0 4px rgba(36,180,126,.12); }
.demo-status.error { color: #b42318; border-color: #fecaca; background: #fff1f2; }
.demo-status.error i { background: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,.12); }
.demo-hero { position: relative; z-index: 1; width: min(1120px, calc(100% - 40px)); min-height: calc(100svh - 72px); margin: 0 auto; padding: 76px 0 92px; display: grid; grid-template-columns: minmax(0,1.05fr) minmax(340px,.75fr); align-items: center; gap: 72px; }
.demo-eyebrow { width: fit-content; display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border: 1px solid rgba(37,99,235,.18); border-radius: 999px; color: #2463d4; background: rgba(239,246,255,.82); box-shadow: 0 3px 10px rgba(37,99,235,.06); font-size: 12px; font-weight: 600; }
.demo-hero { position: relative; z-index: 1; width: calc(100% - 40px); max-width: 1120px; min-height: calc(100vh - 72px); margin: 0 auto; padding: 76px 0 92px; display: grid; grid-template-columns: 1fr 380px; align-items: center; gap: 72px; }
.demo-eyebrow { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border: 1px solid rgba(37,99,235,.18); border-radius: 999px; color: #2463d4; background: #eff6ff; box-shadow: 0 3px 10px rgba(37,99,235,.06); font-size: 12px; font-weight: 600; }
.demo-eyebrow svg { width: 14px; height: 14px; }
.demo-hero h1 { max-width: 650px; margin: 22px 0 0; font-size: clamp(38px, 4.2vw, 58px); font-weight: 700; line-height: 1.13; letter-spacing: -.045em; }
.demo-hero h1 { max-width: 650px; margin: 22px 0 0; font-size: 52px; font-weight: 700; line-height: 1.13; letter-spacing: -.045em; }
.demo-hero__copy > p { max-width: 640px; margin: 22px 0 0; color: #5e6b80; font-size: 17px; line-height: 1.75; }
.demo-hero code { padding: 2px 5px; border-radius: 6px; color: #335fbd; background: rgba(37,99,235,.07); font-size: .88em; }
.identity-grid { margin-top: 28px; display: flex; flex-wrap: wrap; gap: 10px; }
.identity-grid > div { min-width: 150px; max-width: 260px; padding: 11px 14px; border: 1px solid rgba(255,255,255,.9); border-radius: 13px; background: rgba(255,255,255,.76); box-shadow: 0 5px 18px rgba(15,23,42,.055); backdrop-filter: blur(12px); }
.identity-grid > div { min-width: 150px; max-width: 260px; padding: 11px 14px; border: 1px solid #e8edf5; border-radius: 13px; background: #fff; box-shadow: 0 5px 18px rgba(15,23,42,.055); }
.identity-grid span { display: block; color: #98a2b3; font-size: 9px; font-weight: 700; letter-spacing: .1em; }
.identity-grid strong { display: block; margin-top: 4px; overflow: hidden; color: #475467; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.action-hint { width: fit-content; max-width: 100%; margin-top: 28px; padding: 12px 15px; display: flex; align-items: center; gap: 11px; border: 1px solid rgba(255,255,255,.9); border-radius: 16px; color: #5e6b80; background: rgba(255,255,255,.82); box-shadow: 0 12px 34px rgba(15,23,42,.075); font-size: 13px; backdrop-filter: blur(16px); }
.action-hint > span { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: #2563eb; background: #eff6ff; }
.action-hint { max-width: 650px; margin-top: 28px; padding: 12px 15px; display: flex; align-items: center; gap: 11px; border: 1px solid #e8edf5; border-radius: 16px; color: #5e6b80; background: #fff; box-shadow: 0 12px 34px rgba(15,23,42,.075); font-size: 13px; }
.action-hint > span { width: 34px; height: 34px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; border-radius: 11px; color: #2563eb; background: #eff6ff; }
.action-hint svg { width: 17px; height: 17px; }
.feature-list { display: grid; gap: 16px; }
.feature-list article { padding: 21px; display: flex; gap: 16px; border: 1px solid rgba(255,255,255,.92); border-radius: 21px; background: rgba(255,255,255,.84); box-shadow: 0 16px 42px rgba(15,23,42,.075); backdrop-filter: blur(18px); }
.feature-list i { width: 40px; height: 40px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; }
.feature-list article { padding: 21px; display: flex; gap: 16px; border: 1px solid #e8edf5; border-radius: 21px; background: #fff; box-shadow: 0 16px 42px rgba(15,23,42,.075); }
.feature-list i { width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; border-radius: 12px; }
.feature-list i svg { width: 19px; height: 19px; }
.feature-list .blue { color: #2563eb; background: #eff6ff; }
.feature-list .violet { color: #7c3aed; background: #f5f3ff; }
.feature-list .green { color: #059669; background: #ecfdf5; }
.feature-list h2 { margin: 1px 0 0; font-size: 15px; line-height: 22px; }
.feature-list p { margin: 5px 0 0; color: #667085; font-size: 13px; line-height: 21px; }
.widget-launcher { position: fixed; z-index: 30; right: max(24px, env(safe-area-inset-right)); bottom: max(24px, env(safe-area-inset-bottom)); width: 64px; height: 64px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 50%; color: #fff; background: linear-gradient(145deg,#3974ec,#605cf5); box-shadow: 0 18px 42px rgba(37,99,235,.28); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.widget-launcher { position: fixed; z-index: 30; right: 24px; bottom: 24px; width: 64px; height: 64px; padding: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; border-radius: 50%; color: #fff; background: #2475fc; box-shadow: 0 18px 42px rgba(37,99,235,.28); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.widget-launcher:hover { transform: translateY(-2px); box-shadow: 0 22px 48px rgba(37,99,235,.34); }
.widget-launcher:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.widget-launcher svg { width: 23px; height: 23px; }
.widget-launcher span { font-size: 12px; font-weight: 650; }
.widget-frame-shell { position: fixed; z-index: 29; right: max(12px, env(safe-area-inset-right)); bottom: max(96px, calc(80px + env(safe-area-inset-bottom))); width: min(380px, calc(100vw - 24px)); height: min(720px, calc(100dvh - 112px)); overflow: hidden; border: 1px solid rgba(255,255,255,.72); border-radius: 20px; background: #fff; box-shadow: 0 28px 80px rgba(15,35,65,.26); transform-origin: right bottom; animation: frame-in .24s cubic-bezier(.22,1,.36,1); }
.widget-frame-shell { position: fixed; z-index: 29; right: 12px; bottom: 96px; width: calc(100vw - 24px); max-width: 380px; height: calc(100vh - 112px); max-height: 720px; overflow: hidden; border: 1px solid #e8edf5; border-radius: 20px; background: #fff; box-shadow: 0 28px 80px rgba(15,35,65,.26); transform-origin: right bottom; animation: frame-in .24s ease-out; }
.widget-frame-shell iframe { width: 100%; height: 100%; display: block; border: 0; background: #fff; }
@keyframes frame-in { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@media (max-width: 820px) { .demo-hero { padding-top: 48px; grid-template-columns: 1fr; gap: 42px; } .feature-list { grid-template-columns: repeat(3,minmax(0,1fr)); } .feature-list article { display: block; } .feature-list article > div { margin-top: 12px; } }
@media (max-width: 620px) { .demo-header__inner, .demo-hero { width: min(100% - 28px, 1120px); } .demo-status span { display: none; } .demo-status { width: 32px; height: 32px; padding: 0; justify-content: center; } .demo-status i { width: 9px; height: 9px; } .demo-hero { padding: 42px 0 110px; } .demo-hero h1 { font-size: 36px; } .demo-hero h1 br { display: none; } .demo-hero__copy > p { font-size: 15px; } .feature-list { grid-template-columns: 1fr; } .feature-list article { display: flex; } .feature-list article > div { margin-top: 0; } .widget-launcher { right: 16px; bottom: 16px; } .widget-frame-shell { right: 8px; bottom: 88px; width: calc(100vw - 16px); height: calc(100dvh - 104px); } }
@media (max-width: 820px) { .demo-hero { padding-top: 48px; grid-template-columns: 1fr; gap: 42px; } .feature-list { grid-template-columns: 1fr 1fr 1fr; } .feature-list article { display: block; } .feature-list article > div { margin-top: 12px; } }
@media (max-width: 620px) { .demo-header__inner, .demo-hero { width: calc(100% - 28px); } .demo-status span { display: none; } .demo-status { width: 32px; height: 32px; padding: 0; justify-content: center; } .demo-status i { width: 9px; height: 9px; } .demo-hero { padding: 42px 0 110px; } .demo-hero h1 { font-size: 36px; } .demo-hero h1 br { display: none; } .demo-hero__copy > p { font-size: 15px; } .feature-list { grid-template-columns: 1fr; } .feature-list article { display: flex; } .feature-list article > div { margin-top: 0; } .widget-launcher { right: 16px; bottom: 16px; } .widget-frame-shell { right: 8px; bottom: 88px; width: calc(100vw - 16px); height: calc(100vh - 104px); } }
@media (prefers-color-scheme: dark) { :root { color: #f8fafc; background: #0f1726; } body, .demo-app { background: radial-gradient(circle at 8% 8%,rgba(37,99,235,.16),transparent 30%),radial-gradient(circle at 92% 14%,rgba(109,93,252,.13),transparent 28%),#0f1726; } .demo-header { border-color: rgba(255,255,255,.07); background: rgba(15,23,38,.78); } .demo-brand small, .demo-hero__copy > p, .feature-list p, .action-hint { color: #9aa7ba; } .identity-grid > div, .action-hint, .feature-list article { border-color: rgba(255,255,255,.08); background: rgba(22,31,48,.78); } .identity-grid strong { color: #cbd5e1; } .widget-frame-shell { border-color: rgba(255,255,255,.1); background: #111827; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
+26 -14
View File
@@ -160,25 +160,37 @@ func TestSupportChatKeepsOlderMobileWebViewsCompatible(t *testing.T) {
}
}
forbiddenCSS := []string{
`color-mix(`,
`100svh`,
`100dvh`,
`inset:`,
`min(`,
`max(`,
`clamp(`,
`minmax(`,
`fit-content`,
`backdrop-filter`,
`place-items`,
`overflow-wrap: anywhere`,
}
for _, name := range []string{"assets/chat.css", "assets/demo.css"} {
stylesheet, readErr := assets.ReadFile(name)
if readErr != nil {
t.Fatalf("read support chat stylesheet %s: %v", name, readErr)
}
for _, forbidden := range forbiddenCSS {
if strings.Contains(string(stylesheet), forbidden) {
t.Fatalf("support chat stylesheet %s must not require newer mobile CSS %q", name, forbidden)
}
}
}
stylesheet, err := assets.ReadFile("assets/chat.css")
if err != nil {
t.Fatalf("read support chat stylesheet: %v", err)
}
css := string(stylesheet)
for _, forbidden := range []string{
`color-mix(`,
`height: 100dvh`,
`inset:`,
`width: min(`,
`top: max(`,
`backdrop-filter`,
`place-items`,
`overflow-wrap: anywhere`,
} {
if strings.Contains(css, forbidden) {
t.Fatalf("support chat stylesheet must not require newer mobile CSS %q", forbidden)
}
}
for _, marker := range []string{
`.message-row.mine .message-bubble { border-color: #2475fc;`,
`.send-button { width: 40px; height: 40px;`,