0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-03 05:10:13 -05:00
penpot-exporter-figma-plugin/ui-src/components/ExporterProgress.tsx
Jordi Sala Morales 4b711b3526
Refactor context (#139)
* Refactor context

* fix

* fix
2024-06-04 18:02:59 +02:00

44 lines
1.1 KiB
TypeScript

import { LoadingIndicator } from '@create-figma-plugin/ui';
import { useFigmaContext } from '@ui/context';
import { Stack } from './Stack';
export const ExporterProgress = () => {
const { currentNode, totalPages, processedPages, downloading } = useFigmaContext();
const truncateText = (text: string, maxChars: number) => {
if (text.length <= maxChars) {
return text;
}
return text.slice(0, maxChars) + '...';
};
return (
<Stack space="small" horizontalAlign="center">
<LoadingIndicator />
<span style={{ textAlign: 'center' }}>
{!downloading ? (
<>
{processedPages} of {totalPages} pages exported 💪
{currentNode ? (
<>
<br />
Currently exporting layer
<br />
{'“' + truncateText(currentNode, 35) + '”'}
</>
) : undefined}
</>
) : (
<>
Generating Penpot file 🚀
<br />
Please wait, this process might take a while...
</>
)}
</span>
</Stack>
);
};