feat: add creative welcome and external works square links
This commit is contained in:
1 parent
4199cadd1e
commit
f8a7880da3
18 files changed
+428
-41
No files matched your search
@@ -0,0 +1,8 @@
|
||||
import { CommunityLink } from './CommunityLink';
|
||||
|
||||
export function CommunityInvitation() {
|
||||
return <section className="community-invitation" aria-label="作品广场入口" data-testid="community-invitation">
|
||||
<div><h2>还没想到?去找找灵感吧</h2><p>作品广场里,有小伙伴们用麦洛做出的奇思妙想。</p></div>
|
||||
<CommunityLink />
|
||||
</section>;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useState } from 'react';
|
||||
import { ArrowUpRight, Compass } from 'lucide-react';
|
||||
import { openCommunity } from '@/lib/community';
|
||||
import './community.css';
|
||||
|
||||
export function CommunityLink({ variant = 'inline', collapsed = false }: {
|
||||
variant?: 'inline' | 'sidebar'; collapsed?: boolean;
|
||||
}) {
|
||||
const [opening, setOpening] = useState(false);
|
||||
const [error, setError] = useState(false);
|
||||
return <div>
|
||||
<button type="button" className="community-link" data-variant={variant} data-collapsed={collapsed}
|
||||
aria-label={variant === 'sidebar' ? '作品广场' : '去作品广场逛逛'}
|
||||
title="在浏览器打开作品广场" disabled={opening}
|
||||
onClick={() => {
|
||||
setOpening(true); setError(false);
|
||||
void openCommunity().catch(() => setError(true)).finally(() => setOpening(false));
|
||||
}}>
|
||||
<Compass aria-hidden="true" />
|
||||
{!collapsed && <><span>{variant === 'sidebar' ? '作品广场' : '去作品广场逛逛'}</span><ArrowUpRight className="community-link-arrow" aria-hidden="true" /></>}
|
||||
</button>
|
||||
{error && <span className="community-link-error" role="alert">没能打开作品广场,请再点一次试试。</span>}
|
||||
</div>;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
.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"] { overflow-y: auto; padding: clamp(24px, 4vh, 48px) 24px 28px; background: radial-gradient(ellipse at 45% 18%, #fff8e8 0%, #fffdf8 28%, #fff 67%); }
|
||||
.coding-chat-body[data-welcome="true"] .classroom-chat-view { flex: 0 0 auto; }
|
||||
.coding-chat-body[data-welcome="true"] .classroom-composer-view { width: 100%; max-width: 740px; margin: 0 auto; }
|
||||
.coding-chat-body[data-welcome="true"] [data-testid="coding-message-composer"] { width: 100%; padding: 0 0 28px; }
|
||||
.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; width: 100%; max-width: 740px; margin: 0 auto; padding: 0 12px 24px; 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; }
|
||||
.coding-start-mark > svg:last-child { width: 12px; height: 12px; left: -23px; top: 39px; color: #83a496; }
|
||||
.coding-start-eyebrow { margin: 18px 0 7px; color: #7a7769; font-size: 12px; letter-spacing: .08em; }
|
||||
.coding-start-heading h1 { color: #304968; font-size: clamp(24px, 2.5vw, 34px); line-height: 1.45; font-weight: 650; letter-spacing: -.04em; }
|
||||
.coding-start-heading h1 span { position: relative; white-space: nowrap; background: linear-gradient(transparent 73%, #ffe6a6 73%, #ffe6a6 94%, transparent 94%); }
|
||||
.coding-start-caption { margin-top: 10px; color: #718096; font-size: 13px; line-height: 1.8; }
|
||||
.community-invitation { display: flex; align-items: center; justify-content: space-between; gap: 18px; width: 100%; max-width: 740px; margin: 5px auto 0; padding: 21px 23px; border: 1px dashed #e4d9bc; border-radius: 18px; background: #fffaf0; color: #304968; }
|
||||
.community-invitation h2 { margin-bottom: 5px; font-size: 15px; font-weight: 600; }
|
||||
.community-invitation p { color: #7c806e; font-size: 12px; line-height: 1.7; }
|
||||
.community-link { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 13px; border: 1px solid #dce5d0; border-radius: 12px; background: #f0f5e8; color: #526b46; font-size: 13px; cursor: pointer; white-space: nowrap; }
|
||||
.community-link:hover:not(:disabled) { background: #e5eed9; border-color: #b7c6a4; }
|
||||
.community-link:disabled { opacity: .6; cursor: wait; }
|
||||
.community-link:focus-visible { outline: 2px solid #547ab0; outline-offset: 3px; }
|
||||
.community-link svg { width: 17px; height: 17px; flex-shrink: 0; }
|
||||
.community-link .community-link-arrow { width: 14px; height: 14px; }
|
||||
.community-link[data-variant="sidebar"] { justify-content: flex-start; width: 100%; margin-top: 12px; border-color: transparent; background: transparent; text-align: left; }
|
||||
.community-link[data-variant="sidebar"]:hover { background: #e8f0e7; }
|
||||
.community-link[data-collapsed="true"] { justify-content: center; padding-inline: 0; }
|
||||
.community-link-error { display: block; margin-top: 6px; color: #965a45; font-size: 12px; line-height: 1.6; }
|
||||
@keyframes community-hello { 0% { transform: rotate(-15deg) translateY(5px); opacity: 0; } 70% { transform: rotate(3deg); opacity: 1; } 100% { transform: rotate(-7deg); } }
|
||||
@media (max-width: 600px) {
|
||||
.coding-chat-body[data-welcome="true"] { padding: 24px 16px; }
|
||||
.coding-start-caption { max-width: 230px; margin: 9px auto 0; }
|
||||
.community-invitation { flex-direction: column; align-items: flex-start; gap: 13px; padding: 19px; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) { .coding-start-mark { animation: none; } }
|
||||
@@ -53,6 +53,7 @@ import { useProviderStore } from '@/stores/providers';
|
||||
import type { CodingProjectSummary } from '@/types/coding-project';
|
||||
import { useProjectConfigStore } from '@/stores/project-config';
|
||||
import { toast } from 'sonner';
|
||||
import { CommunityLink } from '@/components/community/CommunityLink';
|
||||
|
||||
type OpenDialogResult = {
|
||||
canceled: boolean;
|
||||
@@ -435,6 +436,7 @@ export function Sidebar({
|
||||
<Plus className="h-4 w-4 shrink-0 text-brand" />
|
||||
{!sidebarCollapsed && '新建项目'}
|
||||
</button>
|
||||
<CommunityLink variant="sidebar" collapsed={sidebarCollapsed} />
|
||||
<div className="classroom-projects mt-3">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
Reference in new issue
Block a user