fix: float teacher introductions above a centered welcome

This commit is contained in:
鲨鱼辣椒 committed 2026-09-29 16:29:19 +08:00
1 parent 521e1ee167
commit 5de8ea823d
6 files changed
+53 -28

No files matched your search

+3 -3
View File
@@ -1,12 +1,12 @@
.coding-chat-body { display: flex; flex: 1; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }
.coding-chat-body[hidden] { display: none; }
.coding-chat-body[data-welcome="true"] { padding: 0 24px 16px; background: radial-gradient(ellipse at 45% 18%, #fff8e8 0%, #fffdf8 28%, #fff 67%); }
.coding-chat-body[data-welcome="true"] .classroom-chat-view { flex: 1 1 0; overflow-y: auto; padding: clamp(24px, 4vh, 48px) 0 24px; }
.coding-chat-body[data-welcome="true"] { padding: 0 24px 16px; background: radial-gradient(ellipse at 50% 40%, #fff8e8 0%, #fffdf8 28%, #fff 67%); }
.coding-chat-body[data-welcome="true"] .classroom-chat-view { flex: 1 1 0; overflow-y: auto; padding: 24px 0; }
.coding-chat-body[data-welcome="true"] .classroom-composer-view { width: 100%; max-width: 740px; margin: 0 auto; padding-top: 16px; }
.coding-chat-body[data-welcome="true"] .classroom-composer-view > .community-invitation { margin: 0 auto 12px; }
.coding-chat-body[data-welcome="true"] [data-testid="coding-message-composer"] { width: 100%; padding: 0; }
.coding-chat-body[data-welcome="true"] .chat-composer-surface { background: #fff; border-color: #d7dfda; border-radius: 20px; box-shadow: 0 5px 0 #eaf0e8, 0 12px 32px #69774b08; }
.coding-start-heading { position: relative; flex-shrink: 0; width: 100%; max-width: 740px; margin: var(--teacher-top-inset, 0px) auto 0; padding: 0 12px 24px; text-align: center; }
.coding-start-heading { position: relative; flex-shrink: 0; width: 100%; max-width: 740px; margin: var(--teacher-top-inset, auto) auto auto; padding: 0 12px; text-align: center; }
.coding-start-mark { display: inline-grid; position: relative; place-items: center; width: 57px; height: 59px; border-radius: 18px; border: 1px solid #f2d6a7; background: #fff0d7; box-shadow: 0 4px 0 #eeddbd; transform: rotate(-7deg); animation: community-hello 650ms ease-out both; }
.coding-start-mark img { width: 35px; height: 35px; }
.coding-start-mark > svg { position: absolute; width: 17px; height: 17px; right: -24px; top: -2px; color: #c78b36; }
+8 -10
View File
@@ -8,19 +8,18 @@ export function CodingChatBody({ welcome, hidden, bubble, children }: {
useLayoutEffect(() => {
const body = ref.current;
const content = body?.querySelector<HTMLElement>('.classroom-chat-view');
if (!body || !content || hidden || !bubble) return;
if (!body || !content || !welcome || hidden || !bubble) return;
const update = () => {
const area = body.getBoundingClientRect();
const message = bubble.getBoundingClientRect();
const overlaps = message.height > 0 && message.right > area.left && message.left < area.right && message.bottom > area.top;
const rightInset = Math.ceil(area.right - message.left + 24);
const besideTeacher = overlaps && area.width >= 900 && area.width - rightInset - 24 >= 420;
// Reserve the same right rail for the welcome and bottom input. The teacher keeps its own fixed width.
body.style.paddingLeft = besideTeacher ? '24px' : '';
body.style.paddingRight = besideTeacher ? `${rightInset}px` : '';
// Put compact-screen clearance inside the scrolling heading, never around the fixed bottom input.
content.style.setProperty('--teacher-top-inset', welcome && overlaps && !besideTeacher
? `${Math.max(0, Math.ceil(message.bottom - content.getBoundingClientRect().top))}px` : '0px');
// The teacher floats over the page; it never narrows or shifts the main column.
// Only compact screens need scrollable space to reveal the welcome below the overlay.
if (overlaps && area.width < 900) {
content.style.setProperty('--teacher-top-inset', `${Math.max(0, Math.ceil(message.bottom - content.getBoundingClientRect().top + 24))}px`);
} else {
content.style.removeProperty('--teacher-top-inset');
}
};
update();
const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(update);
@@ -28,7 +27,6 @@ export function CodingChatBody({ welcome, hidden, bubble, children }: {
window.addEventListener('resize', update);
return () => {
observer?.disconnect(); window.removeEventListener('resize', update);
body.style.paddingLeft = ''; body.style.paddingRight = '';
content.style.removeProperty('--teacher-top-inset');
};
}, [welcome, hidden, bubble]);