Skip to content

Commit

Permalink
Deps - Upgrade to Emotion v11 (from v10) [BREAKING CHANGES] (#247) (m…
Browse files Browse the repository at this point in the history
…odified, conflicts solved)
  • Loading branch information
Vadorequest committed Jan 11, 2021
1 parent a5da6f3 commit a284eb4
Show file tree
Hide file tree
Showing 46 changed files with 302 additions and 216 deletions.
6 changes: 6 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ plugins:
- jest
- react
- react-hooks
- '@emotion'
parser: '@typescript-eslint/parser'
parserOptions:
project: ./tsconfig.json
Expand Down Expand Up @@ -95,6 +96,11 @@ rules: # See https://eslint.org/docs/rules
extendDefaults: true
types:
'{}': false # Allow writing `type Props = {}` - See https://github.com/typescript-eslint/typescript-eslint/issues/2063#issuecomment-632833366

# Emotion rules - See https://github.com/emotion-js/emotion/tree/master/packages/eslint-plugin
# Emotion 11 - See https://emotion.sh/docs/emotion-11
'@emotion/pkg-renaming': error

overrides:
- files: ['**/*.tsx']
rules:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-vercel-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ jobs:
# On E2E failure, add a comment to the PR with additional information, if there is an open PR for the current branch
- name: Comment PR (E2E failure)
uses: peter-evans/create-or-update-comment@v1 # See https://github.com/peter-evans/create-or-update-comment
if: fromJson(steps.restore-variable.outputs.variables).GITHUB_PULL_REQUEST_ID && success()
if: fromJson(steps.restore-variable.outputs.variables).GITHUB_PULL_REQUEST_ID && failure()
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ fromJson(steps.restore-variable.outputs.variables).GITHUB_PULL_REQUEST_ID }}
Expand Down
14 changes: 13 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,20 @@
*
* @see https://nextjs.org/docs/advanced-features/customizing-babel-config Official doc reference v10
* @see https://github.com/vercel/next.js/blob/canary/packages/next/build/babel/preset.ts You can take a look at this file to learn about the presets included by next/babel.
* @see https://emotion.sh/docs/css-prop##babel-preset Configuring Emotion 11
* @example https://github.com/vercel/next.js/tree/canary/examples/with-custom-babel-config Next.js official example of customizing Babel
*/
module.exports = {
presets: ['next/babel', '@emotion/babel-preset-css-prop'],
presets: [
[
"next/babel",
{
"preset-react": {
"runtime": "automatic",
"importSource": "@emotion/react"
}
}
]
],
plugins: ["@emotion/babel-plugin"],
};
1 change: 0 additions & 1 deletion cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"exclude": [],
"compilerOptions": {
"baseUrl": ".",
"jsx": "react",
"types": [
"cypress"
],
Expand Down
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
"@amplitude/react-amplitude": "1.0.0",
"@apollo/react-hooks": "3.1.5",
"@apollo/react-ssr": "3.1.5",
"@emotion/core": "10.0.35",
"@emotion/styled": "10.0.27",
"@emotion/react": "11.1.4",
"@emotion/styled": "11.0.0",
"@fortawesome/fontawesome-svg-core": "1.2.32",
"@fortawesome/free-brands-svg-icons": "5.15.1",
"@fortawesome/free-regular-svg-icons": "5.15.1",
Expand All @@ -119,7 +119,6 @@
"css-to-react-native": "3.0.0",
"csstype": "3.0.6",
"deepmerge": "4.2.2",
"emotion-theming": "10.0.27",
"graphql": "15.4.0",
"graphql-tag": "2.11.0",
"i18next": "19.8.4",
Expand Down Expand Up @@ -168,7 +167,7 @@
},
"devDependencies": {
"@cypress/react": "4.16.3",
"@emotion/babel-preset-css-prop": "10.0.27",
"@emotion/eslint-plugin": "11.0.0",
"@next/bundle-analyzer": "10.0.5",
"@svgr/cli": "5.5.0",
"@types/amplitude-js": "7.0.0",
Expand Down
18 changes: 7 additions & 11 deletions src/components/ComponentTemplate.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import React from 'react';

import Text from './utils/Text';

type Props = {}

/**
* This component is a template meant to be duplicated to quickly get started with new React components.
*/
const ComponentTemplate: React.FunctionComponent<Props> = (props): JSX.Element => {
return (
<Text
<div
css={css`
margin: 30px;
`}
>
{`
This component is a template meant to be duplicated to quickly get started with new React components.
Feel free to adapt it at your convenience
`}
</Text>
>
This component is a template meant to be duplicated to quickly get started with new React components.<br />
<br />
Feel free to adapt it at your convenience
</div>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/animations/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import React from 'react';

import AnimatedLoader from '../svg/AnimatedLoader';
Expand Down
4 changes: 2 additions & 2 deletions src/components/appBootstrap/BrowserPageBootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import * as Sentry from '@sentry/node';
import { createLogger } from '@unly/utils-simple-logger';
import { AmplitudeClient } from 'amplitude-js';
import { useTheme } from 'emotion-theming';
import { useTheme } from '@emotion/react';
import React from 'react';
import { useTranslation } from 'react-i18next';
import useCustomer from '../../hooks/useCustomer';
Expand Down Expand Up @@ -76,7 +76,7 @@ const BrowserPageBootstrap = (props: BrowserPageBootstrapProps): JSX.Element =>
cookiesManager,
userSession,
};
const theme = useTheme<CustomerTheme>();
const theme = useTheme();
const isCypressRunning = detectCypress();
const isLightHouseRunning = detectLightHouse();

Expand Down
2 changes: 1 addition & 1 deletion src/components/appBootstrap/MultiversalAppBootstrap.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Sentry from '@sentry/node';
import { isBrowser } from '@unly/utils';
import { createLogger } from '@unly/utils-simple-logger';
import { ThemeProvider } from 'emotion-theming';
import { ThemeProvider } from '@emotion/react';
import { i18n } from 'i18next';
import find from 'lodash.find';
import includes from 'lodash.includes';
Expand Down
2 changes: 1 addition & 1 deletion src/components/appBootstrap/MultiversalGlobalStyles.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
css,
Global,
} from '@emotion/core';
} from '@emotion/react';
import React from 'react';
import { NRN_DEFAULT_FALLBACK_FONTS } from '../../constants';
import { CustomerTheme } from '../../types/data/CustomerTheme';
Expand Down
2 changes: 1 addition & 1 deletion src/components/data/ProductRow.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import React from 'react';
import {
Col,
Expand Down
2 changes: 1 addition & 1 deletion src/components/data/Products.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import map from 'lodash.map';
import React from 'react';
import { Container } from 'reactstrap';
Expand Down
2 changes: 1 addition & 1 deletion src/components/doc/DocPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import React, { ReactNode } from 'react';

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/doc/DocSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import React, { ReactNode } from 'react';

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/doc/IntroductionSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import React from 'react';
import {
Alert,
Expand Down
2 changes: 1 addition & 1 deletion src/components/doc/SidebarFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React from 'react';
import { useTranslation } from 'react-i18next';
Expand Down
2 changes: 1 addition & 1 deletion src/components/doc/SidebarToggle.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import React from 'react';

Expand Down
2 changes: 1 addition & 1 deletion src/components/errors/DefaultErrorLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import * as Sentry from '@sentry/node';
import * as React from 'react';
import { Button } from 'reactstrap';
Expand Down
2 changes: 1 addition & 1 deletion src/components/errors/ErrorDebug.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import * as React from 'react';
import { Fragment } from 'react';

Expand Down
4 changes: 2 additions & 2 deletions src/components/pageLayouts/DefaultPageContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import classnames from 'classnames';
import { useTheme } from 'emotion-theming';
import { useTheme } from '@emotion/react';
import React from 'react';
import { Container } from 'reactstrap';

Expand Down
6 changes: 3 additions & 3 deletions src/components/pageLayouts/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@emotion/core';
import { useTheme } from 'emotion-theming';
import { css } from '@emotion/react';
import { useTheme } from '@emotion/react';
import React from 'react';
import { useTranslation } from 'react-i18next';

Expand Down Expand Up @@ -27,7 +27,7 @@ const Footer: React.FunctionComponent<Props> = (props) => {
const customer: Customer = useCustomer();
const { availableLanguages } = customer;
const shouldDisplayI18nButton = availableLanguages?.length > 1;
const theme = useTheme<CustomerTheme>();
const theme = useTheme();
const {
backgroundColor,
onBackgroundColor,
Expand Down
6 changes: 3 additions & 3 deletions src/components/pageLayouts/Nav.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Amplitude } from '@amplitude/react-amplitude';
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import classnames from 'classnames';
import { useTheme } from 'emotion-theming';
import { useTheme } from '@emotion/react';
import kebabCase from 'lodash.kebabcase';
import map from 'lodash.map';
import {
Expand Down Expand Up @@ -45,7 +45,7 @@ type Props = {};
const Nav: React.FunctionComponent<Props> = () => {
const { t } = useTranslation();
const router: NextRouter = useRouter();
const theme = useTheme<CustomerTheme>();
const theme = useTheme();
const { locale }: I18n = useI18n();
const { primaryColor, logo } = theme;

Expand Down
6 changes: 3 additions & 3 deletions src/components/pageLayouts/PreviewModeBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { useTheme } from 'emotion-theming';
import { useTheme } from '@emotion/react';
import {
NextRouter,
useRouter,
Expand Down Expand Up @@ -61,7 +61,7 @@ const PreviewModeBanner: React.FunctionComponent<Props> = (props): JSX.Element =
const { t } = useTranslation();
const {
secondaryColor, secondaryColorVariant1, onSecondaryColor,
} = useTheme<CustomerTheme>();
} = useTheme();

if (process.env.NEXT_PUBLIC_APP_STAGE === 'production') {
return null;
Expand Down
6 changes: 3 additions & 3 deletions src/components/pageLayouts/QuickPreviewBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { createLogger } from '@unly/utils-simple-logger';
import { useTheme } from 'emotion-theming';
import { useTheme } from '@emotion/react';
import {
NextRouter,
useRouter,
Expand Down Expand Up @@ -45,7 +45,7 @@ const QuickPreviewBanner: React.FunctionComponent<Props> = (props): JSX.Element
} = props;
const {
secondaryColor, secondaryColorVariant1, onSecondaryColor,
} = useTheme<CustomerTheme>();
} = useTheme();
const { t } = useTranslation();
const router: NextRouter = useRouter();
const customer: Customer = useCustomer();
Expand Down
19 changes: 12 additions & 7 deletions src/components/svg/AnimatedTextBubble.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { css } from '@emotion/core';
import { useTheme } from 'emotion-theming';
import {
css,
useTheme,
} from '@emotion/react';
import React from 'react';

import { Theme } from '../../types/data/Theme';

const AnimatedTextBubble = props => {
const theme: Theme = useTheme();
const theme = useTheme();
const { surfaceColor } = theme;
return (
<div style={{ width: '100%', marginLeft: '20px' }}>
<div
style={{
width: '100%',
marginLeft: '20px',
}}
>
<svg
viewBox="0 0 33 21" width="50px" {...props}
css={css`
Expand All @@ -20,7 +25,7 @@ const AnimatedTextBubble = props => {
transform: translateY(-4px);
}
30% {
transform: translateY(0px);
transform: translateY(0px);
}
100% {
transform: translateY(0px);
Expand Down
6 changes: 3 additions & 3 deletions src/components/utils/Btn.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import classnames from 'classnames';
import { useTheme } from 'emotion-theming';
import { useTheme } from '@emotion/react';
import React, { ReactNode } from 'react';
import { CustomerTheme } from '../../types/data/CustomerTheme';
import { ReactButtonProps } from '../../types/react/ReactButtonProps';
Expand Down Expand Up @@ -35,7 +35,7 @@ const Btn: React.FunctionComponent<Props> = (props): JSX.Element => {
transparent,
...rest
} = props;
const customerTheme = useTheme<CustomerTheme>();
const customerTheme = useTheme();
const {
color,
backgroundColor,
Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/Buttons.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import React, { Fragment } from 'react';
import { Row } from 'reactstrap';
import Btn from './Btn';
Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/Cards.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import classnames from 'classnames';
import React, { ReactNode } from 'react';
import { CardDeck } from 'reactstrap';
Expand Down
6 changes: 3 additions & 3 deletions src/components/utils/CircleBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@emotion/core';
import { useTheme } from 'emotion-theming';
import { css } from '@emotion/react';
import { useTheme } from '@emotion/react';
import React from 'react';
import { CustomerTheme } from '../../types/data/CustomerTheme';
import { ReactDivProps } from '../../types/react/ReactDivProps';
Expand Down Expand Up @@ -32,7 +32,7 @@ const CircleBtn: React.FunctionComponent<Props> = (props): JSX.Element => {
transparent,
...rest
} = props;
const customerTheme = useTheme<CustomerTheme>();
const customerTheme = useTheme();
const {
color,
backgroundColor,
Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/EllipsisText.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import React, { ReactNode } from 'react';

type Props = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/utils/LanguageSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { css } from '@emotion/core';
import { css } from '@emotion/react';
import React from 'react';

type Props = {}
Expand Down
Loading

1 comment on commit a284eb4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.