diff --git a/.vscode/launch.json b/.vscode/launch.json index 3e2f26fa9..279055bd0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,6 +7,13 @@ "request": "attach", "port": 9222, "webRoot": "${workspaceRoot}" - } + }, + { + "type": "node", + "request": "launch", + "name": "Launch Current Jest Suite", + "program": "${workspaceFolder}/node_modules/.bin/jest", + "args": ["--runInBand", "${relativeFile}"] + } ] } diff --git a/docs/extending/styling-components.md b/docs/extending/styling-components.md index c02daa606..33ca641eb 100644 --- a/docs/extending/styling-components.md +++ b/docs/extending/styling-components.md @@ -12,13 +12,13 @@ For basic building blocks (views, texts, ...) you can use the styled object. ```javascript import {styled} from 'flipper'; -const MyView = styled('div')({ +const MyView = styled.div({ fontSize: 10, color: colors.red }); -const MyText = styled('span')({ ... }); -const MyImage = styled('img')({ ... }); -const MyInput = styled('input')({ ... }); +const MyText = styled.span({ ... }); +const MyImage = styled.img({ ... }); +const MyInput = styled.input({ ... }); ``` ## Extending Flipper Components @@ -46,7 +46,7 @@ The CSS-in-JS object passed to the styled components takes just any CSS rule, wi The style object can also be returned from a function for dynamic values. Props can be passed to the styled component using React. ```javascript -const MyView = styled('div')( +const MyView = styled.div( props => ({ fontSize: 10, color: => (props.disabled ? colors.red : colors.black), diff --git a/docs/tutorial/js-custom.md b/docs/tutorial/js-custom.md index ee57384ea..5d539b52c 100644 --- a/docs/tutorial/js-custom.md +++ b/docs/tutorial/js-custom.md @@ -120,7 +120,7 @@ class Card extends React.Component<{ cursor: 'pointer', })); - static Image = styled('div')({ + static Image = styled.div({ backgroundSize: 'cover', width: '100%', paddingTop: '100%', diff --git a/package.json b/package.json index e9b6be273..50421fa3b 100644 --- a/package.json +++ b/package.json @@ -108,6 +108,8 @@ "typescript": "^3.7.2" }, "dependencies": { + "@emotion/core": "^10.0.22", + "@emotion/styled": "^10.0.23", "@types/promise-retry": "^1.1.3", "@types/react-color": "^3.0.1", "@types/react-test-renderer": "^16.9.1", @@ -131,7 +133,7 @@ "deep-equal": "^1.0.1", "detect-port": "^1.1.1", "electron-devtools-installer": "^2.2.0", - "emotion": "^9.2.6", + "emotion": "^10.0.23", "expand-tilde": "^2.0.2", "express": "^4.15.2", "flipper-doctor": "^0.2.1", @@ -159,7 +161,6 @@ "react-debounce-render": "^5.0.0", "react-devtools-core": "^4.0.6", "react-dom": "^16.12.0", - "react-emotion": "^9.2.6", "react-markdown": "^4.2.2", "react-player": "^1.14.1", "react-redux": "^7.1.1", @@ -188,8 +189,6 @@ "ignore": [ "electron", "electron-builder", - "emotion", - "react-emotion", "tmp" ] }, diff --git a/src/NotificationsHub.tsx b/src/NotificationsHub.tsx index 25d0c3b4f..f43b5945b 100644 --- a/src/NotificationsHub.tsx +++ b/src/NotificationsHub.tsx @@ -319,7 +319,7 @@ type NotificationBoxProps = { severity: keyof typeof SEVERITY_COLOR_MAP; }; -const NotificationBox = styled(FlexRow)((props: NotificationBoxProps) => ({ +const NotificationBox = styled(FlexRow)(props => ({ backgroundColor: props.inactive ? 'transparent' : colors.white, opacity: props.inactive ? 0.5 : 1, alignItems: 'flex-start', @@ -348,7 +348,7 @@ const NotificationBox = styled(FlexRow)((props: NotificationBoxProps) => ({ }, })); -const Title = styled('div')({ +const Title = styled.div({ minWidth: 150, color: colors.light80, flexShrink: 0, @@ -358,8 +358,8 @@ const Title = styled('div')({ fontSize: '1.1em', }); -const NotificationContent = styled(FlexColumn)( - (props: {isSelected?: boolean}) => ({ +const NotificationContent = styled(FlexColumn)<{isSelected?: boolean}>( + props => ({ marginLeft: 6, marginRight: 10, flexGrow: 1, @@ -379,7 +379,7 @@ const Actions = styled(FlexRow)({ paddingTop: 8, }); -const NotificationButton = styled('div')({ +const NotificationButton = styled.div({ border: `1px solid ${colors.light20}`, color: colors.light50, borderRadius: 4, diff --git a/src/chrome/BugReporterDialog.tsx b/src/chrome/BugReporterDialog.tsx index 77cf60bf3..4767e7d48 100644 --- a/src/chrome/BugReporterDialog.tsx +++ b/src/chrome/BugReporterDialog.tsx @@ -44,7 +44,7 @@ const Center = styled(Text)({ paddingRight: 20, }); -const Title = styled('div')({ +const Title = styled.div({ fontWeight: 500, marginTop: 8, marginLeft: 2, @@ -66,7 +66,7 @@ const DescriptionTextarea = styled(Textarea)({ flexGrow: 1, }); -const SubmitButtonContainer = styled('div')({ +const SubmitButtonContainer = styled.div({ marginLeft: 'auto', }); @@ -118,8 +118,8 @@ class BugReporterDialog extends Component { error: null, }; - titleRef?: HTMLElement; - descriptionRef?: HTMLElement; + titleRef?: HTMLElement | null; + descriptionRef?: HTMLElement | null; onDescriptionChange = (e: React.ChangeEvent) => { this.setState({description: e.target.value}); @@ -184,11 +184,11 @@ class BugReporterDialog extends Component { ); }; - setTitleRef = (ref: HTMLElement) => { + setTitleRef = (ref: HTMLElement | null) => { this.titleRef = ref; }; - setDescriptionRef = (ref: HTMLElement) => { + setDescriptionRef = (ref: HTMLElement | null) => { this.descriptionRef = ref; }; @@ -240,7 +240,7 @@ class BugReporterDialog extends Component { @@ -248,7 +248,7 @@ class BugReporterDialog extends Component { diff --git a/src/chrome/DoctorBar.tsx b/src/chrome/DoctorBar.tsx index 272bcf007..5fb29738e 100644 --- a/src/chrome/DoctorBar.tsx +++ b/src/chrome/DoctorBar.tsx @@ -114,12 +114,12 @@ export default connect(null, { finishHealthchecks, })(DoctorBar); -const Container = styled('div')({ +const Container = styled.div({ boxShadow: '2px 2px 2px #ccc', userSelect: 'text', }); -const WarningContainer = styled('div')({ +const WarningContainer = styled.div({ backgroundColor: colors.orange, color: '#fff', maxHeight: '600px', diff --git a/src/chrome/ErrorBar.tsx b/src/chrome/ErrorBar.tsx index b39a43345..9d62bbae9 100644 --- a/src/chrome/ErrorBar.tsx +++ b/src/chrome/ErrorBar.tsx @@ -120,12 +120,12 @@ function ErrorTile({ ); } -const ErrorBarContainer = styled('div')({ +const ErrorBarContainer = styled.div({ boxShadow: '2px 2px 2px #ccc', userSelect: 'text', }); -const DismissAllErrors = styled('div')({ +const DismissAllErrors = styled.div({ boxShadow: '2px 2px 2px #ccc', backgroundColor: colors.cherryDark3, color: '#fff', @@ -143,12 +143,12 @@ const DismissAllErrors = styled('div')({ alignItems: 'center', }); -const ErrorDetails = styled('div')({ +const ErrorDetails = styled.div({ width: '100%', marginTop: 4, }); -const ErrorRows = styled('div')({ +const ErrorRows = styled.div({ backgroundColor: colors.cherry, color: '#fff', maxHeight: '600px', @@ -160,7 +160,7 @@ const ErrorRows = styled('div')({ }, }); -const ErrorRow = styled('div')({ +const ErrorRow = styled.div({ padding: '4px 12px', borderBottom: '1px solid ' + colors.cherryDark3, verticalAlign: 'middle', diff --git a/src/chrome/ListView.tsx b/src/chrome/ListView.tsx index a558b5928..d4c4eb671 100644 --- a/src/chrome/ListView.tsx +++ b/src/chrome/ListView.tsx @@ -66,24 +66,17 @@ const RowComponentContainer = styled(FlexColumn)({ maxHeight: 500, }); -const Padder = styled('div')( - ({ - paddingLeft, - paddingRight, - paddingBottom, - paddingTop, - }: { - paddingLeft?: number; - paddingRight?: number; - paddingBottom?: number; - paddingTop?: number; - }) => ({ - paddingLeft: paddingLeft || 0, - paddingRight: paddingRight || 0, - paddingBottom: paddingBottom || 0, - paddingTop: paddingTop || 0, - }), -); +const Padder = styled.div<{ + paddingLeft?: number; + paddingRight?: number; + paddingBottom?: number; + paddingTop?: number; +}>(({paddingLeft, paddingRight, paddingBottom, paddingTop}) => ({ + paddingLeft: paddingLeft || 0, + paddingRight: paddingRight || 0, + paddingBottom: paddingBottom || 0, + paddingTop: paddingTop || 0, +})); type RowComponentProps = { name: string; diff --git a/src/chrome/MainSidebar.tsx b/src/chrome/MainSidebar.tsx index 96f1ff702..f7f1f4f87 100644 --- a/src/chrome/MainSidebar.tsx +++ b/src/chrome/MainSidebar.tsx @@ -51,7 +51,6 @@ import {setActiveSheet} from '../reducers/application'; import UserAccount from './UserAccount'; import {connect} from 'react-redux'; import {BackgroundColorProperty} from 'csstype'; -import {StyledOtherComponent} from 'create-emotion-styled'; import SupportRequestFormManager from '../fb-stubs/SupportRequestFormManager'; import SupportRequestDetails from '../fb-stubs/SupportRequestDetails'; import SupportRequestFormV2 from '../fb-stubs/SupportRequestFormV2'; @@ -59,7 +58,7 @@ import SupportRequestFormV2 from '../fb-stubs/SupportRequestFormV2'; type FlipperPlugins = typeof FlipperPlugin[]; type PluginsByCategory = [string, FlipperPlugins][]; -const ListItem = styled('div')(({active}: {active?: boolean}) => ({ +const ListItem = styled.div<{active?: boolean}>(({active}) => ({ paddingLeft: 10, display: 'flex', alignItems: 'center', @@ -74,7 +73,7 @@ const ListItem = styled('div')(({active}: {active?: boolean}) => ({ }, })); -const SidebarButton = styled(Button)(({small}: {small?: boolean}) => ({ +const SidebarButton = styled(Button)<{small?: boolean}>(({small}) => ({ fontWeight: 'bold', fontSize: small ? 11 : 14, width: '100%', @@ -88,22 +87,22 @@ const SidebarButton = styled(Button)(({small}: {small?: boolean}) => ({ whiteSpace: 'nowrap', })); -const PluginShape = styled(FlexBox)( - ({backgroundColor}: {backgroundColor?: BackgroundColorProperty}) => ({ - marginRight: 8, - backgroundColor, - borderRadius: 3, - flexShrink: 0, - width: 18, - height: 18, - justifyContent: 'center', - alignItems: 'center', - top: '-1px', - }), -); +const PluginShape = styled(FlexBox)<{ + backgroundColor?: BackgroundColorProperty; +}>(({backgroundColor}) => ({ + marginRight: 8, + backgroundColor, + borderRadius: 3, + flexShrink: 0, + width: 18, + height: 18, + justifyContent: 'center', + alignItems: 'center', + top: '-1px', +})); -const PluginName = styled(Text)( - (props: {isActive?: boolean; count?: number}) => ({ +const PluginName = styled(Text)<{isActive?: boolean; count?: number}>( + props => ({ minWidth: 0, textOverflow: 'ellipsis', whiteSpace: 'nowrap', @@ -211,9 +210,7 @@ const Spinner = centerInSidebar(LoadingIndicator); const ErrorIndicator = centerInSidebar(Glyph); -function centerInSidebar( - component: StyledOtherComponent | React.ComponentType, -) { +function centerInSidebar(component: any) { return styled(component)({ marginTop: '10px', marginBottom: '10px', diff --git a/src/chrome/Popover.tsx b/src/chrome/Popover.tsx index b323a4a4c..75388c049 100644 --- a/src/chrome/Popover.tsx +++ b/src/chrome/Popover.tsx @@ -18,7 +18,7 @@ import { } from 'flipper'; import React, {PureComponent} from 'react'; -const Anchor = styled('img')({ +const Anchor = styled.img({ zIndex: 6, position: 'absolute', bottom: 0, @@ -100,13 +100,13 @@ const ItemImage = styled(FlexBox)({ flexShrink: 0, }); -const ItemContent = styled('div')({ +const ItemContent = styled.div({ minWidth: 0, paddingRight: 5, flexGrow: 1, }); -const Section = styled('div')({ +const Section = styled.div({ borderBottom: `1px solid ${colors.light05}`, '&:last-child': { borderBottom: 'none', @@ -142,7 +142,7 @@ type Props = { }; export default class Popover extends PureComponent { - _ref: Element | null | undefined; + _ref?: Element | null; componentDidMount() { window.document.addEventListener('click', this.handleClick); @@ -158,7 +158,7 @@ export default class Popover extends PureComponent { } }; - _setRef = (ref?: Element) => { + _setRef = (ref: Element | null) => { this._ref = ref; }; @@ -166,7 +166,7 @@ export default class Popover extends PureComponent { return ( <> - + {this.props.sections.map(section => { if (section.items.length > 0) { return ( diff --git a/src/chrome/RatingButton.tsx b/src/chrome/RatingButton.tsx index 873504624..4d45efcea 100644 --- a/src/chrome/RatingButton.tsx +++ b/src/chrome/RatingButton.tsx @@ -41,7 +41,7 @@ class PredefinedComment extends Component<{ selected: boolean; onClick: (_: unknown) => unknown; }> { - static Container = styled('div')((props: {selected: boolean}) => { + static Container = styled.div<{selected: boolean}>(props => { return { border: '1px solid #f2f3f5', cursor: 'pointer', @@ -82,7 +82,7 @@ const DismissRow = styled(Row)({ marginTop: 10, }); -const DismissButton = styled('span')({ +const DismissButton = styled.span({ '&:hover': { textDecoration: 'underline', cursor: 'pointer', diff --git a/src/chrome/Sheet.tsx b/src/chrome/Sheet.tsx index 9fdebefad..da65758c3 100644 --- a/src/chrome/Sheet.tsx +++ b/src/chrome/Sheet.tsx @@ -19,7 +19,7 @@ import {State as Store} from '../reducers'; import {ActiveSheet} from '../reducers/application'; -const DialogContainer = styled('div')(({state}: {state: TransitionStatus}) => ({ +const DialogContainer = styled.div<{state: TransitionStatus}>(({state}) => ({ transform: `translate(-50%, ${ state === 'entering' || state === 'exiting' || state === 'exited' ? 'calc(-100% - 20px)' diff --git a/src/chrome/TitleBar.tsx b/src/chrome/TitleBar.tsx index 305086e4b..6cd7fbf6d 100644 --- a/src/chrome/TitleBar.tsx +++ b/src/chrome/TitleBar.tsx @@ -43,7 +43,7 @@ import {clipboard} from 'electron'; import React from 'react'; import {State} from 'src/reducers'; -const AppTitleBar = styled(FlexRow)(({focused}: {focused?: boolean}) => ({ +const AppTitleBar = styled(FlexRow)<{focused?: boolean}>(({focused}) => ({ background: focused ? `linear-gradient(to bottom, ${colors.macOSTitleBarBackgroundTop} 0%, ${colors.macOSTitleBarBackgroundBottom} 100%)` : colors.macOSTitleBarBackgroundBlur, diff --git a/src/chrome/UserAccount.tsx b/src/chrome/UserAccount.tsx index 72726d5bd..965c8a3ed 100644 --- a/src/chrome/UserAccount.tsx +++ b/src/chrome/UserAccount.tsx @@ -28,7 +28,7 @@ const Container = styled(FlexRow)({ color: colors.blackAlpha80, }); -const ProfilePic = styled('img')({ +const ProfilePic = styled.img({ borderRadius: '999em', flexShrink: 0, width: 24, @@ -58,7 +58,7 @@ type Props = OwnProps & DispatchFromProps & StateFromProps; class UserAccount extends PureComponent { _ref: Element | null | undefined; - setRef = (ref: React.ReactInstance) => { + setRef = (ref: HTMLDivElement | null) => { const element = findDOMNode(ref); if (element instanceof HTMLElement) { this._ref = element; @@ -90,7 +90,7 @@ class UserAccount extends PureComponent { const {user} = this.props; const name = user ? user.name : null; return name ? ( - + diff --git a/src/chrome/WelcomeScreen.tsx b/src/chrome/WelcomeScreen.tsx index 79bb0021b..5969bdae2 100644 --- a/src/chrome/WelcomeScreen.tsx +++ b/src/chrome/WelcomeScreen.tsx @@ -29,7 +29,7 @@ const Container = styled(FlexColumn)({ backgroundColor: colors.light02, }); -const Welcome = styled(FlexColumn)(({isMounted}: {isMounted?: boolean}) => ({ +const Welcome = styled(FlexColumn)<{isMounted?: boolean}>(({isMounted}) => ({ width: 460, background: colors.white, borderRadius: 10, @@ -85,7 +85,7 @@ const Icon = styled(Glyph)({ marginLeft: 6, }); -const Logo = styled('img')({ +const Logo = styled.img({ width: 128, height: 128, alignSelf: 'center', diff --git a/src/chrome/__tests__/__snapshots__/ShareSheetPendingDialog.node.tsx.snap b/src/chrome/__tests__/__snapshots__/ShareSheetPendingDialog.node.tsx.snap index fde290a3f..488a6aa79 100644 --- a/src/chrome/__tests__/__snapshots__/ShareSheetPendingDialog.node.tsx.snap +++ b/src/chrome/__tests__/__snapshots__/ShareSheetPendingDialog.node.tsx.snap @@ -17,7 +17,7 @@ exports[`ShareSheetPendingDialog is rendered with status update 1`] = ` size={30} /> Update @@ -30,7 +30,7 @@ exports[`ShareSheetPendingDialog is rendered with status update 1`] = ` className="css-12zzrdt" />
wubba lubba dub dub @@ -80,7 +80,7 @@ exports[`ShareSheetPendingDialog is rendered without status update 1`] = ` className="css-12zzrdt" />
({ +const FileInputBox = styled(Input)<{isValid: boolean}>(({isValid}) => ({ marginRight: 0, flexGrow: 1, fontFamily: 'monospace', @@ -38,7 +38,7 @@ const CenteredGlyph = styled(Glyph)({ marginLeft: 10, }); -const GreyedOutOverlay = styled('div')({ +const GreyedOutOverlay = styled.div({ backgroundColor: '#EFEEEF', borderRadius: 4, opacity: 0.6, diff --git a/src/index.tsx b/src/index.tsx index ff07556a4..2e7660a05 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -7,7 +7,8 @@ * @format */ -export {default as styled, keyframes} from 'react-emotion'; +export {default as styled} from '@emotion/styled'; +export {keyframes} from 'emotion'; export * from './ui/index'; export {getStringFromErrorLike, textContent} from './utils/index'; export {serialize, deserialize} from './utils/serialization'; diff --git a/src/init.tsx b/src/init.tsx index b65cc86a9..c8075ef73 100644 --- a/src/init.tsx +++ b/src/init.tsx @@ -31,6 +31,8 @@ import React from 'react'; import path from 'path'; import {store} from './store'; import {registerRecordingHooks} from './utils/pluginStateRecorder'; +import {cache} from 'emotion'; +import {CacheProvider} from '@emotion/core'; const logger = initLogger(store); const bugReporter = new BugReporter(logger, store); @@ -51,15 +53,17 @@ const AppFrame = () => { - {warnEmployee ? ( - { - setWarnEmployee(false); - }} - /> - ) : ( - - )} + + {warnEmployee ? ( + { + setWarnEmployee(false); + }} + /> + ) : ( + + )} + diff --git a/src/plugins/TableNativePlugin.tsx b/src/plugins/TableNativePlugin.tsx index 3b3226259..7ef2b4a9f 100644 --- a/src/plugins/TableNativePlugin.tsx +++ b/src/plugins/TableNativePlugin.tsx @@ -10,7 +10,7 @@ import ManagedDataInspector from '../ui/components/data-inspector/ManagedDataInspector'; import Panel from '../ui/components/Panel'; import {colors} from '../ui/components/colors'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import Text from '../ui/components/Text'; import Toolbar from '../ui/components/Toolbar'; import Spacer from '../ui/components/Toolbar'; @@ -98,7 +98,7 @@ const NonWrappingText = styled(Text)({ userSelect: 'none', }); -const BooleanValue = styled(NonWrappingText)((props: {active?: boolean}) => ({ +const BooleanValue = styled(NonWrappingText)<{active?: boolean}>(props => ({ '&::before': { content: '""', display: 'inline-block', @@ -111,7 +111,7 @@ const BooleanValue = styled(NonWrappingText)((props: {active?: boolean}) => ({ }, })); -const Label = styled('span')({ +const Label = styled.span({ fontSize: 12, color: '#90949c', fontWeight: 'bold', diff --git a/src/plugins/cpu/index.tsx b/src/plugins/cpu/index.tsx index 832ed6901..e3d1e3d22 100644 --- a/src/plugins/cpu/index.tsx +++ b/src/plugins/cpu/index.tsx @@ -95,7 +95,7 @@ const Columns = { }, }; -const Heading = styled('div')({ +const Heading = styled.div({ fontWeight: 'bold', fontSize: 13, display: 'block', diff --git a/src/plugins/crash_reporter/index.js b/src/plugins/crash_reporter/index.js index e848cc674..2db1e5386 100644 --- a/src/plugins/crash_reporter/index.js +++ b/src/plugins/crash_reporter/index.js @@ -79,7 +79,7 @@ type State = { crash: ?Crash, }; -const Padder = styled('div')( +const Padder = styled.div( ({paddingLeft, paddingRight, paddingBottom, paddingTop}) => ({ paddingLeft: paddingLeft || 0, paddingRight: paddingRight || 0, diff --git a/src/plugins/databases/index.js b/src/plugins/databases/index.js index 6b2bc5d87..53cada576 100644 --- a/src/plugins/databases/index.js +++ b/src/plugins/databases/index.js @@ -38,13 +38,13 @@ import dateFormat from 'dateformat'; const PAGE_SIZE = 50; -const BoldSpan = styled('span')({ +const BoldSpan = styled.span({ fontSize: 12, color: '#90949c', fontWeight: 'bold', textTransform: 'uppercase', }); -const ErrorBar = styled('div')({ +const ErrorBar = styled.div({ backgroundColor: colors.cherry, color: colors.white, lineHeight: '26px', diff --git a/src/plugins/fresco/ImagesCacheOverview.tsx b/src/plugins/fresco/ImagesCacheOverview.tsx index e65b7ed2a..7ecf232b5 100644 --- a/src/plugins/fresco/ImagesCacheOverview.tsx +++ b/src/plugins/fresco/ImagesCacheOverview.tsx @@ -288,7 +288,7 @@ class ImageGrid extends PureComponent<{ size: number; events: Array; }> { - static Content = styled('div')({ + static Content = styled.div({ paddingLeft: 15, }); @@ -348,12 +348,12 @@ class ImageGridHeader extends PureComponent<{ zIndex: 3, }); - static Heading = styled('span')({ + static Heading = styled.span({ fontSize: 22, fontWeight: 600, }); - static Subtitle = styled('span')({ + static Subtitle = styled.span({ fontSize: 22, fontWeight: 300, marginLeft: 15, @@ -392,7 +392,7 @@ class ImageItem extends PureComponent<{ size: number; numberOfRequests: number; }> { - static Container = styled(FlexBox)((props: {size: number}) => ({ + static Container = styled(FlexBox)<{size: number}>(props => ({ float: 'left', alignItems: 'center', justifyContent: 'center', @@ -405,18 +405,18 @@ class ImageItem extends PureComponent<{ backgroundColor: colors.light02, })); - static Image = styled('img')({ + static Image = styled.img({ borderRadius: 4, maxHeight: '100%', maxWidth: '100%', objectFit: 'contain', }); - static Loading = styled('span')({ + static Loading = styled.span({ padding: '0 0', }); - static SelectedHighlight = styled('div')((props: {selected: boolean}) => ({ + static SelectedHighlight = styled.div<{selected: boolean}>(props => ({ borderColor: colors.highlight, borderStyle: 'solid', borderWidth: props.selected ? 3 : 0, @@ -429,8 +429,8 @@ class ImageItem extends PureComponent<{ top: 0, })); - static HoverOverlay = styled(FlexColumn)( - (props: {selected: boolean; size: number}) => ({ + static HoverOverlay = styled(FlexColumn)<{selected: boolean; size: number}>( + props => ({ alignItems: 'center', backgroundColor: colors.whiteAlpha80, bottom: props.selected ? 4 : 0, @@ -449,16 +449,16 @@ class ImageItem extends PureComponent<{ }), ); - static MemoryLabel = styled('span')({ + static MemoryLabel = styled.span({ fontWeight: 600, marginBottom: 6, }); - static SizeLabel = styled('span')({ + static SizeLabel = styled.span({ fontWeight: 300, }); - static Events = styled('div')({ + static Events = styled.div({ position: 'absolute', top: -5, right: -5, diff --git a/src/plugins/fresco/ImagesSidebar.tsx b/src/plugins/fresco/ImagesSidebar.tsx index 4603fb25f..26e52ef5a 100644 --- a/src/plugins/fresco/ImagesSidebar.tsx +++ b/src/plugins/fresco/ImagesSidebar.tsx @@ -29,7 +29,7 @@ type ImagesSidebarProps = { type ImagesSidebarState = {}; -const DataDescriptionKey = styled('span')({ +const DataDescriptionKey = styled.span({ color: colors.grapeDark1, }); diff --git a/src/plugins/fresco/MultipleSelect.tsx b/src/plugins/fresco/MultipleSelect.tsx index ab3f0e2d0..46cb5e835 100644 --- a/src/plugins/fresco/MultipleSelect.tsx +++ b/src/plugins/fresco/MultipleSelect.tsx @@ -15,7 +15,7 @@ const Container = styled(Block)({ marginLeft: '10px', }); -const List = styled(FlexColumn)((props: {visibleList: boolean}) => ({ +const List = styled(FlexColumn)<{visibleList: boolean}>(props => ({ display: props.visibleList ? 'flex' : 'none', position: 'absolute', top: '32px', @@ -30,7 +30,7 @@ const List = styled(FlexColumn)((props: {visibleList: boolean}) => ({ borderRadius: 4, })); -const ListItem = styled('label')({ +const ListItem = styled.label({ cursor: 'pointer', display: 'flex', alignItems: 'center', @@ -43,7 +43,7 @@ const ListItem = styled('label')({ }, }); -const Checkbox = styled('input')({ +const Checkbox = styled.input({ display: 'inline-block', marginRight: 5, verticalAlign: 'middle', diff --git a/src/plugins/fresco/__tests__/__snapshots__/index.node.tsx.snap b/src/plugins/fresco/__tests__/__snapshots__/index.node.tsx.snap index ed6cc0b24..29cf1dd38 100644 --- a/src/plugins/fresco/__tests__/__snapshots__/index.node.tsx.snap +++ b/src/plugins/fresco/__tests__/__snapshots__/index.node.tsx.snap @@ -2,31 +2,31 @@ exports[`notifications for leaks 1`] = ` - + CloseableReference leaked for - com.facebook.imagepipeline.memory.NativeMemoryChunk - + (identity hashcode: deadbeef ). - - - + + Stacktrace: - - - - + + + <unavailable> - - + + `; diff --git a/src/plugins/layout/ToolbarIcon.tsx b/src/plugins/layout/ToolbarIcon.tsx index 7bc55e67f..e20d1169e 100644 --- a/src/plugins/layout/ToolbarIcon.tsx +++ b/src/plugins/layout/ToolbarIcon.tsx @@ -17,7 +17,7 @@ type Props = { onClick: () => void; }; -const ToolbarIcon = styled('div')({ +const ToolbarIcon = styled.div({ marginRight: 9, marginTop: -3, marginLeft: 4, diff --git a/src/plugins/logs/index.tsx b/src/plugins/logs/index.tsx index afafe17cb..dc7cdcb00 100644 --- a/src/plugins/logs/index.tsx +++ b/src/plugins/logs/index.tsx @@ -229,24 +229,22 @@ const HiddenScrollText = styled(Text)({ }, }); -const LogCount = styled('div')( - ({backgroundColor}: {backgroundColor: string}) => ({ - backgroundColor, - borderRadius: '999em', - fontSize: 11, - marginTop: 4, - minWidth: 16, - height: 16, - color: colors.white, - textAlign: 'center', - lineHeight: '16px', - paddingLeft: 4, - paddingRight: 4, - textOverflow: 'ellipsis', - overflow: 'hidden', - whiteSpace: 'nowrap', - }), -); +const LogCount = styled.div<{backgroundColor: string}>(({backgroundColor}) => ({ + backgroundColor, + borderRadius: '999em', + fontSize: 11, + marginTop: 4, + minWidth: 16, + height: 16, + color: colors.white, + textAlign: 'center', + lineHeight: '16px', + paddingLeft: 4, + paddingRight: 4, + textOverflow: 'ellipsis', + overflow: 'hidden', + whiteSpace: 'nowrap', +})); function pad(chunk: any, len: number): string { let str = String(chunk); diff --git a/src/plugins/navigation/components/AutoCompleteSheet.tsx b/src/plugins/navigation/components/AutoCompleteSheet.tsx index ac58dc145..83e2aaa2e 100644 --- a/src/plugins/navigation/components/AutoCompleteSheet.tsx +++ b/src/plugins/navigation/components/AutoCompleteSheet.tsx @@ -22,7 +22,7 @@ type Props = { const MAX_ITEMS = 5; -const AutoCompleteSheetContainer = styled('div')({ +const AutoCompleteSheetContainer = styled.div({ width: '100%', position: 'absolute', top: 'calc(100% - 3px)', @@ -33,7 +33,7 @@ const AutoCompleteSheetContainer = styled('div')({ boxShadow: '0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)', }); -const SheetItem = styled('div')({ +const SheetItem = styled.div({ padding: 5, textOverflow: 'ellipsis', overflowX: 'hidden', @@ -46,7 +46,7 @@ const SheetItem = styled('div')({ }, }); -const SheetItemIcon = styled('span')({ +const SheetItemIcon = styled.span({ padding: 8, }); diff --git a/src/plugins/navigation/components/BookmarksSidebar.tsx b/src/plugins/navigation/components/BookmarksSidebar.tsx index 9a4c09383..792c3b17b 100644 --- a/src/plugins/navigation/components/BookmarksSidebar.tsx +++ b/src/plugins/navigation/components/BookmarksSidebar.tsx @@ -32,7 +32,7 @@ const NoData = styled(FlexCenter)({ color: colors.macOSTitleBarIcon, }); -const BookmarksList = styled('div')({ +const BookmarksList = styled.div({ overflowY: 'scroll', overflowX: 'hidden', height: '100%', diff --git a/src/plugins/navigation/components/FavoriteButton.tsx b/src/plugins/navigation/components/FavoriteButton.tsx index c05686639..22e11499e 100644 --- a/src/plugins/navigation/components/FavoriteButton.tsx +++ b/src/plugins/navigation/components/FavoriteButton.tsx @@ -17,7 +17,7 @@ type Props = { size: IconSize; }; -const FavoriteButtonContainer = styled('div')({ +const FavoriteButtonContainer = styled.div({ position: 'relative', '>:first-child': { position: 'absolute', diff --git a/src/plugins/navigation/components/IconButton.tsx b/src/plugins/navigation/components/IconButton.tsx index ac633c8db..16ba25f4c 100644 --- a/src/plugins/navigation/components/IconButton.tsx +++ b/src/plugins/navigation/components/IconButton.tsx @@ -27,7 +27,7 @@ type Props = { size: IconSize; }; -const RippleEffect = styled('div')({ +const RippleEffect = styled.div({ padding: 5, borderRadius: 100, backgroundPosition: 'center', @@ -43,7 +43,7 @@ const RippleEffect = styled('div')({ }, }); -const IconButton = styled('div')({ +const IconButton = styled.div({ ':active': { animation: `${shrinkAnimation} .25s ease forwards`, }, diff --git a/src/plugins/navigation/components/NavigationInfoBox.tsx b/src/plugins/navigation/components/NavigationInfoBox.tsx index 43a596708..777bf69e4 100644 --- a/src/plugins/navigation/components/NavigationInfoBox.tsx +++ b/src/plugins/navigation/components/NavigationInfoBox.tsx @@ -32,7 +32,7 @@ type Props = { date: Date | null; }; -const ScreenshotContainer = styled('div')({ +const ScreenshotContainer = styled.div({ width: 200, minWidth: 200, overflow: 'hidden', @@ -45,19 +45,19 @@ const ScreenshotContainer = styled('div')({ }, }); -const NoData = styled('div')({ +const NoData = styled.div({ color: colors.light30, fontSize: 14, position: 'relative', }); -const NavigationDataContainer = styled('div')({ +const NavigationDataContainer = styled.div({ alignItems: 'flex-start', flexGrow: 1, position: 'relative', }); -const Footer = styled('div')({ +const Footer = styled.div({ width: '100%', padding: '10px', borderTop: `1px ${colors.blueGreyTint90} solid`, @@ -65,16 +65,16 @@ const Footer = styled('div')({ alignItems: 'center', }); -const Seperator = styled('div')({ +const Seperator = styled.div({ flexGrow: 1, }); -const TimeContainer = styled('div')({ +const TimeContainer = styled.div({ color: colors.light30, fontSize: 14, }); -const NavigationInfoBoxContainer = styled('div')({ +const NavigationInfoBoxContainer = styled.div({ display: 'flex', height: BOX_HEIGHT, borderRadius: 10, @@ -85,7 +85,7 @@ const NavigationInfoBoxContainer = styled('div')({ boxShadow: '1px 1px 5px rgba(0,0,0,0.1)', }); -const Header = styled('div')({ +const Header = styled.div({ fontSize: 18, fontWeight: 500, userSelect: 'text', @@ -95,11 +95,11 @@ const Header = styled('div')({ display: 'flex', }); -const ClassNameContainer = styled('div')({ +const ClassNameContainer = styled.div({ color: colors.light30, }); -const ParametersContainer = styled('div')({ +const ParametersContainer = styled.div({ height: 150, '&>*': { height: 150, @@ -112,7 +112,7 @@ const NoParamters = styled(FlexCenter)({ color: colors.light10, }); -const TimelineCircle = styled('div')({ +const TimelineCircle = styled.div({ width: 18, height: 18, top: 11, @@ -123,7 +123,7 @@ const TimelineCircle = styled('div')({ position: 'absolute', }); -const TimelineMiniCircle = styled('div')({ +const TimelineMiniCircle = styled.div({ width: 12, height: 12, top: 1, diff --git a/src/plugins/navigation/components/RequiredParametersDialog.tsx b/src/plugins/navigation/components/RequiredParametersDialog.tsx index e5378562a..ccffe4cc5 100644 --- a/src/plugins/navigation/components/RequiredParametersDialog.tsx +++ b/src/plugins/navigation/components/RequiredParametersDialog.tsx @@ -33,23 +33,23 @@ const Container = styled(FlexColumn)({ width: 600, }); -const Title = styled('span')({ +const Title = styled.span({ display: 'flex', marginTop: 8, marginLeft: 2, marginBottom: 8, }); -const Text = styled('span')({ +const Text = styled.span({ lineHeight: 1.3, }); -const ErrorLabel = styled('span')({ +const ErrorLabel = styled.span({ color: colors.yellow, lineHeight: 1.4, }); -const URIContainer = styled('div')({ +const URIContainer = styled.div({ lineHeight: 1.3, marginLeft: 2, marginBottom: 8, @@ -57,7 +57,7 @@ const URIContainer = styled('div')({ overflowWrap: 'break-word', }); -const ButtonContainer = styled('div')({ +const ButtonContainer = styled.div({ marginLeft: 'auto', }); @@ -68,7 +68,7 @@ const RequiredParameterInput = styled(Input)({ width: '100%', }); -const WarningIconContainer = styled('span')({ +const WarningIconContainer = styled.span({ marginRight: 8, }); diff --git a/src/plugins/navigation/components/SaveBookmarkDialog.tsx b/src/plugins/navigation/components/SaveBookmarkDialog.tsx index 2a744683e..830097c2a 100644 --- a/src/plugins/navigation/components/SaveBookmarkDialog.tsx +++ b/src/plugins/navigation/components/SaveBookmarkDialog.tsx @@ -25,20 +25,20 @@ const Container = styled(FlexColumn)({ width: 400, }); -const Title = styled('div')({ +const Title = styled.div({ fontWeight: 500, marginTop: 8, marginLeft: 2, marginBottom: 8, }); -const URIContainer = styled('div')({ +const URIContainer = styled.div({ marginLeft: 2, marginBottom: 8, overflowWrap: 'break-word', }); -const ButtonContainer = styled('div')({ +const ButtonContainer = styled.div({ marginLeft: 'auto', }); diff --git a/src/plugins/navigation/components/SearchBar.tsx b/src/plugins/navigation/components/SearchBar.tsx index 0e0824517..4343123cf 100644 --- a/src/plugins/navigation/components/SearchBar.tsx +++ b/src/plugins/navigation/components/SearchBar.tsx @@ -28,7 +28,7 @@ type State = { prevURIFromAbove: URI; }; -const IconContainer = styled('div')({ +const IconContainer = styled.div({ display: 'inline-flex', height: '16px', alignItems: 'center', @@ -44,13 +44,13 @@ const IconContainer = styled('div')({ }, }); -const ToolbarContainer = styled('div')({ +const ToolbarContainer = styled.div({ '.drop-shadow': { boxShadow: '0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)', }, }); -const SearchInputContainer = styled('div')({ +const SearchInputContainer = styled.div({ width: '100%', marginLeft: 5, marginRight: 9, diff --git a/src/plugins/navigation/components/Timeline.tsx b/src/plugins/navigation/components/Timeline.tsx index d024a271d..aba7bd039 100644 --- a/src/plugins/navigation/components/Timeline.tsx +++ b/src/plugins/navigation/components/Timeline.tsx @@ -19,7 +19,7 @@ type Props = { onFavorite: (uri: URI) => void; }; -const TimelineLine = styled('div')({ +const TimelineLine = styled.div({ width: 2, backgroundColor: colors.highlight, position: 'absolute', @@ -27,7 +27,7 @@ const TimelineLine = styled('div')({ bottom: 0, }); -const TimelineContainer = styled('div')({ +const TimelineContainer = styled.div({ position: 'relative', paddingLeft: 25, overflowY: 'scroll', @@ -43,7 +43,7 @@ const TimelineContainer = styled('div')({ }, }); -const NavigationEventContainer = styled('div')({ +const NavigationEventContainer = styled.div({ display: 'flex', paddingTop: 25, paddingLeft: 25, @@ -63,7 +63,7 @@ export default (props: Props) => { return events.length === 0 ? ( No Navigation Events to Show ) : ( - +
{events.map((event: NavigationEvent, idx: number) => { diff --git a/src/plugins/network/RequestDetails.tsx b/src/plugins/network/RequestDetails.tsx index 3fc76224c..573e19399 100644 --- a/src/plugins/network/RequestDetails.tsx +++ b/src/plugins/network/RequestDetails.tsx @@ -295,7 +295,7 @@ class HeaderInspector extends Component< } } -const BodyContainer = styled('div')({ +const BodyContainer = styled.div({ paddingTop: 10, paddingBottom: 20, }); @@ -382,7 +382,7 @@ type ImageWithSizeState = { }; class ImageWithSize extends Component { - static Image = styled('img')({ + static Image = styled.img({ objectFit: 'scale-down', maxWidth: '100%', marginBottom: 10, @@ -435,7 +435,7 @@ class ImageFormatter { } class VideoFormatter { - static Video = styled('video')({ + static Video = styled.video({ maxWidth: 500, maxHeight: 500, }); diff --git a/src/plugins/reactdevtools/index.tsx b/src/plugins/reactdevtools/index.tsx index b6a9eeb66..ad0a0f4f6 100644 --- a/src/plugins/reactdevtools/index.tsx +++ b/src/plugins/reactdevtools/index.tsx @@ -14,7 +14,7 @@ import React from 'react'; import getPort from 'get-port'; import address from 'address'; -const Container = styled('div')({ +const Container = styled.div({ display: 'flex', flex: '1 1 0%', justifyContent: 'center', diff --git a/src/plugins/sandbox/index.tsx b/src/plugins/sandbox/index.tsx index 993367047..b5a234de6 100644 --- a/src/plugins/sandbox/index.tsx +++ b/src/plugins/sandbox/index.tsx @@ -45,7 +45,7 @@ export default class SandboxView extends FlipperPlugin< showFeedback: false, }; - static TextInput = styled('input')({ + static TextInput = styled.input({ border: `1px solid ${colors.light10}`, fontSize: '1em', padding: '0 5px', @@ -55,7 +55,7 @@ export default class SandboxView extends FlipperPlugin< flexGrow: 1, }); - static FeedbackMessage = styled('span')({ + static FeedbackMessage = styled.span({ fontSize: '1.2em', paddingTop: '10px', color: 'green', diff --git a/src/plugins/seamammals/index.tsx b/src/plugins/seamammals/index.tsx index 377df4f27..675671301 100644 --- a/src/plugins/seamammals/index.tsx +++ b/src/plugins/seamammals/index.tsx @@ -105,7 +105,7 @@ class Card extends React.Component< selected: boolean; } & Row > { - static Container = styled(FlexColumn)((props: {selected?: boolean}) => ({ + static Container = styled(FlexColumn)<{selected?: boolean}>(props => ({ margin: 10, borderRadius: 5, border: '2px solid black', @@ -120,7 +120,7 @@ class Card extends React.Component< cursor: 'pointer', })); - static Image = styled('div')({ + static Image = styled.div({ backgroundSize: 'cover', width: '100%', paddingTop: '100%', diff --git a/src/plugins/sections/EventsTable.js b/src/plugins/sections/EventsTable.js index 2105e75e3..2bd46b636 100644 --- a/src/plugins/sections/EventsTable.js +++ b/src/plugins/sections/EventsTable.js @@ -73,7 +73,7 @@ const Row = styled(FlexRow)(props => ({ }, })); -const Label = styled('div')({ +const Label = styled.div({ width: LABEL_WIDTH, paddingLeft: 10, paddingRight: 10, @@ -88,7 +88,7 @@ const Label = styled('div')({ zIndex: 2, }); -const Content = styled('div')({ +const Content = styled.div({ textOverflow: 'ellipsis', overflow: 'hidden', fontSize: 11, @@ -98,7 +98,7 @@ const Content = styled('div')({ color: colors.light50, }); -const Record = styled('div')(({highlighted}) => ({ +const Record = styled.div(({highlighted}) => ({ border: `1px solid ${colors.light15}`, boxShadow: highlighted ? `inset 0 0 0 2px ${colors.macOSTitleBarIconSelected}` @@ -116,7 +116,7 @@ const Record = styled('div')(({highlighted}) => ({ alignItems: 'center', })); -const Empty = styled('div')({ +const Empty = styled.div({ width: WIDTH, padding: '10px 5px', marginRight: PADDING, diff --git a/src/plugins/sections/Tree.js b/src/plugins/sections/Tree.js index 9dd7e15ee..3c1da6770 100644 --- a/src/plugins/sections/Tree.js +++ b/src/plugins/sections/Tree.js @@ -13,7 +13,7 @@ import {Glyph, PureComponent, styled, Toolbar, Spacer, colors} from 'flipper'; import {Tree} from 'react-d3-tree'; import {Fragment} from 'react'; -const Legend = styled('div')(props => ({ +const Legend = styled.div(props => ({ color: colors.dark50, marginLeft: 20, '&::before': { @@ -29,7 +29,7 @@ const Legend = styled('div')(props => ({ }, })); -const Label = styled('div')({ +const Label = styled.div({ position: 'relative', top: -7, left: 7, @@ -43,7 +43,7 @@ const Label = styled('div')({ display: 'inline-block', }); -const Container = styled('div')({ +const Container = styled.div({ width: '100%', height: '100%', overflow: 'hidden', @@ -53,11 +53,11 @@ const Container = styled('div')({ '10px 10px,10px 10px,100px 100px,100px 100px,100px 100px,100px 100px,100px 100px,100px 100px', }); -const LabelContainer = styled('div')({ +const LabelContainer = styled.div({ display: 'flex', }); -const IconButton = styled('div')({ +const IconButton = styled.div({ position: 'relative', left: 5, top: -8, diff --git a/src/plugins/sections/index.js b/src/plugins/sections/index.js index 436850ebb..cdbcdccec 100644 --- a/src/plugins/sections/index.js +++ b/src/plugins/sections/index.js @@ -45,14 +45,14 @@ const Waiting = styled(FlexBox)(props => ({ textAlign: 'center', })); -const InfoText = styled('div')(props => ({ +const InfoText = styled.div(props => ({ marginTop: 10, marginBottom: 10, fontWeight: '500', color: colors.light30, })); -const InfoBox = styled('div')(props => ({ +const InfoBox = styled.div(props => ({ maxWidth: 400, margin: 'auto', textAlign: 'center', diff --git a/src/ui/components/Block.tsx b/src/ui/components/Block.tsx index 93c8844be..d7e38013f 100644 --- a/src/ui/components/Block.tsx +++ b/src/ui/components/Block.tsx @@ -7,12 +7,12 @@ * @format */ -import styled from 'react-emotion'; +import styled from '@emotion/styled'; /** * A Block styled div */ -const Block = styled('div')({ +const Block = styled.div({ display: 'block', }); Block.displayName = 'Block'; diff --git a/src/ui/components/Bordered.tsx b/src/ui/components/Bordered.tsx index 29d276d21..3aef905a4 100644 --- a/src/ui/components/Bordered.tsx +++ b/src/ui/components/Bordered.tsx @@ -7,13 +7,13 @@ * @format */ -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import {colors} from './colors'; /** * Puts a gray border around something */ -const Bordered = styled('div')({ +const Bordered = styled.div({ borderRadius: 4, overflow: 'hidden', border: `1px solid ${colors.macOSTitleBarButtonBorder}`, diff --git a/src/ui/components/Box.tsx b/src/ui/components/Box.tsx index dd274f19f..b5794441d 100644 --- a/src/ui/components/Box.tsx +++ b/src/ui/components/Box.tsx @@ -8,7 +8,7 @@ */ import FlexBox from './FlexBox'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; const Box = styled(FlexBox)({ height: '100%', diff --git a/src/ui/components/Button.tsx b/src/ui/components/Button.tsx index 3d1d45b35..d7b8f960f 100644 --- a/src/ui/components/Button.tsx +++ b/src/ui/components/Button.tsx @@ -10,11 +10,11 @@ import React from 'react'; import PropTypes from 'prop-types'; import electron, {MenuItemConstructorOptions} from 'electron'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import {colors} from './colors'; import {connect} from 'react-redux'; import {findDOMNode} from 'react-dom'; -import {keyframes} from 'react-emotion'; +import {keyframes} from 'emotion'; import {State as Store} from '../../reducers/index'; import Glyph, {IconSize} from './Glyph'; @@ -106,88 +106,85 @@ const pulse = keyframes({ }, }); -const StyledButton = styled('div')( - (props: { - windowIsFocused?: boolean; - compact?: boolean; - inButtonGroup?: boolean; - padded?: boolean; - pulse?: boolean; - disabled?: boolean; - dropdown?: Array; - }) => ({ - backgroundColor: - props.windowIsFocused && !props.disabled - ? colors.white - : colors.macOSTitleBarButtonBackgroundBlur, - backgroundImage: backgroundImage(props), - borderStyle: 'solid', - borderWidth: 1, +const StyledButton = styled.div<{ + windowIsFocused?: boolean; + compact?: boolean; + inButtonGroup?: boolean; + padded?: boolean; + pulse?: boolean; + disabled?: boolean; + dropdown?: Array; +}>(props => ({ + backgroundColor: + props.windowIsFocused && !props.disabled + ? colors.white + : colors.macOSTitleBarButtonBackgroundBlur, + backgroundImage: backgroundImage(props), + borderStyle: 'solid', + borderWidth: 1, + borderColor: borderColor(props), + borderBottomColor: borderBottomColor(props), + color: color(props), + borderRadius: 4, + position: 'relative', + padding: props.padded ? '0 15px' : '0 6px', + height: props.compact === true ? 24 : 28, + margin: 0, + minWidth: 34, + display: 'inline-flex', + alignItems: 'center', + justifyContent: 'center', + flexShrink: 0, + + boxShadow: + props.pulse && props.windowIsFocused + ? `0 0 0 ${colors.macOSTitleBarIconSelected}` + : '', + animation: props.pulse && props.windowIsFocused ? `${pulse} 1s infinite` : '', + + '&:not(:first-child)': { + marginLeft: props.inButtonGroup === true ? 0 : 10, + borderTopLeftRadius: props.inButtonGroup === true ? 0 : 4, + borderBottomLeftRadius: props.inButtonGroup === true ? 0 : 4, + }, + + '&:not(:last-child)': { + borderTopRightRadius: props.inButtonGroup === true ? 0 : 4, + borderBottomRightRadius: props.inButtonGroup === true ? 0 : 4, + borderRight: props.inButtonGroup === true ? 0 : '', + }, + + '&:first-of-type': { + marginLeft: 0, + }, + + '&:active': props.disabled + ? null + : { + borderColor: colors.macOSTitleBarButtonBorder, + borderBottomColor: colors.macOSTitleBarButtonBorderBottom, + background: `linear-gradient(to bottom, ${colors.macOSTitleBarButtonBackgroundActiveHighlight} 1px, ${colors.macOSTitleBarButtonBackgroundActive} 0%, ${colors.macOSTitleBarButtonBorderBlur} 100%)`, + }, + + '&:disabled': { borderColor: borderColor(props), borderBottomColor: borderBottomColor(props), - color: color(props), - borderRadius: 4, - position: 'relative', - padding: props.padded ? '0 15px' : '0 6px', - height: props.compact === true ? 24 : 28, - margin: 0, - minWidth: 34, - display: 'inline-flex', - alignItems: 'center', - justifyContent: 'center', - flexShrink: 0, + pointerEvents: 'none', + }, - boxShadow: - props.pulse && props.windowIsFocused - ? `0 0 0 ${colors.macOSTitleBarIconSelected}` - : '', - animation: - props.pulse && props.windowIsFocused ? `${pulse} 1s infinite` : '', - - '&:not(:first-child)': { - marginLeft: props.inButtonGroup === true ? 0 : 10, - borderTopLeftRadius: props.inButtonGroup === true ? 0 : 4, - borderBottomLeftRadius: props.inButtonGroup === true ? 0 : 4, - }, - - '&:not(:last-child)': { - borderTopRightRadius: props.inButtonGroup === true ? 0 : 4, - borderBottomRightRadius: props.inButtonGroup === true ? 0 : 4, - borderRight: props.inButtonGroup === true ? 0 : '', - }, - - '&:first-of-type': { - marginLeft: 0, - }, - - '&:active': props.disabled - ? null - : { - borderColor: colors.macOSTitleBarButtonBorder, - borderBottomColor: colors.macOSTitleBarButtonBorderBottom, - background: `linear-gradient(to bottom, ${colors.macOSTitleBarButtonBackgroundActiveHighlight} 1px, ${colors.macOSTitleBarButtonBackgroundActive} 0%, ${colors.macOSTitleBarButtonBorderBlur} 100%)`, - }, - - '&:disabled': { - borderColor: borderColor(props), - borderBottomColor: borderBottomColor(props), - pointerEvents: 'none', - }, - - '&:hover::before': { - content: props.dropdown ? "''" : 'normal', - position: 'absolute', - bottom: 1, - right: 2, - borderStyle: 'solid', - borderWidth: '4px 3px 0 3px', - borderColor: `${colors.macOSTitleBarIcon} transparent transparent transparent`, - }, - }), -); + '&:hover::before': { + content: props.dropdown ? "''" : 'normal', + position: 'absolute', + bottom: 1, + right: 2, + borderStyle: 'solid', + borderWidth: '4px 3px 0 3px', + borderColor: `${colors.macOSTitleBarIcon} transparent transparent transparent`, + }, +})); StyledButton.displayName = 'Button:StyledButton'; -const Icon = styled(Glyph)(({hasText}: {hasText: boolean}) => ({ +const Icon = styled(Glyph)<{hasText: boolean}>(({hasText}) => ({ marginRight: hasText ? 3 : 0, })); Icon.displayName = 'Button:Icon'; diff --git a/src/ui/components/ButtonGroup.tsx b/src/ui/components/ButtonGroup.tsx index 69d895e58..02cf35ca5 100644 --- a/src/ui/components/ButtonGroup.tsx +++ b/src/ui/components/ButtonGroup.tsx @@ -7,11 +7,11 @@ * @format */ -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import React, {Component} from 'react'; import PropTypes from 'prop-types'; -const ButtonGroupContainer = styled('div')({ +const ButtonGroupContainer = styled.div({ display: 'inline-flex', marginLeft: 10, '&:first-child': { diff --git a/src/ui/components/ButtonGroupChain.tsx b/src/ui/components/ButtonGroupChain.tsx index 4aea750ce..34b36d142 100644 --- a/src/ui/components/ButtonGroupChain.tsx +++ b/src/ui/components/ButtonGroupChain.tsx @@ -9,10 +9,10 @@ import React, {Component} from 'react'; import PropTypes from 'prop-types'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import Glyph from './Glyph'; -const IconContainer = styled('div')({ +const IconContainer = styled.div({ width: 0, zIndex: 1, display: 'inline-flex', @@ -21,25 +21,23 @@ const IconContainer = styled('div')({ }); IconContainer.displayName = 'ButtonGroupChain:IconContainer'; -const ButtonGroupChainContainer = styled('div')( - (props: {iconSize: number}) => ({ - display: 'inline-flex', - marginLeft: 10, - '&:first-child>*:not(:first-child):nth-child(odd)': { - paddingLeft: props.iconSize + 6, - }, - '&:first-child>*': { - borderRightStyle: 'none', - borderLeftStyle: 'none', - }, - '&:first-child>:first-child': { - borderLeftStyle: 'solid', - }, - '&:first-child>:last-child': { - borderRightStyle: 'solid', - }, - }), -); +const ButtonGroupChainContainer = styled.div<{iconSize: number}>(props => ({ + display: 'inline-flex', + marginLeft: 10, + '&:first-child>*:not(:first-child):nth-child(odd)': { + paddingLeft: props.iconSize + 6, + }, + '&:first-child>*': { + borderRightStyle: 'none', + borderLeftStyle: 'none', + }, + '&:first-child>:first-child': { + borderLeftStyle: 'solid', + }, + '&:first-child>:last-child': { + borderRightStyle: 'solid', + }, +})); IconContainer.displayName = 'ButtonGroupChain:ButtonGroupChainContainer'; type Props = { diff --git a/src/ui/components/CenteredView.tsx b/src/ui/components/CenteredView.tsx index 3e562b08e..b8100f9fb 100644 --- a/src/ui/components/CenteredView.tsx +++ b/src/ui/components/CenteredView.tsx @@ -8,7 +8,7 @@ */ import React from 'react'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import {colors} from './colors'; import FlexColumn from './FlexColumn'; @@ -19,7 +19,7 @@ const Container = styled(FlexColumn)({ }); Container.displayName = 'CenteredView:Container'; -const ContentWrapper = styled('div')({ +const ContentWrapper = styled.div({ width: 500, marginLeft: 'auto', marginRight: 'auto', diff --git a/src/ui/components/Checkbox.tsx b/src/ui/components/Checkbox.tsx index ec1052b56..bee23de06 100644 --- a/src/ui/components/Checkbox.tsx +++ b/src/ui/components/Checkbox.tsx @@ -8,7 +8,7 @@ */ import {PureComponent} from 'react'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import React from 'react'; type CheckboxProps = { @@ -18,7 +18,7 @@ type CheckboxProps = { onChange: (checked: boolean) => void; }; -const CheckboxContainer = styled('input')({ +const CheckboxContainer = styled.input({ display: 'inline-block', marginRight: 5, verticalAlign: 'middle', diff --git a/src/ui/components/CodeBlock.tsx b/src/ui/components/CodeBlock.tsx index af784e4b9..494a4bac8 100644 --- a/src/ui/components/CodeBlock.tsx +++ b/src/ui/components/CodeBlock.tsx @@ -7,9 +7,9 @@ * @format */ -import styled from 'react-emotion'; +import styled from '@emotion/styled'; -const CodeBlock = styled('div')({ +const CodeBlock = styled.div({ fontFamily: 'monospace', }); CodeBlock.displayName = 'CodeBlock'; diff --git a/src/ui/components/ContextMenuProvider.tsx b/src/ui/components/ContextMenuProvider.tsx index b8b89ae90..7e32fbcc5 100644 --- a/src/ui/components/ContextMenuProvider.tsx +++ b/src/ui/components/ContextMenuProvider.tsx @@ -8,14 +8,14 @@ */ import {Component} from 'react'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import electron, {MenuItemConstructorOptions} from 'electron'; import React from 'react'; import PropTypes from 'prop-types'; type MenuTemplate = Array; -const Container = styled('div')({ +const Container = styled.div({ display: 'contents', }); Container.displayName = 'ContextMenuProvider:Container'; diff --git a/src/ui/components/ErrorBlock.tsx b/src/ui/components/ErrorBlock.tsx index 46d607709..e0c2a0c80 100644 --- a/src/ui/components/ErrorBlock.tsx +++ b/src/ui/components/ErrorBlock.tsx @@ -7,7 +7,7 @@ * @format */ -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import React from 'react'; import CodeBlock from './CodeBlock'; diff --git a/src/ui/components/ErrorBoundary.tsx b/src/ui/components/ErrorBoundary.tsx index dd60b78aa..880453c16 100644 --- a/src/ui/components/ErrorBoundary.tsx +++ b/src/ui/components/ErrorBoundary.tsx @@ -12,7 +12,7 @@ import {Component} from 'react'; import Heading from './Heading'; import Button from './Button'; import View from './View'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import React from 'react'; const ErrorBoundaryContainer = styled(View)({ diff --git a/src/ui/components/FlexBox.tsx b/src/ui/components/FlexBox.tsx index 6e9429018..f53ed9b4c 100644 --- a/src/ui/components/FlexBox.tsx +++ b/src/ui/components/FlexBox.tsx @@ -8,7 +8,7 @@ */ import View from './View'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; type Props = { /** Flexbox's shrink property. Set to `0`, to disable shrinking. */ @@ -18,7 +18,7 @@ type Props = { /** * A container using flexbox to layout its children */ -const FlexBox = styled(View)(({shrink}: Props) => ({ +const FlexBox = styled(View)(({shrink}) => ({ display: 'flex', flexShrink: shrink == null || shrink ? 1 : 0, })); diff --git a/src/ui/components/FlexCenter.tsx b/src/ui/components/FlexCenter.tsx index 0d875e8cc..a81a75db7 100644 --- a/src/ui/components/FlexCenter.tsx +++ b/src/ui/components/FlexCenter.tsx @@ -8,7 +8,7 @@ */ import View from './View'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; /** * A container displaying its children horizontally and vertically centered. diff --git a/src/ui/components/FlexColumn.tsx b/src/ui/components/FlexColumn.tsx index 995bfcaf8..de9242a07 100644 --- a/src/ui/components/FlexColumn.tsx +++ b/src/ui/components/FlexColumn.tsx @@ -8,7 +8,7 @@ */ import FlexBox from './FlexBox'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; /** * A container displaying its children in a column diff --git a/src/ui/components/FlexRow.tsx b/src/ui/components/FlexRow.tsx index 0004082a2..8a674f46c 100644 --- a/src/ui/components/FlexRow.tsx +++ b/src/ui/components/FlexRow.tsx @@ -8,7 +8,7 @@ */ import FlexBox from './FlexBox'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; /** * A container displaying its children in a row diff --git a/src/ui/components/FocusableBox.tsx b/src/ui/components/FocusableBox.tsx index 1ac0ac8a8..3d6409ba6 100644 --- a/src/ui/components/FocusableBox.tsx +++ b/src/ui/components/FocusableBox.tsx @@ -10,7 +10,7 @@ import {Component} from 'react'; import Box from './Box'; import {colors} from './colors'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import React from 'react'; const FocusableBoxBorder = styled(Box)({ diff --git a/src/ui/components/Glyph.tsx b/src/ui/components/Glyph.tsx index eb4a93230..47146dbfb 100644 --- a/src/ui/components/Glyph.tsx +++ b/src/ui/components/Glyph.tsx @@ -8,13 +8,13 @@ */ import React from 'react'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import PropTypes from 'prop-types'; import {getIconURL} from '../../utils/icons.js'; export type IconSize = 8 | 10 | 12 | 16 | 18 | 20 | 24 | 32; -const ColoredIconBlack = styled('img')(({size}: {size: number}) => ({ +const ColoredIconBlack = styled.img<{size: number}>(({size}) => ({ height: size, verticalAlign: 'middle', width: size, @@ -22,20 +22,22 @@ const ColoredIconBlack = styled('img')(({size}: {size: number}) => ({ })); ColoredIconBlack.displayName = 'Glyph:ColoredIconBlack'; -const ColoredIconCustom = styled('div')( - (props: {size: number; color?: string; src: string}) => ({ - height: props.size, - verticalAlign: 'middle', - width: props.size, - backgroundColor: props.color, - display: 'inline-block', - maskImage: `url('${props.src}')`, - maskSize: '100% 100%', - WebkitMaskImage: `url('${props.src}')`, - WebkitMaskSize: '100% 100%', - flexShrink: 0, - }), -); +const ColoredIconCustom = styled.div<{ + size: number; + color?: string; + src: string; +}>(props => ({ + height: props.size, + verticalAlign: 'middle', + width: props.size, + backgroundColor: props.color, + display: 'inline-block', + maskImage: `url('${props.src}')`, + maskSize: '100% 100%', + WebkitMaskImage: `url('${props.src}')`, + WebkitMaskSize: '100% 100%', + flexShrink: 0, +})); ColoredIconCustom.displayName = 'Glyph:ColoredIconCustom'; function ColoredIcon( diff --git a/src/ui/components/HBox.tsx b/src/ui/components/HBox.tsx index 71bb9b1e3..75db68f64 100644 --- a/src/ui/components/HBox.tsx +++ b/src/ui/components/HBox.tsx @@ -8,7 +8,7 @@ */ import React from 'react'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import FlexRow from './FlexRow'; /** @@ -16,8 +16,8 @@ import FlexRow from './FlexRow'; * It takes two children, 'left' and 'right'. One is assumed to have a fixed (or minimum) size, * and the other will grow automatically */ -const HBoxContainer = styled(FlexRow)( - ({verticalAlign}: {verticalAlign: string}) => ({ +const HBoxContainer = styled(FlexRow)<{verticalAlign: string}>( + ({verticalAlign}) => ({ shrink: 0, alignItems: verticalAlign, }), diff --git a/src/ui/components/Heading.tsx b/src/ui/components/Heading.tsx index 64d90b5b2..2bbf37191 100644 --- a/src/ui/components/Heading.tsx +++ b/src/ui/components/Heading.tsx @@ -7,10 +7,10 @@ * @format */ -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import React from 'react'; -const LargeHeading = styled('div')({ +const LargeHeading = styled.div({ fontSize: 18, fontWeight: 'bold', lineHeight: '20px', @@ -19,7 +19,7 @@ const LargeHeading = styled('div')({ }); LargeHeading.displayName = 'Heading:LargeHeading'; -const SmallHeading = styled('div')({ +const SmallHeading = styled.div({ fontSize: 12, color: '#90949c', fontWeight: 'bold', diff --git a/src/ui/components/HorizontalRule.tsx b/src/ui/components/HorizontalRule.tsx index dc08b1198..481d90472 100644 --- a/src/ui/components/HorizontalRule.tsx +++ b/src/ui/components/HorizontalRule.tsx @@ -7,9 +7,9 @@ * @format */ -import styled from 'react-emotion'; +import styled from '@emotion/styled'; -const HorizontalRule = styled('div')({ +const HorizontalRule = styled.div({ backgroundColor: '#c9ced4', height: 1, margin: '5px 0', diff --git a/src/ui/components/Info.tsx b/src/ui/components/Info.tsx index 0c6f28758..8a7bf349b 100644 --- a/src/ui/components/Info.tsx +++ b/src/ui/components/Info.tsx @@ -7,7 +7,7 @@ * @format */ -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import React from 'react'; import {colors} from './colors'; @@ -43,8 +43,8 @@ const bgColor = { spinning: 'transparent', }; -const InfoWrapper = styled(FlexColumn)( - ({type, small}: Pick) => ({ +const InfoWrapper = styled(FlexColumn)>( + ({type, small}) => ({ padding: small ? '0 4px' : 10, borderRadius: 4, color: color[type], diff --git a/src/ui/components/Input.tsx b/src/ui/components/Input.tsx index 418ac9b06..e1aaa044d 100644 --- a/src/ui/components/Input.tsx +++ b/src/ui/components/Input.tsx @@ -7,7 +7,7 @@ * @format */ -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import {colors} from './colors'; export const inputStyle = (props: { @@ -30,24 +30,18 @@ export const inputStyle = (props: { }, }); -const Input = styled('input')( - ({ - compact, - valid, - readOnly, - }: { - compact?: boolean; - valid?: boolean; - readOnly?: boolean; - }) => ({ - ...inputStyle({ - compact: compact || false, - valid: valid !== false, - readOnly: readOnly === true, - }), - padding: compact ? '0 5px' : '0 10px', +const Input = styled.input<{ + compact?: boolean; + valid?: boolean; + readOnly?: boolean; +}>(({compact, valid, readOnly}) => ({ + ...inputStyle({ + compact: compact || false, + valid: valid !== false, + readOnly: readOnly === true, }), -); + padding: compact ? '0 5px' : '0 10px', +})); Input.displayName = 'Input'; diff --git a/src/ui/components/Interactive.tsx b/src/ui/components/Interactive.tsx index a8d565f09..8de4d6eee 100644 --- a/src/ui/components/Interactive.tsx +++ b/src/ui/components/Interactive.tsx @@ -15,7 +15,7 @@ import { maybeSnapTop, SNAP_SIZE, } from '../../utils/snap'; -import styled from 'react-emotion'; +import styled from '@emotion/styled'; import invariant from 'invariant'; import React from 'react'; @@ -72,7 +72,7 @@ type InteractiveProps = { onResize?: (width: number, height: number) => void; resizing?: boolean; resizable?: boolean | ResizingSides; - innerRef?: (elem: HTMLElement) => void; + innerRef?: (elem: HTMLElement | null) => void; style?: Object; className?: string; children?: React.ReactNode; @@ -90,7 +90,7 @@ type InteractiveState = { resizingInitialCursor: CursorState | null | undefined; }; -const InteractiveContainer = styled('div')({ +const InteractiveContainer = styled.div({ willChange: 'transform, height, width, z-index', }); InteractiveContainer.displayName = 'Interactive:InteractiveContainer'; @@ -118,11 +118,11 @@ export default class Interactive extends React.Component< } globalMouse: boolean; - ref: HTMLElement | undefined; + ref?: HTMLElement | null; - nextTop: number | null | undefined; - nextLeft: number | null | undefined; - nextEvent: MouseEvent | null | undefined; + nextTop?: number | null; + nextLeft?: number | null; + nextEvent?: MouseEvent | null; static defaultProps = { minHeight: 0, @@ -656,7 +656,7 @@ export default class Interactive extends React.Component< }); } - setRef = (ref: HTMLElement) => { + setRef = (ref: HTMLElement | null) => { this.ref = ref; const {innerRef} = this.props; @@ -706,7 +706,7 @@ export default class Interactive extends React.Component<