Skip to content

Commit

Permalink
Hook in to RTD theme to set react theme
Browse files Browse the repository at this point in the history
  • Loading branch information
pjrobertson committed Mar 3, 2025
1 parent 9845804 commit a88a37d
Show file tree
Hide file tree
Showing 7 changed files with 48,378 additions and 332 deletions.
48,630 changes: 48,333 additions & 297 deletions docs/source/installation/settings.html

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions scripts/settings/index.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!-- <!doctype html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1, width=device-width" />
<!-- Fonts to support Material Design -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
Expand All @@ -11,13 +12,8 @@
/>
<title>Auto Archiver Settings</title>
</head>
<body> -->

<!-- No need for html/head markup, this page is designed to be included in a RTD page.
See `settings_page.md` for where this is included. -->

<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>

<!-- </body>
</html> -->
</body>
</html>
2 changes: 1 addition & 1 deletion scripts/settings/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ function ModuleTypes({ stepType, setEnabledModules, enabledModules, configValues
{stepType}
</Typography>
<Typography variant="body1" >
Select the {stepType} you wish to enable. Drag to re-order.
Select the {stepType} you wish to enable. Drag to.
Learn more about {stepType} <a href={`https://auto-archiver.readthedocs.io/en/latest/modules/${stepType.slice(0,-1)}.html`} target="_blank">here</a>.
</Typography>
</Box>
Expand Down
1 change: 1 addition & 0 deletions scripts/settings/src/StepCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const StepCard = ({


const style = {
...Card.style,
transform: CSS.Transform.toString(transform),
transition,
zIndex: isDragging ? "100" : "auto",
Expand Down
39 changes: 34 additions & 5 deletions scripts/settings/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,43 @@ import * as React from 'react';
import * as ReactDOM from 'react-dom/client';
import { ThemeProvider } from '@mui/material/styles';
import { CssBaseline } from '@mui/material';
import theme from './theme';
import App from './App';
import { createTheme } from '@mui/material/styles';
import { red } from '@mui/material/colors';
import { useState, useEffect } from 'react';

function RootApp() {
const [mode, setMode] = useState('light');

useEffect(() => {
setMode(window.localStorage.getItem('theme') || 'light');
}, []);

var observer = new MutationObserver(function(mutations) {
setMode(window.localStorage.getItem('theme') || 'light');

})
observer.observe(document.documentElement, {attributes: true, attributeFilter: ['data-theme']});

// A custom theme for this app
const theme = createTheme({
palette: {
mode: mode == 'light' ? 'light' : 'dark',
},
cssVariables: true
});

return (
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>
);
}

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<ThemeProvider theme={theme}>
<CssBaseline />
<App />
</ThemeProvider>
<RootApp />
</React.StrictMode>,
);

20 changes: 0 additions & 20 deletions scripts/settings/src/theme.tsx

This file was deleted.

4 changes: 4 additions & 0 deletions scripts/settings/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ import { viteSingleFile } from "vite-plugin-singlefile"
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), viteSingleFile()],
build: {
minify: false,
sourcemap: true,
}
});

0 comments on commit a88a37d

Please sign in to comment.