Skip to content

Commit

Permalink
Fix black background color when exporting pdf
Browse files Browse the repository at this point in the history
  • Loading branch information
JonBunator committed Nov 1, 2023
1 parent 8d332d0 commit dadb657
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ import {
createContext,
useContext,
useEffect,
useMemo,
useState,
} from 'react';
import parseMarkdown, { CodeType } from './CodeFileParser';
import FileStatus from '../FileStatus';
import { useSettings } from '../Settings/SettingsProvider';

const MarkdownParserContext = createContext<MarkdownParserProps | undefined>(
undefined
undefined,
);

interface MarkdownParserProps {
Expand All @@ -27,7 +28,7 @@ export type Props = {
export default function MarkdownParserProvider(props: Props) {
const [markdown, setMarkdown] = useState('');
const [markdownParsed, setMarkdownParsed] = useState<[CodeType, string][]>(
[]
[],
);
const [codeFiles, setCodeFiles] = useState<
Map<string, [string, FileStatus]>
Expand Down Expand Up @@ -55,7 +56,7 @@ export default function MarkdownParserProvider(props: Props) {
if (!codeFiles.has(codePath)) {
setCodeFiles(
(prev) =>
new Map(prev.set(codePath, ['', FileStatus.Loading]))
new Map(prev.set(codePath, ['', FileStatus.Loading])),
);
}
}
Expand All @@ -79,22 +80,25 @@ export default function MarkdownParserProvider(props: Props) {
prev.set(codePath, [
'',
FileStatus.PathNotFoundError,
])
)
]),
),
);
} else if (file[1]) {
setCodeFiles(
(prev) =>
new Map(
prev.set(codePath, ['', FileStatus.BinaryFileError])
)
prev.set(codePath, [
'',
FileStatus.BinaryFileError,
]),
),
);
} else {
setCodeFiles(
(prev) =>
new Map(
prev.set(codePath, [file[0], FileStatus.Success])
)
prev.set(codePath, [file[0], FileStatus.Success]),
),
);
}
}
Expand Down Expand Up @@ -177,10 +181,13 @@ export default function MarkdownParserProvider(props: Props) {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [markdown]);

const value = useMemo(
() => ({ markdown, markdownParsed, setMarkdown }),
[markdown, markdownParsed],
);

return (
<MarkdownParserContext.Provider
value={{ markdown, markdownParsed, setMarkdown }}
>
<MarkdownParserContext.Provider value={value}>
{children}
</MarkdownParserContext.Provider>
);
Expand Down
2 changes: 1 addition & 1 deletion src/src/renderer/components/Settings/SettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import StringProperty from './SettingsProperties/StringProperty';

const SettingsPagePanel = styled.div`
background-color: ${themeGet('colors.canvas.default')};
margin-bottom: 32px;
padding-bottom: 32px;
`;

export default function SettingsPage() {
Expand Down
5 changes: 4 additions & 1 deletion src/src/renderer/components/Theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,11 @@ export const editorThemeDark = createTheme({
});

export const GlobalStyle = createGlobalStyle`
html {
height: 100%;
}
body {
background-color: ${themeGet('colors.canvas.default')};
height: 100%;
}
Expand Down

0 comments on commit dadb657

Please sign in to comment.