Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Migrate to emotion #992

Merged
merged 6 commits into from
Mar 25, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 0 additions & 6 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ module.exports = (phase) =>
'@mui/system',
'@mui/icons-material',
],
compiler: {
styledComponents: {
ssr: true,
displayName: true,
},
},
env: {
SENTRY_RELEASE: GIT_SHA,
NEXT_PUBLIC_IS_TEST_APP: process.env.IS_TEST_RELEASE,
Expand Down
12 changes: 5 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
},
"dependencies": {
"@date-io/date-fns": "^2.14.0",
"@emotion/cache": "^11.10.5",
"@emotion/react": "^11.10.6",
"@emotion/server": "^11.10.0",
"@emotion/styled": "^11.10.6",
"@mui/icons-material": "^5.6.2",
"@mui/material": "^5.6.2",
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest",
"@mui/styled-engine-sc": "^5.6.1",
"@mui/x-date-pickers": "^5.0.0-alpha.6",
"@sentry/nextjs": "^6.7.1",
"@stripe/stripe-js": "^1.13.2",
Expand Down Expand Up @@ -97,7 +99,6 @@
"@types/react-select": "^4.0.15",
"@types/react-window": "^1.8.2",
"@types/react-window-infinite-loader": "^1.0.3",
"@types/styled-components": "^5.1.25",
"@types/wicg-file-system-access": "^2020.9.5",
"@types/yup": "^0.29.7",
"@types/zxcvbn": "^4.4.1",
Expand All @@ -112,8 +113,5 @@
},
"standard": {
"parser": "babel-eslint"
},
"resolutions": {
"@mui/styled-engine": "npm:@mui/styled-engine-sc@latest"
}
}
}
7 changes: 5 additions & 2 deletions src/components/Collections/styledComponents.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Box } from '@mui/material';
import { styled } from '@mui/material';
import { Overlay } from 'components/Container';
import { SpecialPadding } from 'styles/SpecialPadding';
import { IMAGE_CONTAINER_MAX_WIDTH, MIN_COLUMNS } from 'constants/gallery';
export const CollectionListWrapper = styled(Box)`
position: relative;
overflow: hidden;
Expand All @@ -10,7 +10,10 @@ export const CollectionListWrapper = styled(Box)`
`;

export const CollectionListBarWrapper = styled(Box)`
${SpecialPadding}
padding: 0 24px;
@media (max-width: ${IMAGE_CONTAINER_MAX_WIDTH * MIN_COLUMNS}px) {
padding: 0 4px;
}
margin-bottom: 16px;
border-bottom: 1px solid ${({ theme }) => theme.palette.divider};
`;
Expand Down
3 changes: 1 addition & 2 deletions src/components/EnteDrawer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Drawer } from '@mui/material';
import styled from 'styled-components';
import { Drawer, styled } from '@mui/material';

export const EnteDrawer = styled(Drawer)(({ theme }) => ({
'& .MuiPaper-root': {
Expand Down
15 changes: 5 additions & 10 deletions src/components/MachineLearning/ImageViews.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import React, { useState, useEffect } from 'react';
import styled from 'styled-components';
import { styled } from '@mui/material';

import { imageBitmapToBlob } from 'utils/image';
import { logError } from 'utils/sentry';
import { getBlobFromCache } from 'utils/storage/cache';

export const Image = styled.img``;

export const FaceCropsRow = styled.div`
export const FaceCropsRow = styled('div')`
& > img {
width: 256px;
height: 256px;
}
`;

export const FaceImagesRow = styled.div`
export const FaceImagesRow = styled('div')`
& > img {
width: 112px;
height: 112px;
Expand Down Expand Up @@ -92,9 +91,5 @@ export function ImageBlobView(props: { blob: Blob }) {
}
}, [props.blob]);

return (
<>
<Image src={imgUrl}></Image>
</>
);
return <img src={imgUrl} />;
}
5 changes: 3 additions & 2 deletions src/components/MachineLearning/MlDebug-disabled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export {};
// import mlIDbStorage from 'utils/storage/mlIDbStorage';
// import { getFaceCropBlobFromStorage } from 'utils/machineLearning/faceCrop';
// import { PeopleList } from './PeopleList';
// import styled from 'styled-components';
// import { styled } from '@mui/material';

// import { RawNodeDatum } from 'react-d3-tree/lib/types/common';
// import { DebugInfo, mstToBinaryTree } from 'hdbscan';
// import { toD3Tree } from 'utils/machineLearning/clustering';
Expand Down Expand Up @@ -70,7 +71,7 @@ export {};
// );
// }

// const D3ImageContainer = styled.div`
// const D3ImageContainer = styled('div')`
// & > img {
// width: 100%;
// height: 100%;
Expand Down
6 changes: 3 additions & 3 deletions src/components/MachineLearning/PeopleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getPeopleList,
getUnidentifiedFaces,
} from 'utils/machineLearning';
import styled from 'styled-components';
import { styled } from '@mui/material';
import { EnteFile } from 'types/file';
import { ImageCacheView } from './ImageViews';
import { CACHES } from 'constants/cache';
Expand All @@ -14,7 +14,7 @@ import { addLogLine } from 'utils/logging';
import { logError } from 'utils/sentry';
import { t } from 'i18next';

