ente/src/pages/_app.tsx

331 lines
8.1 KiB
TypeScript
Raw Normal View History

import React, { useCallback, useEffect, useState } from 'react';
import styled, { createGlobalStyle } from 'styled-components';
2020-09-09 21:09:51 +00:00
import Navbar from 'components/Navbar';
import constants from 'utils/strings/constants';
import { useRouter } from 'next/router';
2020-09-13 17:01:36 +00:00
import Container from 'components/Container';
2020-09-14 09:32:01 +00:00
import Head from 'next/head';
2020-09-20 15:18:35 +00:00
import 'bootstrap/dist/css/bootstrap.min.css';
import 'photoswipe/dist/photoswipe.css';
2021-03-12 06:58:27 +00:00
2021-03-08 12:44:07 +00:00
import { sentryInit } from '../utils/sentry';
import { useDropzone } from 'react-dropzone';
2021-04-18 13:01:40 +00:00
import EnteSpinner from 'components/EnteSpinner';
2020-09-09 21:09:51 +00:00
const GlobalStyles = createGlobalStyle`
2021-04-23 15:35:48 +00:00
/* ubuntu-regular - latin */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 400;
src: local(''),
url('/fonts/ubuntu-v15-latin-regular.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('/fonts/ubuntu-v15-latin-regular.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
/* ubuntu-700 - latin */
@font-face {
font-family: 'Ubuntu';
font-style: normal;
font-weight: 700;
src: local(''),
url('/fonts/ubuntu-v15-latin-700.woff2') format('woff2'), /* Chrome 26+, Opera 23+, Firefox 39+ */
url('/fonts/ubuntu-v15-latin-700.woff') format('woff'); /* Chrome 6+, Firefox 3.6+, IE 9+, Safari 5.1+ */
}
2020-09-09 21:09:51 +00:00
html, body {
padding: 0;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
height: 100%;
flex: 1;
display: flex;
flex-direction: column;
2021-02-15 12:42:03 +00:00
background-color: #191919;
2021-03-12 11:43:02 +00:00
color: #aaa;
2021-04-23 15:35:48 +00:00
font-family:Ubuntu, Arial, sans-serif;
2020-09-09 21:09:51 +00:00
}
#__next {
flex: 1;
display: flex;
flex-direction: column;
}
.material-icons {
vertical-align: middle;
margin: 8px;
}
2020-11-26 15:57:20 +00:00
.pswp__item video {
width: 100%;
height: 100%;
}
.video-loading {
width: 100%;
height: 100%;
position: relative;
}
.video-loading > img {
object-fit: contain;
width: 100%;
height: 100%;
}
.video-loading > div {
position: relative;
top: -50vh;
left: 50vw;
}
2020-09-09 21:09:51 +00:00
:root {
--primary: #e26f99,
};
2020-09-13 17:01:36 +00:00
svg {
fill: currentColor;
}
2020-10-03 14:21:56 +00:00
.pswp__img {
object-fit: contain;
}
2021-01-14 12:34:55 +00:00
.modal-90w{
width:90vw;
2021-02-15 13:19:59 +00:00
max-width:960px!important;
}
2021-03-13 07:25:18 +00:00
.modal {
z-index: 2000;
}
2021-04-21 06:56:57 +00:00
.modal-dialog-centered {
min-height: -webkit-calc(90% - 3.5rem);
min-height: -moz-calc(90% - 3.5rem);
min-height: calc(90% - 3.5rem);
}
2021-03-13 07:25:18 +00:00
.modal .modal-header, .modal .modal-footer {
border-color: #444 !important;
}
.modal .modal-header .close {
color: #aaa;
text-shadow: none;
}
.modal-backdrop {
z-index:2000;
}
2021-04-26 07:44:56 +00:00
.modal .card , .table {
2021-02-15 13:19:59 +00:00
background-color: #202020;
border: none;
}
.modal .card > div {
border-radius: 30px;
overflow: hidden;
margin: 0 0 5px 0;
2021-01-14 14:07:26 +00:00
}
2021-02-15 10:46:16 +00:00
.modal-content {
2021-04-19 08:29:12 +00:00
border-radius:15px;
2021-02-15 13:19:59 +00:00
background-color:#202020 !important;
color:#aaa;
2021-01-14 12:34:55 +00:00
}
2021-02-15 08:14:33 +00:00
.download-btn{
margin-top:10px;
width: 25px;
height: 25px;
float: right;
background: url('/download_icon.png') no-repeat;
cursor: pointer;
background-size: cover;
border: none;
2021-02-17 09:09:43 +00:00
}
2021-04-11 05:08:06 +00:00
.btn-success {
2021-02-15 10:46:16 +00:00
background: #2dc262;
2021-02-15 11:34:11 +00:00
border-color: #29a354;
2021-02-15 10:46:16 +00:00
}
2021-04-11 05:08:06 +00:00
.btn-success:hover ,.btn-success:focus .btn-success:active{
2021-02-15 10:46:16 +00:00
background-color: #29a354;
2021-02-15 11:34:11 +00:00
border-color: #2dc262;
2021-02-15 10:46:16 +00:00
}
2021-04-08 06:18:28 +00:00
.btn-success:disabled {
2021-02-15 10:46:16 +00:00
background-color: #69b383;
}
2021-04-08 06:18:28 +00:00
.btn-outline-success {
2021-03-22 13:02:16 +00:00
color: #2dc262;
border-color: #2dc262;
2021-04-05 13:53:12 +00:00
border-width: 2px;
2021-03-22 13:02:16 +00:00
}
2021-04-08 06:18:28 +00:00
.btn-outline-success:hover {
2021-03-22 13:02:16 +00:00
background: #2dc262;
}
2021-04-11 05:08:06 +00:00
.btn-outline-danger, .btn-outline-secondary, .btn-outline-primary{
2021-04-05 13:59:48 +00:00
border-width: 2px;
}
2021-02-15 12:42:03 +00:00
.card {
background-color: #242424;
2021-04-19 08:29:12 +00:00
color: #d1d1d1;
2021-02-15 12:42:03 +00:00
border-radius: 12px;
2021-02-15 08:14:33 +00:00
}
2021-03-09 07:41:52 +00:00
.jumbotron{
2021-03-09 10:36:23 +00:00
background-color: #191919;
2021-04-19 08:29:12 +00:00
color: #d1d1d1;
2021-03-09 10:36:23 +00:00
text-align: center;
margin-top: 50px;
}
.alert-success {
2021-04-05 14:32:15 +00:00
background-color: #a9f7ff;
color: #000000;
2021-03-09 10:36:23 +00:00
}
.alert-primary {
background-color: #c4ffd6;
2021-03-09 07:41:52 +00:00
}
2021-03-11 14:13:36 +00:00
.ente-modal{
2021-03-11 13:36:54 +00:00
width: 500px;
max-width:100%;
}
.bm-burger-button {
position: fixed;
2021-03-13 05:18:16 +00:00
width: 28px;
height: 20px;
top:25px;
left: 32px;
2021-03-13 05:18:16 +00:00
}
.bm-burger-bars {
2021-03-13 05:18:16 +00:00
background: #bdbdbd;
}
.bm-menu-wrap {
top:0px;
}
2021-03-13 05:18:16 +00:00
.bm-menu {
2021-03-13 07:00:40 +00:00
background: #131313;
padding: 2.5em 1.5em 0;
font-size: 1.15em;
2021-04-19 08:29:12 +00:00
color:#d1d1d1
2021-03-13 05:18:16 +00:00
}
.bm-cross {
2021-04-19 08:29:12 +00:00
background: #d1d1d1;
2021-03-13 05:18:16 +00:00
}
2021-03-22 12:22:15 +00:00
.bg-upload-progress-bar {
background-color: #2dc262;
}
2021-04-18 10:33:22 +00:00
.custom-switch.custom-switch-md .custom-control-label {
padding-left: 2rem;
padding-bottom: 1.5rem;
}
.custom-switch.custom-switch-md .custom-control-label::before {
height: 1.5rem;
2021-04-19 08:29:12 +00:00
background-color: #303030;
border: none;
2021-04-18 10:33:22 +00:00
width: calc(2.5rem + 0.75rem);
border-radius: 3rem;
}
2021-04-19 08:29:12 +00:00
.custom-switch.custom-switch-md:active .custom-control-label::before {
background-color: #303030;
}
2021-04-18 10:33:22 +00:00
.custom-switch.custom-switch-md .custom-control-label::after {
2021-04-19 08:29:12 +00:00
top:2px;
background:#c4c4c4;
width: calc(2.0rem - 4px);
height: calc(2.0rem - 4px);
border-radius: calc(2rem - (2.0rem / 2));
2021-04-18 10:33:22 +00:00
}
.custom-switch.custom-switch-md .custom-control-input:checked ~ .custom-control-label::after {
transform: translateX(calc(2.0rem - 0.25rem));
2021-04-19 08:29:12 +00:00
background:#c4c4c4;
2021-04-18 10:33:22 +00:00
}
2021-04-18 10:41:56 +00:00
.bold-text{
color: #ECECEC;
line-height: 24px;
font-size: 24px;
}
.subscription-plan-selector {
background: #222;
}
.subscription-plan-selector:hover {
background: #1b1b1b;
}
2021-04-24 10:54:16 +00:00
.dropdown-item:active{
color: #16181b;
text-decoration: none;
background-color: #e9ecef;
}
2021-04-25 15:01:44 +00:00
.submitButton:hover > .spinner-border{
color:white;
}
2021-04-26 07:44:56 +00:00
hr{
border-top: 1rem solid #444 !important;
}
2020-09-09 21:09:51 +00:00
`;
const Image = styled.img`
max-height: 28px;
margin-right: 5px;
2020-09-09 21:09:51 +00:00
`;
const FlexContainer = styled.div`
flex: 1;
2021-02-15 09:21:52 +00:00
text-align: center;
`;
export interface BannerMessage {
message: string;
variant: string;
}
2021-03-08 12:44:07 +00:00
sentryInit();
2021-03-08 11:59:14 +00:00
export default function App({ Component, pageProps, err }) {
2021-01-14 12:34:55 +00:00
const router = useRouter();
const [loading, setLoading] = useState(false);
useEffect(() => {
console.log(
`%c${constants.CONSOLE_WARNING_STOP}`,
'color: red; font-size: 52px;'
);
console.log(`%c${constants.CONSOLE_WARNING_DESC}`, 'font-size: 20px;');
router.events.on('routeChangeStart', (url: string) => {
if (window.location.pathname !== url.split('?')[0]) {
setLoading(true);
}
});
router.events.on('routeChangeComplete', () => {
setLoading(false);
});
}, []);
return (
<>
2021-01-19 03:41:56 +00:00
<Head>
2021-02-27 11:01:25 +00:00
<title>{constants.TITLE}</title>
2021-04-15 08:50:18 +00:00
{/* Cloudflare Web Analytics */}
<script
defer
src="https://static.cloudflareinsights.com/beacon.min.js"
data-cf-beacon='{"token": "6a388287b59c439cb2070f78cc89dde1"}'
/>
{/* End Cloudflare Web Analytics */}
2021-01-19 03:41:56 +00:00
</Head>
<GlobalStyles />
<Navbar>
<FlexContainer>
2021-03-08 13:39:53 +00:00
<Image
style={{ height: '24px' }}
alt="logo"
src="/icon.svg"
/>
2021-01-19 03:41:56 +00:00
</FlexContainer>
</Navbar>
{loading ? (
<Container>
2021-04-18 13:01:40 +00:00
<EnteSpinner>
<span className="sr-only">Loading...</span>
2021-04-18 13:01:40 +00:00
</EnteSpinner>
2021-01-19 03:41:56 +00:00
</Container>
) : (
2021-04-26 20:10:06 +00:00
<Component err={err} />
)}
</>
2020-09-09 21:09:51 +00:00
);
}