Skip to content

Commit

Permalink
feat: implement the pdf declaration generation for sacem
Browse files Browse the repository at this point in the history
  • Loading branch information
sneko committed Jan 13, 2025
1 parent 0ae7d53 commit d5ffa81
Show file tree
Hide file tree
Showing 14 changed files with 1,554 additions and 48 deletions.
35 changes: 35 additions & 0 deletions .storybook/document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { usePDF } from '@react-pdf/renderer';
import { StoryFn } from '@storybook/react';
import React from 'react';

export const commonDocumentsParameters = {
layout: 'fullscreen',
};

export function WithDocumentRenderer(Story: StoryFn) {
const [instance, updateInstance] = usePDF({
document: (
<>
<Story />
</>
),
});

if (instance.loading) {
return <div>Rendering the PDF...</div>;
} else if (instance.error) {
return <div>Something went wrong: {instance.error}</div>;
} else if (!instance.url) {
return <div>Initializing the renderer</div>;
}

return (
<iframe
title="PDF preview"
src={instance.url}
style={{
height: '100%',
}}
/>
);
}
4 changes: 4 additions & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ const config: StorybookConfig = {
from: path.dirname(require.resolve('@gouvfr/dsfr/dist/fonts/Marianne-Bold.woff2')),
to: path.resolve(__dirname, '../public/assets/fonts/'),
},
{
from: path.dirname(require.resolve('@fontsource/dancing-script/files/dancing-script-latin-400-normal.woff2')),
to: path.resolve(__dirname, '../public/assets/fonts/'),
},
{
from: require.resolve('@ad/src/assets/fonts/index.css'),
to: path.resolve(__dirname, '../public/assets/fonts/'),
Expand Down
4 changes: 4 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ const moduleExports = async () => {
from: path.dirname(require.resolve('@gouvfr/dsfr/dist/fonts/Marianne-Bold.woff2')),
to: path.resolve(__dirname, './public/assets/fonts/'),
},
{
from: path.dirname(require.resolve('@fontsource/dancing-script/files/dancing-script-latin-400-normal.woff2')),
to: path.resolve(__dirname, './public/assets/fonts/'),
},
{
from: require.resolve('./src/assets/fonts/index.css'),
to: path.resolve(__dirname, './public/assets/fonts/'),
Expand Down
Loading

0 comments on commit d5ffa81

Please sign in to comment.