Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ deploy/aws-lambda/.serverless

website/cypress/videos
website/cypress/screenshots

.idea
1 change: 1 addition & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cypress/downloads/

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
5 changes: 4 additions & 1 deletion website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png" />
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#5bbad5" />
<link rel="stylesheet" href="/index.css" />
<title>Yopass: Share Secrets Securely</title>
</head>
<body style="margin: 0">
<noscript> You need to enable JavaScript to run this app. </noscript>
<div id="root"></div>
<div id="root">
<div class="placeholder"></div>
</div>
<script type="module" src="./src/index.tsx"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions website/public/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.placeholder {
position: fixed;
width: 100%;
height: 100%;

background-color: #fff;
color: #000;
}
@media (prefers-color-scheme: dark) {
.placeholder {
background-color: #222;
color: #fff;
}
}
5 changes: 3 additions & 2 deletions website/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Container } from '@mui/material';
import { Container, CssBaseline } from '@mui/material';
import { ThemeProvider, StyledEngineProvider } from '@mui/material/styles';

import { Header } from './shared/Header';
Expand All @@ -21,7 +21,8 @@ const App = () => {
const features = process.env.YOPASS_DISABLE_FEATURES_CARDS !== '1';
return (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<ThemeProvider theme={theme} defaultMode="system">
<CssBaseline />
<HashRouter>
<Header />
<Container maxWidth={'lg'}>
Expand Down
5 changes: 3 additions & 2 deletions website/src/createSecret/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import Result from '../displaySecret/Result';
import { randomString, uploadFile } from '../utils/utils';
import { useTranslation } from 'react-i18next';
import { useForm } from 'react-hook-form';
import { Grid, Typography } from '@mui/material';
import { Grid, Typography, useTheme } from '@mui/material';

const Upload = () => {
const maxSize = 1024 * 500;
const [error, setError] = useState('');
const { t } = useTranslation();
const { palette } = useTheme();
const [result, setResult] = useState({
password: '',
customPassword: false,
Expand Down Expand Up @@ -116,7 +117,7 @@ const Upload = () => {
</Grid>
<Grid container justifyContent="center">
<FontAwesomeIcon
color={isDragActive ? 'blue' : 'black'}
color={isDragActive ? palette.primary.main : palette.text.primary}
size="8x"
icon={faFileUpload}
/>
Expand Down
9 changes: 7 additions & 2 deletions website/src/displaySecret/DeleteSecret.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ const DeleteSecret = ({ url }: { readonly url: string }) => {

return (
<>
<Button color="secondary" onClick={handleConfirmOpen} disabled={deleted}>
<FontAwesomeIcon icon={faTrash} /> {t('delete.buttonDelete')}
<Button
color="secondary"
onClick={handleConfirmOpen}
disabled={deleted}
startIcon={<FontAwesomeIcon icon={faTrash} />}
>
{t('delete.buttonDelete')}
</Button>

<Dialog
Expand Down
50 changes: 29 additions & 21 deletions website/src/displaySecret/Secret.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faCopy } from '@fortawesome/free-solid-svg-icons';
import { Box, Button, Typography } from '@mui/material';
import { Box, Button, Paper, Typography, useTheme } from '@mui/material';
import { useCopyToClipboard } from 'react-use';
import { saveAs } from 'file-saver';
import { useEffect, useState } from 'react';
Expand All @@ -11,6 +11,7 @@ const RenderSecret = ({ secret }: { readonly secret: string }) => {
const { t } = useTranslation();
const [copy, copyToClipboard] = useCopyToClipboard();
const [showQr, setShowQr] = useState(false);
const { palette } = useTheme();

return (
<div>
Expand All @@ -19,27 +20,28 @@ const RenderSecret = ({ secret }: { readonly secret: string }) => {
<Button
color={copy.error ? 'secondary' : 'primary'}
onClick={() => copyToClipboard(secret)}
startIcon={<FontAwesomeIcon icon={faCopy} size="xs" />}
>
<FontAwesomeIcon icon={faCopy} /> {t('secret.buttonCopy')}
{t('secret.buttonCopy')}
</Button>
<Typography
id="pre"
data-test-id="preformatted-text-secret"
sx={{
backgroundColor: '#ecf0f1',
padding: '15px',
border: '1px solid #cccccc',
display: 'block',
fontSize: '1rem',
borderRadius: '4px',
wordWrap: 'break-word',
wordBreak: 'break-all',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace, monospace', // https://github.com/necolas/normalize.css/issues/519#issuecomment-197131966
}}
>
{secret}
</Typography>
<Paper variant="outlined">
<Typography
id="pre"
data-test-id="preformatted-text-secret"
sx={{
padding: '15px',
display: 'block',
fontSize: '1rem',
borderRadius: '4px',
wordWrap: 'break-word',
wordBreak: 'break-all',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace, monospace', // https://github.com/necolas/normalize.css/issues/519#issuecomment-197131966
}}
>
{secret}
</Typography>
</Paper>
<Button onClick={() => setShowQr(!showQr)}>
{showQr ? t('secret.hideQrCode') : t('secret.showQrCode')}
</Button>
Expand All @@ -51,7 +53,13 @@ const RenderSecret = ({ secret }: { readonly secret: string }) => {
margin: 5,
}}
>
<QRCode size={150} style={{ height: 'auto' }} value={secret} />
<QRCode
bgColor={palette.background.default}
fgColor={palette.text.primary}
size={150}
style={{ height: 'auto' }}
value={secret}
/>
</Box>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion website/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import '@fontsource/roboto/700.css';
const container = document.getElementById('root');
const root = createRoot(container!);
root.render(
<Suspense fallback={<div>Loading...</div>}>
<Suspense fallback={<div className="placeholder">Loading...</div>}>
<App />
</Suspense>,
);
3 changes: 2 additions & 1 deletion website/src/shared/Features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const Feature = (props: FeatureProps) => {
<Grid item={true} xs={12} md={4}>
<Paper
sx={{
backgroundColor: 'unset',
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
Expand All @@ -73,7 +74,7 @@ const Feature = (props: FeatureProps) => {
padding: '16px',
}}
>
<FontAwesomeIcon color={'black'} size={'4x'} icon={props.icon} />
<FontAwesomeIcon size={'4x'} icon={props.icon} />
<Typography sx={{ padding: '5px' }} variant="h5">
{props.title}
</Typography>
Expand Down
20 changes: 16 additions & 4 deletions website/src/shared/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { AppBar, Toolbar, Typography, Button, Box, Link } from '@mui/material';
import {
AppBar,
Toolbar,
Typography,
Button,
Box,
Link,
Stack,
} from '@mui/material';
import { useTranslation } from 'react-i18next';
import { useLocation } from 'react-router-dom';
import { ModeToggle } from './ModeToggle';

export const Header = () => {
const { t } = useTranslation();
Expand All @@ -10,7 +19,7 @@ export const Header = () => {
const home = base + '/#/';
const upload = base + '/#/upload';
return (
<AppBar position="static" color="transparent" sx={{ marginBottom: 4 }}>
<AppBar position="static" color="default" sx={{ marginBottom: 4 }}>
<Toolbar>
<Link href={home} color="inherit" underline="none">
<Typography variant="h6" component="div">
Expand All @@ -29,11 +38,14 @@ export const Header = () => {
/>
</Typography>
</Link>
<Box
<Stack
direction="row"
gap={2}
sx={{
marginLeft: 'auto',
}}
>
<ModeToggle />
<Button
component={Link}
href={isOnUploadPage ? home : upload}
Expand All @@ -42,7 +54,7 @@ export const Header = () => {
>
{isOnUploadPage ? t('header.buttonHome') : t('header.buttonUpload')}
</Button>
</Box>
</Stack>
</Toolbar>
</AppBar>
);
Expand Down
21 changes: 21 additions & 0 deletions website/src/shared/ModeToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { faMoon, faSun } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { IconButton, useTheme } from '@mui/material';
import { useColorScheme } from '@mui/material/styles';

export const ModeToggle = () => {
const { mode, systemMode, setMode } = useColorScheme();
const { palette } = useTheme();

const currentMode = (mode == 'system' ? systemMode : mode) ?? 'light';
const isDarkMode = currentMode == 'dark';
const nextMode = isDarkMode ? 'light' : 'dark';

const icon = isDarkMode ? faSun : faMoon;

return (
<IconButton onClick={() => setMode(nextMode)}>
<FontAwesomeIcon icon={icon} color={palette.primary.main} width="24px" />
</IconButton>
);
};
18 changes: 16 additions & 2 deletions website/src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,21 @@ import { createTheme } from '@mui/material/styles';
import { blueGrey } from '@mui/material/colors';

export const theme = createTheme({
palette: {
primary: blueGrey,
colorSchemes: {
dark: {
palette: {
background: {
default: '#222',
},
},
},
light: {
palette: {
primary: blueGrey,
background: {
paper: '#ecf0f1',
},
},
},
},
});
Loading