Skip to content

emotion 9 --> emotion 10 #3321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Apr 26, 2019
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module.exports = {
argsIgnorePattern: '^event$',
ignoreRestSiblings: true,
vars: 'all',
varsIgnorePattern: 'jsx|emotionJSX'
},
],
curly: [2, 'multi-line'],
Expand Down
5 changes: 3 additions & 2 deletions docs/App/Footer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import React, { type Node } from 'react';
/** @jsx jsx */
import { type Node } from 'react';
import { jsx } from '@emotion/core';

// const smallDevice = '@media (max-width: 769px)';
const largeDevice = '@media (min-width: 770px)';
Expand Down
4 changes: 2 additions & 2 deletions docs/App/GitHubButton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React from 'react';
/** @jsx jsx */
import { jsx } from '@emotion/core';

type Props = { count: number, repo: string };

Expand Down
5 changes: 3 additions & 2 deletions docs/App/Header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @flow

/** @jsx jsx */
import fetch from 'unfetch';
import React, { Component, type Node } from 'react';
import { Component, type Node } from 'react';
import { jsx } from '@emotion/core';
import { withRouter } from 'react-router-dom';

import Select from '../../src';
Expand Down
5 changes: 3 additions & 2 deletions docs/App/PageNav.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import React, { Component, type ElementRef } from 'react';
/** @jsx jsx */
import { Component, type ElementRef } from 'react';
import { jsx } from '@emotion/core';
import { Route, Switch } from 'react-router-dom';

import type { RouterProps } from '../types';
Expand Down
4 changes: 2 additions & 2 deletions docs/App/TwitterButton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React from 'react';
/** @jsx jsx */
import { jsx } from '@emotion/core';

