mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-12-03 20:04:28 +01:00
# Description of Changes <!-- Please provide a summary of the changes, including: - What was changed - Why the change was made - Any challenges encountered Closes #(issue_number) --> --- ## Checklist ### General - [ ] I have read the [Contribution Guidelines](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/CONTRIBUTING.md) - [ ] I have read the [Stirling-PDF Developer Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md) (if applicable) - [ ] I have read the [How to add new languages to Stirling-PDF](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md) (if applicable) - [ ] I have performed a self-review of my own code - [ ] My changes generate no new warnings ### Documentation - [ ] I have updated relevant docs on [Stirling-PDF's doc repo](https://github.com/Stirling-Tools/Stirling-Tools.github.io/blob/main/docs/) (if functionality has heavily changed) - [ ] I have read the section [Add New Translation Tags](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/HowToAddNewLanguage.md#add-new-translation-tags) (for new translation tags only) ### UI Changes (if applicable) - [ ] Screenshots or videos demonstrating the UI changes are attached (e.g., as comments or direct attachments in the PR) ### Testing (if applicable) - [ ] I have tested my changes locally. Refer to the [Testing Guide](https://github.com/Stirling-Tools/Stirling-PDF/blob/main/devGuide/DeveloperGuide.md#6-testing) for more details.
80 lines
2.7 KiB
TypeScript
80 lines
2.7 KiB
TypeScript
import React, { useEffect } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useFileContext } from "../contexts/FileContext";
|
|
import { FileSelectionProvider, useFileSelection } from "../contexts/FileSelectionContext";
|
|
import { ToolWorkflowProvider, useToolSelection } from "../contexts/ToolWorkflowContext";
|
|
import { Group } from "@mantine/core";
|
|
import { SidebarProvider, useSidebarContext } from "../contexts/SidebarContext";
|
|
import { useDocumentMeta } from "../hooks/useDocumentMeta";
|
|
import { getBaseUrl } from "../constants/app";
|
|
|
|
import ToolPanel from "../components/tools/ToolPanel";
|
|
import Workbench from "../components/layout/Workbench";
|
|
import QuickAccessBar from "../components/shared/QuickAccessBar";
|
|
import FileManager from "../components/FileManager";
|
|
|
|
|
|
function HomePageContent() {
|
|
const { t } = useTranslation();
|
|
const {
|
|
sidebarRefs,
|
|
} = useSidebarContext();
|
|
|
|
const { quickAccessRef } = sidebarRefs;
|
|
|
|
const { setMaxFiles, setIsToolMode, setSelectedFiles } = useFileSelection();
|
|
|
|
const { selectedTool } = useToolSelection();
|
|
|
|
const baseUrl = getBaseUrl();
|
|
|
|
// Update document meta when tool changes
|
|
useDocumentMeta({
|
|
title: selectedTool?.title ? `${selectedTool.title} - Stirling PDF` : 'Stirling PDF',
|
|
description: selectedTool?.description || t('app.description', 'The Free Adobe Acrobat alternative (10M+ Downloads)'),
|
|
ogTitle: selectedTool?.title ? `${selectedTool.title} - Stirling PDF` : 'Stirling PDF',
|
|
ogDescription: selectedTool?.description || t('app.description', 'The Free Adobe Acrobat alternative (10M+ Downloads)'),
|
|
ogImage: selectedTool ? `${baseUrl}/og_images/${selectedTool.id}.png` : `${baseUrl}/og_images/home.png`,
|
|
ogUrl: selectedTool ? `${baseUrl}${window.location.pathname}` : baseUrl
|
|
});
|
|
|
|
// Update file selection context when tool changes
|
|
useEffect(() => {
|
|
if (selectedTool) {
|
|
setMaxFiles(selectedTool.maxFiles);
|
|
setIsToolMode(true);
|
|
} else {
|
|
setMaxFiles(-1);
|
|
setIsToolMode(false);
|
|
setSelectedFiles([]);
|
|
}
|
|
}, [selectedTool, setMaxFiles, setIsToolMode, setSelectedFiles]);
|
|
|
|
return (
|
|
<Group
|
|
align="flex-start"
|
|
gap={0}
|
|
className="min-h-screen w-screen overflow-hidden flex-nowrap flex"
|
|
>
|
|
<QuickAccessBar
|
|
ref={quickAccessRef} />
|
|
<ToolPanel />
|
|
<Workbench />
|
|
<FileManager selectedTool={selectedTool as any /* FIX ME */} />
|
|
</Group>
|
|
);
|
|
}
|
|
|
|
export default function HomePage() {
|
|
const { setCurrentView } = useFileContext();
|
|
return (
|
|
<FileSelectionProvider>
|
|
<ToolWorkflowProvider onViewChange={setCurrentView as any /* FIX ME */}>
|
|
<SidebarProvider>
|
|
<HomePageContent />
|
|
</SidebarProvider>
|
|
</ToolWorkflowProvider>
|
|
</FileSelectionProvider>
|
|
);
|
|
}
|