const FaceChipContainer = styled.div`
const FaceChipContainer = styled('div')`
display: flex;
flex-wrap: wrap;
justify-content: center;
Expand All @@ -24,7 +24,7 @@ const FaceChipContainer = styled.div`
overflow: auto;
`;

const FaceChip = styled.div<{ clickable?: boolean }>`
const FaceChip = styled('div')<{ clickable?: boolean }>`
width: 112px;
height: 112px;
margin: 5px;
Expand Down
7 changes: 5 additions & 2 deletions src/components/Navbar/base.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FlexWrapper } from 'components/Container';
import { styled } from '@mui/material';
import { SpecialPadding } from 'styles/SpecialPadding';
import { IMAGE_CONTAINER_MAX_WIDTH, MIN_COLUMNS } from 'constants/gallery';
const NavbarBase = styled(FlexWrapper)`
min-height: 64px;
position: sticky;
Expand All @@ -10,7 +10,10 @@ const NavbarBase = styled(FlexWrapper)`
border-bottom: 1px solid ${({ theme }) => theme.palette.divider};
background-color: ${({ theme }) => theme.palette.background.default};
margin-bottom: 16px;
${SpecialPadding}
padding: 0 24px;
@media (max-width: ${IMAGE_CONTAINER_MAX_WIDTH * MIN_COLUMNS}px) {
padding: 0 4px;
}
`;

export default NavbarBase;
6 changes: 4 additions & 2 deletions src/components/PhotoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { DeduplicateContext } from 'pages/deduplicate';
import { FlexWrapper } from './Container';
import { Typography } from '@mui/material';
import { GalleryContext } from 'pages/gallery';
import { SpecialPadding } from 'styles/SpecialPadding';
import { formatDate } from 'utils/time/format';
import { Trans } from 'react-i18next';
import { t } from 'i18next';
Expand Down Expand Up @@ -111,7 +110,10 @@ const ListContainer = styled(Box)<{
grid-column-gap: ${GAP_BTW_TILES}px;
width: 100%;
color: #fff;
${SpecialPadding}
padding: 0 24px;
@media (max-width: ${IMAGE_CONTAINER_MAX_WIDTH * MIN_COLUMNS}px) {
padding: 0 4px;
}
`;

const ListItemContainer = styled(FlexWrapper)<{ span: number }>`
Expand Down
7 changes: 5 additions & 2 deletions src/components/Search/SearchBar/styledComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import {
FluidContainer,
} from 'components/Container';
import { css, styled } from '@mui/material';
import { SpecialPadding } from 'styles/SpecialPadding';
import { IMAGE_CONTAINER_MAX_WIDTH, MIN_COLUMNS } from 'constants/gallery';

export const SearchBarWrapper = styled(FlexWrapper)`
${SpecialPadding}
padding: 0 24px;
@media (max-width: ${IMAGE_CONTAINER_MAX_WIDTH * MIN_COLUMNS}px) {
padding: 0 4px;
}
`;

export const SearchMobileBox = styled(FluidContainer)`
Expand Down
25 changes: 19 additions & 6 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import { styled, ThemeProvider } from '@mui/material/styles';
import darkThemeOptions from 'themes/darkThemeOptions';
import lightThemeOptions from 'themes/lightThemeOptions';
import { CssBaseline, useMediaQuery } from '@mui/material';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import * as types from 'styled-components/cssprop'; // need to css prop on styled component
import { SetDialogBoxAttributes, DialogBoxAttributes } from 'types/dialogBox';
import {
getFamilyPortalRedirectURL,
Expand Down Expand Up @@ -56,6 +54,9 @@ import { SetTheme } from 'types/theme';
import { useLocalState } from 'hooks/useLocalState';
import { THEME_COLOR } from 'constants/theme';
import { setupI18n } from 'i18n';
import createEmotionCache from 'themes/createEmotionCache';
import { CacheProvider, EmotionCache } from '@emotion/react';
import { AppProps } from 'next/app';

export const MessageContainer = styled('div')`
background-color: #111;
Expand Down Expand Up @@ -115,7 +116,19 @@ const redirectMap = new Map([

const APP_TITLE = 'ente Photos';

export default function App({ Component, err }) {
// Client-side cache, shared for the whole session of the user in the browser.
const clientSideEmotionCache = createEmotionCache();

export interface EnteAppProps extends AppProps {
emotionCache?: EmotionCache;
}

export default function App(props) {
const {
Component,
emotionCache = clientSideEmotionCache,
pageProps,
} = props;
const router = useRouter();
const [isI18nReady, setIsI18nReady] = useState<boolean>(false);
const [loading, setLoading] = useState(false);
Expand Down Expand Up @@ -323,7 +336,7 @@ export default function App({ Component, err }) {
});

return (
<>
<CacheProvider value={emotionCache}>
<Head>
<title>{isI18nReady ? t('TITLE') : APP_TITLE}</title>
<meta
Expand Down Expand Up @@ -411,10 +424,10 @@ export default function App({ Component, err }) {
</EnteSpinner>
</VerticallyCentered>
) : (
<Component err={err} setLoading={setLoading} />
<Component setLoading={setLoading} {...pageProps} />
)}
</AppContext.Provider>
</ThemeProvider>
</>
</CacheProvider>
);
}
Loading