feat(home): add projects-only view from sidebar
This commit is contained in:
parent
aa2554e4ed
commit
25f962415a
@ -324,6 +324,7 @@ export function LovartHome({
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
const [activeCategory, setActiveCategory] = useState("全部");
|
||||
const [showAllProjects, setShowAllProjects] = useState(false);
|
||||
const [isProjectsOnlyView, setIsProjectsOnlyView] = useState(false);
|
||||
const [upgradeDialogOpen, setUpgradeDialogOpen] = useState(false);
|
||||
const [accountCenterOpen, setAccountCenterOpen] = useState(false);
|
||||
const [accountCenterTab, setAccountCenterTab] = useState<"account" | "usage" | "billing">(
|
||||
@ -588,10 +589,12 @@ export function LovartHome({
|
||||
);
|
||||
}, [loadedFeaturedImages, activeCategory]);
|
||||
|
||||
const shouldShowAllProjects = isProjectsOnlyView || showAllProjects;
|
||||
|
||||
const recentProjects = useMemo(() => {
|
||||
const projects = canvasData?.data || [];
|
||||
return showAllProjects ? projects : projects.slice(0, 4);
|
||||
}, [canvasData?.data, showAllProjects]);
|
||||
return shouldShowAllProjects ? projects : projects.slice(0, 4);
|
||||
}, [canvasData?.data, shouldShowAllProjects]);
|
||||
|
||||
const hasMoreProjects = useMemo(() => {
|
||||
return (canvasData?.data || []).length > 4;
|
||||
@ -1098,6 +1101,7 @@ export function LovartHome({
|
||||
openLoginDialog();
|
||||
return;
|
||||
}
|
||||
setIsProjectsOnlyView(true);
|
||||
setShowAllProjects(true);
|
||||
projectSectionRef.current?.scrollIntoView({ behavior: "smooth", block: "start" });
|
||||
};
|
||||
@ -1370,7 +1374,10 @@ export function LovartHome({
|
||||
<button
|
||||
type="button"
|
||||
className="flex h-10 w-10 items-center justify-center rounded-full bg-black/5"
|
||||
onClick={() => window.scrollTo({ top: 0, behavior: "smooth" })}
|
||||
onClick={() => {
|
||||
setIsProjectsOnlyView(false);
|
||||
window.scrollTo({ top: 0, behavior: "smooth" });
|
||||
}}
|
||||
>
|
||||
<Home className="h-[18px] w-[18px]" />
|
||||
</button>
|
||||
@ -1562,7 +1569,8 @@ export function LovartHome({
|
||||
</aside>
|
||||
|
||||
<main className="mx-auto max-w-[1240px] px-6 pb-20 pt-[84px]">
|
||||
<section className="mt-8 text-center">
|
||||
{!isProjectsOnlyView && (
|
||||
<section className="mt-8 text-center">
|
||||
{isMembershipEnabled ? (
|
||||
<button
|
||||
type="button"
|
||||
@ -1733,12 +1741,18 @@ export function LovartHome({
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<section ref={projectSectionRef} className="mt-20">
|
||||
<section
|
||||
ref={projectSectionRef}
|
||||
className={isProjectsOnlyView ? "mt-6" : "mt-20"}
|
||||
>
|
||||
<div className="mb-4 flex items-center justify-between">
|
||||
<h2 className="text-[18px] font-semibold tracking-tight">最近项目</h2>
|
||||
{hasMoreProjects ? (
|
||||
<h2 className="text-[18px] font-semibold tracking-tight">
|
||||
{isProjectsOnlyView ? "所有项目" : "最近项目"}
|
||||
</h2>
|
||||
{!isProjectsOnlyView && hasMoreProjects ? (
|
||||
<button
|
||||
type="button"
|
||||
className="inline-flex items-center gap-1 text-[13px] text-black/45 hover:text-black"
|
||||
@ -1795,7 +1809,8 @@ export function LovartHome({
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="mt-16">
|
||||
{!isProjectsOnlyView && (
|
||||
<section className="mt-16">
|
||||
<h2 className="text-[18px] font-semibold tracking-tight">灵感发现</h2>
|
||||
|
||||
<div className="mt-3 flex flex-wrap gap-1.5">
|
||||
@ -1865,7 +1880,8 @@ export function LovartHome({
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
)}
|
||||
</main>
|
||||
|
||||
<button
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user