const TwitterButton = () => (
<div css={{ alignItems: 'center', display: 'inline-flex' }}>
Expand Down
5 changes: 3 additions & 2 deletions docs/App/components.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @flow

import React, { Component, type ElementConfig } from 'react';
/** @jsx jsx */
import { Component, type ElementConfig } from 'react';
import { Link, withRouter } from 'react-router-dom';
import { jsx } from '@emotion/core';

const navWidth = 180;
const appWidth = 800;
Expand Down
4 changes: 3 additions & 1 deletion docs/ExampleWrapper.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { Component } from 'react';
/** @jsx jsx */
import { jsx } from '@emotion/core'; // eslint-disable-line no-unused-vars
import { Component } from 'react';
import CodeSandboxer from 'react-codesandboxer';
import { replaceImports } from 'codesandboxer';
import { CodeBlock } from './markdown/renderer';
Expand Down
4 changes: 3 additions & 1 deletion docs/Svg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React from 'react';
// @flow
/** @jsx jsx */
import { jsx } from '@emotion/core';

const Svg = ({ size, ...props }: { size: number }) => (
<svg
Expand Down
2 changes: 1 addition & 1 deletion docs/Tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export default function Tests() {
<div id={'cypress-long-values'}>
<Select
id="long-value-select"
instsanceId="long-value-select"
instanceId="long-value-select"
classNamePrefix="react-select"
defaultValue={optionLength[3]}
options={optionLength}
Expand Down
5 changes: 3 additions & 2 deletions docs/examples/Experimental.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow

import React, { Component } from 'react';
/** @jsx jsx */
import { Component } from 'react';
import { jsx } from '@emotion/core';
import moment from 'moment';
import chrono from 'chrono-node';

Expand Down
4 changes: 3 additions & 1 deletion docs/examples/Popout.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import React, { Component } from 'react';
/** @jsx jsx */
import { Component } from 'react';
import { jsx } from '@emotion/core';
import Button from '@atlaskit/button';

import Select from '../../src';
Expand Down
8 changes: 5 additions & 3 deletions docs/markdown/renderer.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
// @flow
/** @jsx emotionJSX */
import md from 'react-markings';
import { jsx as emotionJSX } from '@emotion/core'; // eslint-disable-line no-unused-vars
import { Link as RRLink } from 'react-router-dom';

import Svg from '../Svg';
Expand Down Expand Up @@ -119,7 +121,7 @@ const Heading = props => {
};

// eslint-disable-next-line no-unused-vars
export const Code = ({ children, inline, literal, nodeKey }) => (
export const Code = ({ children, inline, literal, nodeKey }: any) => (
<code
css={{
backgroundColor: 'rgba(38, 132, 255, 0.08)',
Expand All @@ -134,7 +136,7 @@ export const Code = ({ children, inline, literal, nodeKey }) => (
</code>
);

export const CodeBlock = ({ codeinfo, literal, nodeKey, ...props }) => {
export const CodeBlock = ({ codeinfo, literal, nodeKey, ...props }: any) => {
const language = codeinfo[0];

return (
Expand Down
4 changes: 2 additions & 2 deletions docs/styled-components.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow

import React from 'react';
/** @jsx emotionJSX */
import { jsx as emotionJSX } from '@emotion/core';

import SyntaxHighlighter, {
registerLanguage,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"url": "https://github.com/JedWatson/react-select.git"
},
"dependencies": {
"@emotion/cache": "^10.0.0",
"@emotion/core": "^10.0.5",
"classnames": "^2.2.5",
"emotion": "^9.1.2",
"memoize-one": "^5.0.0",
Expand Down Expand Up @@ -49,7 +51,7 @@
"css-loader": "^0.28.7",
"cypress": "^1.4.1",
"dotenv": "^5.0.1",
"enzyme": "^3.3.0",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

upgrade enzyme so it plays well with emotion 10 and new context api

"enzyme": "^3.8.0",
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.0",
"eslint": "^4.6.1",
Expand Down
28 changes: 28 additions & 0 deletions src/NonceProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @flow
import React, { Component, type Node } from 'react';
import { CacheProvider } from '@emotion/core';
import createCache from '@emotion/cache';
import memoizeOne from 'memoize-one';

type NonceProviderProps = {
nonce: string,
children: Node,
};

export default class NonceProvider extends Component<NonceProviderProps> {
constructor (props: NonceProviderProps) {
super(props);
this.createEmotionCache = memoizeOne(this.createEmotionCache);
}
createEmotionCache = (nonce: string) => {
return createCache({ nonce });
}
render () {
const emotionCache = this.createEmotionCache(this.props.nonce);
return (
<CacheProvider value={emotionCache}>
{this.props.children}
</CacheProvider>
);
}
}
3 changes: 1 addition & 2 deletions src/Select.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import React, { Component, type ElementRef, type Node } from 'react';

import memoizeOne from 'memoize-one';
import { MenuPlacer } from './components/Menu';
import isEqual from './internal/react-fast-compare';
Expand Down Expand Up @@ -307,6 +306,7 @@ type ElRef = ElementRef<*>;

let instanceId = 1;


export default class Select extends Component<Props, State> {
static defaultProps = defaultProps;
state = {
Expand Down Expand Up @@ -1804,7 +1804,6 @@ export default class Select extends Component<Props, State> {

const { className, id, isDisabled, menuIsOpen } = this.props;
const { isFocused } = this.state;

const commonProps = (this.commonProps = this.getCommonProps());

return (
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/__snapshots__/Async.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-1pcexqc-container"
className="css-1pcexqc-container "
onKeyDown={[Function]}
>
<Control
Expand Down Expand Up @@ -264,7 +264,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-bg1rzq-control"
className="css-bg1rzq-control "
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
Expand Down Expand Up @@ -359,7 +359,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-1hwfws3"
className="css-1hwfws3 "
>
<Placeholder
clearValue={[Function]}
Expand Down Expand Up @@ -454,7 +454,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-151xaom-placeholder"
className="css-151xaom-placeholder "
>
Select...
</div>
Expand Down Expand Up @@ -736,7 +736,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-1wy0on6"
className="css-1wy0on6 "
>
<IndicatorSeparator
clearValue={[Function]}
Expand Down Expand Up @@ -830,7 +830,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<span
className="css-bgvzuu-indicatorSeparator"
className="css-bgvzuu-indicatorSeparator "
/>
</IndicatorSeparator>
<DropdownIndicator
Expand Down Expand Up @@ -933,7 +933,7 @@ exports[`defaults - snapshot 1`] = `
>
<div
aria-hidden="true"
className="css-16pqwjk-indicatorContainer"
className="css-16pqwjk-indicatorContainer "
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
Expand Down
14 changes: 7 additions & 7 deletions src/__tests__/__snapshots__/AsyncCreatable.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-1pcexqc-container"
className="css-1pcexqc-container "
onKeyDown={[Function]}
>
<Control
Expand Down Expand Up @@ -298,7 +298,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-bg1rzq-control"
className="css-bg1rzq-control "
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
Expand Down Expand Up @@ -398,7 +398,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-1hwfws3"
className="css-1hwfws3 "
>
<Placeholder
clearValue={[Function]}
Expand Down Expand Up @@ -498,7 +498,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-151xaom-placeholder"
className="css-151xaom-placeholder "
>
Select...
</div>
Expand Down Expand Up @@ -790,7 +790,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<div
className="css-1wy0on6"
className="css-1wy0on6 "
>
<IndicatorSeparator
clearValue={[Function]}
Expand Down Expand Up @@ -889,7 +889,7 @@ exports[`defaults - snapshot 1`] = `
}
>
<span
className="css-bgvzuu-indicatorSeparator"
className="css-bgvzuu-indicatorSeparator "
/>
</IndicatorSeparator>
<DropdownIndicator
Expand Down Expand Up @@ -997,7 +997,7 @@ exports[`defaults - snapshot 1`] = `
>
<div
aria-hidden="true"
className="css-16pqwjk-indicatorContainer"
className="css-16pqwjk-indicatorContainer "
onMouseDown={[Function]}
onTouchEnd={[Function]}
>
Expand Down
23 changes: 15 additions & 8 deletions src/components/Control.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// @flow
import React, { type Node, type ElementRef } from 'react';
import { css as emotionCSS } from 'emotion';
/** @jsx jsx */
import { type Node, type ElementRef } from 'react';
import { jsx } from '@emotion/core';

import type { CommonProps, PropsWithStyles } from '../types';

type State = {
Expand Down Expand Up @@ -58,12 +60,17 @@ const Control = (props: ControlProps) => {
return (
<div
ref={innerRef}
className={cx(emotionCSS(getStyles('control', props)), {
'control': true,
'control--is-disabled': isDisabled,
'control--is-focused': isFocused,
'control--menu-is-open': menuIsOpen
}, className)}
css={getStyles('control', props)}
className={cx(
null,
{
'control': true,
'control--is-disabled': isDisabled,
'control--is-focused': isFocused,
'control--menu-is-open': menuIsOpen
},
className
)}
{...innerProps}
>
{children}
Expand Down
Loading