diff --git a/flow-typed/npm/react-emotion_vx.x.x.js b/flow-typed/npm/react-emotion_vx.x.x.js new file mode 100644 index 000000000..4b7b91f57 --- /dev/null +++ b/flow-typed/npm/react-emotion_vx.x.x.js @@ -0,0 +1,60 @@ +// flow-typed signature: 69f0585b3bbc433c0c0eb3d242636c6d +// flow-typed version: <>/react-emotion_v9.2.6/flow_v0.76.0 + +/** + * This is an autogenerated libdef stub for: + * + * 'react-emotion' + * + * Fill this stub out by replacing all the `any` types. + * + * Once filled out, we encourage you to share your work with the + * community by sending a pull request to: + * https://github.com/flowtype/flow-typed + */ + +declare module 'react-emotion' { + declare module.exports: any; +} + +/** + * We include stubs for each file inside this npm package in case you need to + * require those files directly. Feel free to delete any files that aren't + * needed. + */ +declare module 'react-emotion/dist/emotion.umd.min' { + declare module.exports: any; +} + +declare module 'react-emotion/dist/index.cjs' { + declare module.exports: any; +} + +declare module 'react-emotion/dist/index.esm' { + declare module.exports: any; +} + +declare module 'react-emotion/macro' { + declare module.exports: any; +} + +declare module 'react-emotion/src/index' { + declare module.exports: any; +} + +// Filename aliases +declare module 'react-emotion/dist/emotion.umd.min.js' { + declare module.exports: $Exports<'react-emotion/dist/emotion.umd.min'>; +} +declare module 'react-emotion/dist/index.cjs.js' { + declare module.exports: $Exports<'react-emotion/dist/index.cjs'>; +} +declare module 'react-emotion/dist/index.esm.js' { + declare module.exports: $Exports<'react-emotion/dist/index.esm'>; +} +declare module 'react-emotion/macro.js' { + declare module.exports: $Exports<'react-emotion/macro'>; +} +declare module 'react-emotion/src/index.js' { + declare module.exports: $Exports<'react-emotion/src/index'>; +} diff --git a/src/PluginContainer.js b/src/PluginContainer.js index 969d10c17..ddc799917 100644 --- a/src/PluginContainer.js +++ b/src/PluginContainer.js @@ -10,7 +10,14 @@ import type Client from './Client.js'; import type BaseDevice from './devices/BaseDevice.js'; import {SonarDevicePlugin} from './plugin.js'; -import {ErrorBoundary, Component, FlexColumn, FlexRow, colors} from 'sonar'; +import { + ErrorBoundary, + Component, + FlexColumn, + FlexRow, + colors, + styled, +} from 'sonar'; import React from 'react'; import {connect} from 'react-redux'; import {setPluginState} from './reducers/pluginStates.js'; @@ -18,14 +25,14 @@ import {devicePlugins} from './device-plugins/index.js'; import plugins from './plugins/index.js'; import {activateMenuItems} from './MenuBar.js'; -const Container = FlexColumn.extends({ +const Container = styled(FlexColumn)({ width: 0, flexGrow: 1, flexShrink: 1, backgroundColor: colors.white, }); -const SidebarContainer = FlexRow.extends({ +const SidebarContainer = styled(FlexRow)({ backgroundColor: colors.light02, height: '100%', overflow: 'scroll', diff --git a/src/chrome/AutoUpdateVersion.js b/src/chrome/AutoUpdateVersion.js index cf32d1f49..52a8e88cb 100644 --- a/src/chrome/AutoUpdateVersion.js +++ b/src/chrome/AutoUpdateVersion.js @@ -5,19 +5,27 @@ * @format */ -import {FlexRow, Text, colors, LoadingIndicator, Glyph, Component} from 'sonar'; +import { + FlexRow, + Text, + colors, + LoadingIndicator, + Glyph, + Component, + styled, +} from 'sonar'; import {remote} from 'electron'; import isProduction from '../utils/isProduction.js'; import config from '../fb-stubs/config.js'; const version = remote.app.getVersion(); -const VersionText = Text.extends({ +const VersionText = styled(Text)({ color: colors.light50, marginLeft: 4, marginTop: 2, }); -const Container = FlexRow.extends({ +const Container = styled(FlexRow)({ alignItems: 'center', }); diff --git a/src/chrome/BugReporterDialog.js b/src/chrome/BugReporterDialog.js index 37c9ba030..8b8417c5d 100644 --- a/src/chrome/BugReporterDialog.js +++ b/src/chrome/BugReporterDialog.js @@ -20,7 +20,7 @@ import { styled, } from 'sonar'; -const Container = FlexColumn.extends({ +const Container = styled(FlexColumn)({ padding: 10, }); @@ -29,7 +29,7 @@ const textareaStyle = { marginBottom: 10, }; -const DialogContainer = styled.view({ +const DialogContainer = styled('div')({ width: 400, height: 300, position: 'absolute', @@ -45,25 +45,25 @@ const DialogContainer = styled.view({ boxShadow: '0 1px 10px rgba(0, 0, 0, 0.1)', }); -const TitleInput = Input.extends({ +const TitleInput = styled(Input)({ ...textareaStyle, height: 30, }); -const DescriptionTextarea = Textarea.extends({ +const DescriptionTextarea = styled(Textarea)({ ...textareaStyle, flexGrow: 1, }); -const SubmitButtonContainer = styled.view({ +const SubmitButtonContainer = styled('div')({ marginLeft: 'auto', }); -const Footer = FlexRow.extends({ +const Footer = styled(FlexRow)({ lineHeight: '24px', }); -const CloseDoneButton = Button.extends({ +const CloseDoneButton = styled(Button)({ width: 50, margin: '10px auto', }); diff --git a/src/chrome/DevicesList.js b/src/chrome/DevicesList.js index 388ab385b..2377e3adc 100644 --- a/src/chrome/DevicesList.js +++ b/src/chrome/DevicesList.js @@ -16,7 +16,7 @@ import { colors, } from 'sonar'; -const Heading = Text.extends({ +const Heading = styled(Text)({ display: 'block', backgroundColor: colors.white, color: colors.light30, @@ -26,7 +26,7 @@ const Heading = Text.extends({ padding: '4px 8px 0', }); -const PopoverItem = FlexRow.extends({ +const PopoverItem = styled(FlexRow)({ alignItems: 'center', borderBottom: `1px solid ${colors.light05}`, height: 50, @@ -35,7 +35,7 @@ const PopoverItem = FlexRow.extends({ }, }); -const ItemTitle = Text.extends({ +const ItemTitle = styled(Text)({ display: 'block', fontSize: 14, fontWeight: 400, @@ -46,7 +46,7 @@ const ItemTitle = Text.extends({ marginBottom: 1, }); -const ItemSubtitle = Text.extends({ +const ItemSubtitle = styled(Text)({ display: 'block', fontWeight: 400, fontSize: 11, @@ -57,20 +57,20 @@ const ItemSubtitle = Text.extends({ whiteSpace: 'nowrap', }); -const ItemImage = FlexBox.extends({ +const ItemImage = styled(FlexBox)({ alignItems: 'center', justifyContent: 'center', width: 40, flexShrink: 0, }); -const ItemContent = styled.view({ +const ItemContent = styled('div')({ minWidth: 0, paddingRight: 5, flexGrow: 1, }); -const Section = styled.view({ +const Section = styled('div')({ maxWidth: 260, borderBottom: `1px solid ${colors.light05}`, '&:last-child': { @@ -78,7 +78,7 @@ const Section = styled.view({ }, }); -const Action = Button.extends({ +const Action = styled(Button)({ border: `1px solid ${colors.macOSTitleBarButtonBorder}`, background: 'transparent', color: colors.macOSTitleBarIconSelected, diff --git a/src/chrome/ErrorBar.js b/src/chrome/ErrorBar.js index 9bfcfd4e1..88f043657 100644 --- a/src/chrome/ErrorBar.js +++ b/src/chrome/ErrorBar.js @@ -7,7 +7,7 @@ import {styled, colors} from 'sonar'; -const ErrorBarContainer = styled.view({ +const ErrorBarContainer = styled('div')({ backgroundColor: colors.cherry, bottom: 0, color: '#fff', diff --git a/src/chrome/MainSidebar.js b/src/chrome/MainSidebar.js index 91cd6c6c8..229b54a79 100644 --- a/src/chrome/MainSidebar.js +++ b/src/chrome/MainSidebar.js @@ -17,11 +17,11 @@ import { Component, Sidebar, FlexBox, - ClickableListItem, colors, brandColors, Text, Glyph, + styled, } from 'sonar'; import React from 'react'; import {devicePlugins} from '../device-plugins/index.js'; @@ -29,15 +29,22 @@ import plugins from '../plugins/index.js'; import {selectPlugin} from '../reducers/connections.js'; import {connect} from 'react-redux'; -const CustomClickableListItem = ClickableListItem.extends({ +const ListItem = styled('div')(({active}) => ({ paddingLeft: 10, display: 'flex', alignItems: 'center', marginBottom: 2, flexShrink: 0, -}); + backgroundColor: active ? colors.macOSTitleBarIconSelected : 'none', + color: active ? colors.white : colors.macOSSidebarSectionItem, + lineHeight: '25px', + padding: '0 10px', + '&[disabled]': { + color: 'rgba(0, 0, 0, 0.5)', + }, +})); -const SidebarHeader = FlexBox.extends({ +const SidebarHeader = styled(FlexBox)({ display: 'block', alignItems: 'center', padding: 3, @@ -51,23 +58,18 @@ const SidebarHeader = FlexBox.extends({ flexShrink: 0, }); -const PluginShape = FlexBox.extends( - { - marginRight: 5, - backgroundColor: props => props.backgroundColor, - borderRadius: 3, - flexShrink: 0, - width: 18, - height: 18, - justifyContent: 'center', - alignItems: 'center', - }, - { - ignoreAttributes: ['backgroundColor'], - }, -); +const PluginShape = styled(FlexBox)(({backgroundColor}) => ({ + marginRight: 5, + backgroundColor, + borderRadius: 3, + flexShrink: 0, + width: 18, + height: 18, + justifyContent: 'center', + alignItems: 'center', +})); -const PluginName = Text.extends({ +const PluginName = styled(Text)({ minWidth: 0, textOverflow: 'ellipsis', whiteSpace: 'nowrap', @@ -75,17 +77,19 @@ const PluginName = Text.extends({ }); function PluginIcon({ + isActive, backgroundColor, name, color, }: { + isActive: boolean, backgroundColor: string, name: string, color: string, }) { return ( - + ); } @@ -118,14 +122,15 @@ class PluginSidebarListItem extends Component<{ } return ( - + {plugin.title} - + ); } } diff --git a/src/chrome/PluginManager.js b/src/chrome/PluginManager.js index d4cc6c23e..28ef2becb 100644 --- a/src/chrome/PluginManager.js +++ b/src/chrome/PluginManager.js @@ -63,18 +63,18 @@ type State = { searchCompleted: boolean, }; -const Container = FlexBox.extends({ +const Container = styled(FlexBox)({ width: '100%', flexGrow: 1, background: colors.light02, overflowY: 'scroll', }); -const Title = Text.extends({ +const Title = styled(Text)({ fontWeight: 500, }); -const Plugin = FlexColumn.extends({ +const Plugin = styled(FlexColumn)({ backgroundColor: colors.white, borderRadius: 4, padding: 15, @@ -82,20 +82,20 @@ const Plugin = FlexColumn.extends({ boxShadow: '0 1px 2px rgba(0,0,0,0.05)', }); -const SectionTitle = styled.text({ +const SectionTitle = styled('span')({ fontWeight: 'bold', fontSize: 24, margin: 15, marginLeft: 20, }); -const Loading = FlexBox.extends({ +const Loading = styled(FlexBox)({ padding: 50, alignItems: 'center', justifyContent: 'center', }); -const RestartRequired = FlexBox.extends({ +const RestartRequired = styled(FlexBox)({ textAlign: 'center', justifyContent: 'center', fontWeight: 500, @@ -105,22 +105,22 @@ const RestartRequired = FlexBox.extends({ cursor: 'pointer', }); -const TitleRow = FlexRow.extends({ +const TitleRow = styled(FlexRow)({ alignItems: 'center', marginBottom: 10, fontSize: '1.1em', }); -const Description = FlexRow.extends({ +const Description = styled(FlexRow)({ marginBottom: 15, lineHeight: '130%', }); -const PluginGlyph = Glyph.extends({ +const PluginGlyph = styled(Glyph)({ marginRight: 5, }); -const PluginLoading = LoadingIndicator.extends({ +const PluginLoading = styled(LoadingIndicator)({ marginLeft: 5, marginTop: 5, }); diff --git a/src/chrome/Popover.js b/src/chrome/Popover.js index 32d0d5ccd..3d2808456 100644 --- a/src/chrome/Popover.js +++ b/src/chrome/Popover.js @@ -16,7 +16,7 @@ import { colors, } from 'sonar'; -const Anchor = styled.image({ +const Anchor = styled('img')({ zIndex: 6, position: 'absolute', bottom: 0, @@ -24,7 +24,7 @@ const Anchor = styled.image({ transform: 'translate(-50%, calc(100% + 2px))', }); -const PopoverContainer = FlexColumn.extends({ +const PopoverContainer = styled(FlexColumn)({ backgroundColor: colors.white, borderRadius: 7, border: '1px solid rgba(0,0,0,0.3)', @@ -50,7 +50,7 @@ const PopoverContainer = FlexColumn.extends({ }, }); -const Heading = Text.extends({ +const Heading = styled(Text)({ display: 'block', backgroundColor: colors.white, color: colors.light30, @@ -60,7 +60,7 @@ const Heading = Text.extends({ padding: '4px 8px 0', }); -const PopoverItem = FlexRow.extends({ +const PopoverItem = styled(FlexRow)({ alignItems: 'center', borderBottom: `1px solid ${colors.light05}`, height: 50, @@ -69,7 +69,7 @@ const PopoverItem = FlexRow.extends({ }, }); -const ItemTitle = Text.extends({ +const ItemTitle = styled(Text)({ display: 'block', fontSize: 14, fontWeight: 400, @@ -80,7 +80,7 @@ const ItemTitle = Text.extends({ marginBottom: 1, }); -const ItemSubtitle = Text.extends({ +const ItemSubtitle = styled(Text)({ display: 'block', fontWeight: 400, fontSize: 11, @@ -91,27 +91,27 @@ const ItemSubtitle = Text.extends({ whiteSpace: 'nowrap', }); -const ItemImage = FlexBox.extends({ +const ItemImage = styled(FlexBox)({ alignItems: 'center', justifyContent: 'center', width: 40, flexShrink: 0, }); -const ItemContent = styled.view({ +const ItemContent = styled('div')({ minWidth: 0, paddingRight: 5, flexGrow: 1, }); -const Section = styled.view({ +const Section = styled('div')({ borderBottom: `1px solid ${colors.light05}`, '&:last-child': { borderBottom: 'none', }, }); -const Action = Button.extends({ +const Action = styled(Button)({ border: `1px solid ${colors.macOSTitleBarButtonBorder}`, background: 'transparent', color: colors.macOSTitleBarIconSelected, diff --git a/src/chrome/SonarTitleBar.js b/src/chrome/SonarTitleBar.js index 5cd006307..befb02e2c 100644 --- a/src/chrome/SonarTitleBar.js +++ b/src/chrome/SonarTitleBar.js @@ -13,6 +13,7 @@ import { Component, Spacer, GK, + styled, } from 'sonar'; import {connect} from 'react-redux'; import { @@ -26,34 +27,24 @@ import ScreenCaptureButtons from './ScreenCaptureButtons.js'; import AutoUpdateVersion from './AutoUpdateVersion.js'; import config from '../fb-stubs/config.js'; -const TitleBar = FlexRow.extends( - { - background: props => - props.focused - ? `linear-gradient(to bottom, ${ - colors.macOSTitleBarBackgroundTop - } 0%, ${colors.macOSTitleBarBackgroundBottom} 100%)` - : colors.macOSTitleBarBackgroundBlur, - borderBottom: props => - `1px solid ${ - props.focused - ? colors.macOSTitleBarBorder - : colors.macOSTitleBarBorderBlur - }`, - height: 38, - flexShrink: 0, - width: '100%', - alignItems: 'center', - paddingLeft: 80, - paddingRight: 10, - justifyContent: 'space-between', - // $FlowFixMe - WebkitAppRegion: 'drag', - }, - { - ignoreAttributes: ['focused'], - }, -); +const TitleBar = styled(FlexRow)(({focused}) => ({ + background: focused + ? `linear-gradient(to bottom, ${colors.macOSTitleBarBackgroundTop} 0%, ${ + colors.macOSTitleBarBackgroundBottom + } 100%)` + : colors.macOSTitleBarBackgroundBlur, + borderBottom: `1px solid ${ + focused ? colors.macOSTitleBarBorder : colors.macOSTitleBarBorderBlur + }`, + height: 38, + flexShrink: 0, + width: '100%', + alignItems: 'center', + paddingLeft: 80, + paddingRight: 10, + justifyContent: 'space-between', + WebkitAppRegion: 'drag', +})); type Props = {| windowIsFocused: boolean, diff --git a/src/chrome/Version.js b/src/chrome/Version.js index 039a864e5..f85a62cb8 100644 --- a/src/chrome/Version.js +++ b/src/chrome/Version.js @@ -5,7 +5,7 @@ * @format */ -import {Component, FlexRow, colors, LoadingIndicator} from 'sonar'; +import {Component, FlexRow, colors, LoadingIndicator, styled} from 'sonar'; import {version} from '../../package.json'; import {remote} from 'electron'; import * as path from 'path'; @@ -24,7 +24,7 @@ export default class Version extends Component<{}, VersionState> { status: 'unknown', }; - static Container = FlexRow.extends({ + static Container = styled(FlexRow)({ alignItems: 'center', marginRight: 7, marginLeft: 7, @@ -32,7 +32,7 @@ export default class Version extends Component<{}, VersionState> { color: colors.light50, }); - static UpdatedContainer = FlexRow.extends({ + static UpdatedContainer = styled(FlexRow)({ backgroundColor: colors.blackAlpha10, borderRadius: '999em', padding: '2px 6px', diff --git a/src/chrome/WelcomeScreen.js b/src/chrome/WelcomeScreen.js index 699b8a3a9..184838df4 100644 --- a/src/chrome/WelcomeScreen.js +++ b/src/chrome/WelcomeScreen.js @@ -18,7 +18,7 @@ import { import isProduction from '../utils/isProduction.js'; import {shell, remote} from 'electron'; -const Container = FlexColumn.extends({ +const Container = styled(FlexColumn)({ height: '100%', width: '100%', justifyContent: 'center', @@ -26,23 +26,18 @@ const Container = FlexColumn.extends({ backgroundColor: colors.light02, }); -const Welcome = FlexColumn.extends( - { - width: 460, - background: colors.white, - borderRadius: 10, - boxShadow: '0 1px 3px rgba(0,0,0,0.25)', - overflow: 'hidden', - opacity: props => (props.isMounted ? 1 : 0), - transform: props => `translateY(${props.isMounted ? 0 : 20}px)`, - transition: '0.6s all ease-out', - }, - { - ignoreAttributes: ['isMounted'], - }, -); +const Welcome = styled(FlexColumn)(({isMounted}) => ({ + width: 460, + background: colors.white, + borderRadius: 10, + boxShadow: '0 1px 3px rgba(0,0,0,0.25)', + overflow: 'hidden', + opacity: isMounted ? 1 : 0, + transform: `translateY(${isMounted ? 0 : 20}px)`, + transition: '0.6s all ease-out', +})); -const Title = Text.extends({ +const Title = styled(Text)({ fontSize: 24, fontWeight: 300, textAlign: 'center', @@ -50,7 +45,7 @@ const Title = Text.extends({ marginBottom: 16, }); -const Version = Text.extends({ +const Version = styled(Text)({ textAlign: 'center', fontSize: 11, fontWeight: 300, @@ -58,7 +53,7 @@ const Version = Text.extends({ marginBottom: 60, }); -const Item = FlexRow.extends({ +const Item = styled(FlexRow)({ padding: 10, cursor: 'pointer', alignItems: 'center', @@ -69,23 +64,23 @@ const Item = FlexRow.extends({ }, }); -const ItemTitle = Text.extends({ +const ItemTitle = styled(Text)({ color: colors.light50, fontSize: 15, }); -const ItemSubTitle = Text.extends({ +const ItemSubTitle = styled(Text)({ color: colors.light30, fontSize: 11, marginTop: 2, }); -const Icon = Glyph.extends({ +const Icon = styled(Glyph)({ marginRight: 11, marginLeft: 6, }); -const Logo = styled.image({ +const Logo = styled('img')({ width: 128, height: 128, alignSelf: 'center', diff --git a/src/device-plugins/logs/LogWatcher.js b/src/device-plugins/logs/LogWatcher.js index f745e62bf..d9a1b366b 100644 --- a/src/device-plugins/logs/LogWatcher.js +++ b/src/device-plugins/logs/LogWatcher.js @@ -15,6 +15,7 @@ import { ManagedTable, Button, colors, + styled, } from 'sonar'; export type Counter = { @@ -55,7 +56,7 @@ const Columns = { }, }; -const Count = Text.extends({ +const Count = styled(Text)({ alignSelf: 'center', background: colors.macOSHighlightActive, color: colors.white, @@ -68,7 +69,7 @@ const Count = Text.extends({ marginLeft: 'auto', }); -const Checkbox = Input.extends({ +const Checkbox = styled(Input)({ lineHeight: '100%', padding: 0, margin: 0, @@ -76,11 +77,11 @@ const Checkbox = Input.extends({ alignSelf: 'center', }); -const ExpressionInput = Input.extends({ +const ExpressionInput = styled(Input)({ flexGrow: 1, }); -const WatcherPanel = Panel.extends({ +const WatcherPanel = styled(Panel)({ minHeight: 200, }); diff --git a/src/device-plugins/logs/index.js b/src/device-plugins/logs/index.js index a0e890e21..1aeda58f3 100644 --- a/src/device-plugins/logs/index.js +++ b/src/device-plugins/logs/index.js @@ -25,6 +25,7 @@ import { FlexColumn, Glyph, SonarSidebar, + styled, } from 'sonar'; import {SonarDevicePlugin, SearchableTable} from 'sonar'; import textContent from '../../utils/textContent.js'; @@ -47,7 +48,7 @@ type LogsState = {| counters: Array, |}; -const Icon = Glyph.extends({ +const Icon = styled(Glyph)({ marginTop: 5, }); @@ -202,7 +203,7 @@ const DEFAULT_FILTERS = [ }, ]; -const HiddenScrollText = Text.extends({ +const HiddenScrollText = styled(Text)({ alignSelf: 'baseline', userSelect: 'none', lineHeight: '130%', @@ -212,23 +213,18 @@ const HiddenScrollText = Text.extends({ }, }); -const LogCount = HiddenScrollText.extends( - { - backgroundColor: props => props.color, - borderRadius: '999em', - fontSize: 11, - display: 'flex', - justifyContent: 'center', - alignItems: 'center', - marginTop: 4, - width: 16, - height: 16, - color: colors.white, - }, - { - ignoreAttributes: ['color'], - }, -); +const LogCount = styled(HiddenScrollText)(({color}) => ({ + backgroundColor: color, + borderRadius: '999em', + fontSize: 11, + display: 'flex', + justifyContent: 'center', + alignItems: 'center', + marginTop: 4, + width: 16, + height: 16, + color: colors.white, +})); function pad(chunk: mixed, len: number): string { let str = String(chunk); @@ -529,7 +525,7 @@ export default class LogTable extends SonarDevicePlugin { ); }; - static ContextMenu = ContextMenu.extends({ + static ContextMenu = styled(ContextMenu)({ flex: 1, }); diff --git a/src/index.js b/src/index.js index 065734b56..a96b95e75 100644 --- a/src/index.js +++ b/src/index.js @@ -5,7 +5,7 @@ * @format */ -export {default as styled} from './ui/styled/index.js'; +export {default as styled} from 'react-emotion'; export * from './ui/index.js'; export * from './utils/index.js'; diff --git a/src/plugins/layout/index.js b/src/plugins/layout/index.js index 756766a5b..1d41f79b1 100644 --- a/src/plugins/layout/index.js +++ b/src/plugins/layout/index.js @@ -106,18 +106,18 @@ type SearchResultTree = {| axElement: Element, |}; -const LoadingSpinner = LoadingIndicator.extends({ +const LoadingSpinner = styled(LoadingIndicator)({ marginRight: 4, marginLeft: 3, marginTop: -1, }); -const Center = FlexRow.extends({ +const Center = styled(FlexRow)({ alignItems: 'center', justifyContent: 'center', }); -const SearchIconContainer = styled.view({ +const SearchIconContainer = styled('div')({ marginRight: 9, marginTop: -3, marginLeft: 4, @@ -131,7 +131,7 @@ class LayoutSearchInput extends Component< value: string, }, > { - static TextInput = styled.textInput({ + static TextInput = styled('input')({ width: '100%', marginLeft: 6, }); diff --git a/src/plugins/leak_canary/index.js b/src/plugins/leak_canary/index.js index 4f4252157..4efcc5440 100644 --- a/src/plugins/leak_canary/index.js +++ b/src/plugins/leak_canary/index.js @@ -16,6 +16,7 @@ import { Checkbox, SonarPlugin, Button, + styled, } from 'sonar'; import type {ElementID, Element} from 'sonar'; import {processLeaks} from './processLeakString'; @@ -42,12 +43,12 @@ export type Leak = { retainedSize: string, }; -const Window = FlexRow.extends({ +const Window = styled(FlexRow)({ height: '100%', flex: 1, }); -const ToolbarItem = FlexRow.extends({ +const ToolbarItem = styled(FlexRow)({ alignItems: 'center', marginLeft: '8px', }); diff --git a/src/plugins/network/RequestDetails.js b/src/plugins/network/RequestDetails.js index b952ebb7d..3ecdd1396 100644 --- a/src/plugins/network/RequestDetails.js +++ b/src/plugins/network/RequestDetails.js @@ -23,7 +23,7 @@ import {getHeaderValue} from './index.js'; import querystring from 'querystring'; -const WrappingText = Text.extends({ +const WrappingText = styled(Text)({ wordWrap: 'break-word', width: '100%', lineHeight: '125%', @@ -84,7 +84,7 @@ function decompress(body: string): string { } export default class RequestDetails extends Component { - static Container = FlexColumn.extends({ + static Container = styled(FlexColumn)({ height: '100%', overflow: 'auto', }); @@ -274,7 +274,7 @@ class HeaderInspector extends Component< } } -const BodyContainer = styled.view({ +const BodyContainer = styled('div')({ paddingTop: 10, paddingBottom: 20, }); @@ -338,7 +338,7 @@ class ResponseBodyInspector extends Component<{ } } -const MediaContainer = FlexColumn.extends({ +const MediaContainer = styled(FlexColumn)({ alignItems: 'center', justifyContent: 'center', width: '100%', @@ -354,14 +354,14 @@ type ImageWithSizeState = { }; class ImageWithSize extends Component { - static Image = styled.image({ + static Image = styled('img')({ objectFit: 'scale-down', maxWidth: 500, maxHeight: 500, marginBottom: 10, }); - static Text = Text.extends({ + static Text = styled(Text)({ color: colors.dark70, fontSize: 14, }); @@ -408,7 +408,7 @@ class ImageFormatter { } class VideoFormatter { - static Video = styled.customHTMLTag('video', { + static Video = styled('video')({ maxWidth: 500, maxHeight: 500, }); diff --git a/src/plugins/network/index.js b/src/plugins/network/index.js index 584c41a15..e2218b26c 100644 --- a/src/plugins/network/index.js +++ b/src/plugins/network/index.js @@ -16,6 +16,7 @@ import { colors, PureComponent, SonarSidebar, + styled, } from 'sonar'; import {SonarPlugin, SearchableTable} from 'sonar'; import RequestDetails from './RequestDetails.js'; @@ -100,7 +101,7 @@ export function formatBytes(count: number): string { return count + ' B'; } -const TextEllipsis = Text.extends({ +const TextEllipsis = styled(Text)({ overflowX: 'hidden', textOverflow: 'ellipsis', maxWidth: '100%', @@ -287,7 +288,7 @@ function calculateState( } class NetworkTable extends PureComponent { - static ContextMenu = ContextMenu.extends({ + static ContextMenu = styled(ContextMenu)({ flex: 1, }); @@ -338,7 +339,7 @@ class NetworkTable extends PureComponent { } } -const Icon = Glyph.extends({ +const Icon = styled(Glyph)({ marginTop: -3, marginRight: 3, }); @@ -367,7 +368,7 @@ class DurationColumn extends PureComponent<{ request: Request, response: ?Response, }> { - static Text = Text.extends({ + static Text = styled(Text)({ flex: 1, textAlign: 'right', paddingRight: 10, @@ -389,7 +390,7 @@ class DurationColumn extends PureComponent<{ class SizeColumn extends PureComponent<{ response: ?Response, }> { - static Text = Text.extends({ + static Text = styled(Text)({ flex: 1, textAlign: 'right', paddingRight: 10, diff --git a/src/plugins/sandbox/index.js b/src/plugins/sandbox/index.js index 54c6d7374..7a17a844c 100644 --- a/src/plugins/sandbox/index.js +++ b/src/plugins/sandbox/index.js @@ -20,13 +20,13 @@ type SandboxState = {| showFeedback: boolean, |}; -const BigButton = Button.extends({ +const BigButton = styled(Button)({ flexGrow: 1, fontSize: 24, padding: 20, }); -const ButtonContainer = FlexColumn.extends({ +const ButtonContainer = styled(FlexColumn)({ alignItems: 'center', padding: 20, }); @@ -42,7 +42,7 @@ export default class SandboxView extends SonarPlugin { static id = 'Sandbox'; static icon = 'translate'; - static TextInput = styled.textInput({ + static TextInput = styled('input')({ border: `1px solid ${colors.light10}`, fontSize: '1em', padding: '0 5px', @@ -52,13 +52,13 @@ export default class SandboxView extends SonarPlugin { flexGrow: 1, }); - static FeedbackMessage = styled.text({ + static FeedbackMessage = styled('span')({ fontSize: '1.2em', paddingTop: '10px', color: 'green', }); - static TextInputLayout = FlexColumn.extends({ + static TextInputLayout = styled(FlexColumn)({ float: 'left', justifyContent: 'center', flexGrow: 1, diff --git a/src/ui/components/Block.js b/src/ui/components/Block.js index 4c7eec6f9..88a2c4b87 100644 --- a/src/ui/components/Block.js +++ b/src/ui/components/Block.js @@ -7,6 +7,6 @@ import styled from '../styled/index.js'; -export default styled.view({ +export default styled('div')({ display: 'block', }); diff --git a/src/ui/components/Box.js b/src/ui/components/Box.js index e0712484e..6009eced1 100644 --- a/src/ui/components/Box.js +++ b/src/ui/components/Box.js @@ -6,8 +6,9 @@ */ import FlexBox from './FlexBox.js'; +import styled from '../styled/index.js'; -export default FlexBox.extends({ +export default styled(FlexBox)({ height: '100%', overflow: 'auto', position: 'relative', diff --git a/src/ui/components/Button.js b/src/ui/components/Button.js index 5d60b2a24..f5485c4bf 100644 --- a/src/ui/components/Button.js +++ b/src/ui/components/Button.js @@ -7,12 +7,12 @@ import Glyph from './Glyph.js'; import styled from '../styled/index.js'; -import type {StyledComponent} from '../styled/index.js'; import {findDOMNode} from 'react-dom'; import PropTypes from 'prop-types'; import {colors} from './colors.js'; import {connect} from 'react-redux'; import electron from 'electron'; +import {keyframes} from 'react-emotion'; const borderColor = props => { if (!props.windowIsFocused) { @@ -35,129 +35,122 @@ const borderBottomColor = props => { } }; -const StyledButton = styled.view( - { - backgroundColor: props => { - if (!props.windowIsFocused) { - return colors.macOSTitleBarButtonBackgroundBlur; - } else { - return colors.white; - } - }, - backgroundImage: props => { - if (props.windowIsFocused) { - if (props.depressed) { - return `linear-gradient(to bottom, ${ - colors.macOSTitleBarBorderBlur - } 1px, ${colors.macOSTitleBarButtonBorderBlur} 0%, ${ - colors.macOSTitleBarButtonBackgroundActive - } 100%)`; - } else { - return `linear-gradient(to bottom, transparent 0%,${ - colors.macOSTitleBarButtonBackground - } 100%)`; - } - } else { - return 'none'; - } - }, +const backgroundImage = props => { + if (props.windowIsFocused) { + if (props.depressed) { + return `linear-gradient(to bottom, ${ + colors.macOSTitleBarBorderBlur + } 1px, ${colors.macOSTitleBarButtonBorderBlur} 0%, ${ + colors.macOSTitleBarButtonBackgroundActive + } 100%)`; + } else { + return `linear-gradient(to bottom, transparent 0%,${ + colors.macOSTitleBarButtonBackground + } 100%)`; + } + } else { + return 'none'; + } +}; + +const color = props => { + if (props.type === 'danger' && props.windowIsFocused) { + return colors.red; + } else if (props.disabled) { + return colors.macOSTitleBarIconBlur; + } else { + return colors.light50; + } +}; + +const pulse = keyframes({ + '0%': { + boxShadow: `0 0 4px 0 ${colors.macOSTitleBarIconSelected}`, + }, + '70%': { + boxShadow: '0 0 4px 6px transparent', + }, + '100%': { + boxShadow: '0 0 4px 0 transparent', + }, +}); + +const StyledButton = styled('div')(props => ({ + backgroundColor: !props.windowIsFocused + ? colors.macOSTitleBarButtonBackgroundBlur + : colors.white, + backgroundImage: backgroundImage(props), + borderStyle: 'solid', + borderWidth: 1, + borderColor: borderColor(props), + borderBottomColor: borderBottomColor(props), + fontSize: props.compact === true ? 11 : '1em', + color: color(props), + borderRadius: 4, + position: 'relative', + padding: '0 6px', + height: props.compact === true ? 24 : 28, + margin: 0, + marginLeft: props.inButtonGroup === true ? 0 : 10, + 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)': { + 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': { + 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 ? "''" : '', + position: 'absolute', + bottom: 1, + right: 2, borderStyle: 'solid', - borderWidth: 1, - borderColor, - borderBottomColor, - fontSize: props => (props.compact === true ? 11 : '1em'), - color: props => { - if (props.type === 'danger' && props.windowIsFocused) { - return colors.red; - } else if (props.disabled) { - return colors.macOSTitleBarIconBlur; - } else { - return colors.light50; - } - }, - borderRadius: 4, - position: 'relative', - padding: '0 6px', - height: props => (props.compact === true ? 24 : 28), - margin: 0, - marginLeft: props => (props.inButtonGroup === true ? 0 : 10), - minWidth: 34, - display: 'inline-flex', - alignItems: 'center', - justifyContent: 'center', - flexShrink: 0, - - boxShadow: props => - props.pulse && props.windowIsFocused - ? `0 0 0 ${colors.macOSTitleBarIconSelected}` - : '', - animation: props => - props.pulse && props.windowIsFocused ? 'pulse 1s infinite' : '', - - '&:not(:first-child)': { - borderTopLeftRadius: props => (props.inButtonGroup === true ? 0 : 4), - borderBottomLeftRadius: props => (props.inButtonGroup === true ? 0 : 4), - }, - - '&:not(:last-child)': { - borderTopRightRadius: props => (props.inButtonGroup === true ? 0 : 4), - borderBottomRightRadius: props => (props.inButtonGroup === true ? 0 : 4), - borderRight: props => (props.inButtonGroup === true ? 0 : ''), - }, - - '&:first-of-type': { - marginLeft: 0, - }, - - '&:active': { - borderColor: colors.macOSTitleBarButtonBorder, - borderBottomColor: colors.macOSTitleBarButtonBorderBottom, - background: `linear-gradient(to bottom, ${ - colors.macOSTitleBarButtonBackgroundActiveHighlight - } 1px, ${colors.macOSTitleBarButtonBackgroundActive} 0%, ${ - colors.macOSTitleBarButtonBorderBlur - } 100%)`, - }, - - '&:disabled': { - borderColor, - borderBottomColor, - pointerEvents: 'none', - }, - - '&:hover::before': { - content: props => (props.dropdown ? "''" : ''), - position: 'absolute', - bottom: 1, - right: 2, - borderStyle: 'solid', - borderWidth: '4px 3px 0 3px', - borderColor: props => - `${colors.macOSTitleBarIcon} transparent transparent transparent`, - }, + borderWidth: '4px 3px 0 3px', + borderColor: `${ + colors.macOSTitleBarIcon + } transparent transparent transparent`, }, - { - ignoreAttributes: [ - 'dropdown', - 'dispatch', - 'compact', - 'large', - 'windowIsFocused', - 'inButtonGroup', - 'danger', - 'pulse', - ], - }, -); +})); -const Icon = Glyph.extends( - { - marginRight: props => (props.hasText ? 3 : 0), - }, - { - ignoreAttributes: ['hasText', 'type'], - }, -); +const Icon = styled(Glyph)(({hasText}) => ({ + marginRight: hasText ? 3 : 0, +})); type Props = { /** @@ -252,7 +245,7 @@ type State = { * @example Disabled button * */ -class Button extends styled.StylableComponent< +class Button extends React.Component< Props & {windowIsFocused: boolean}, State, > { @@ -350,25 +343,6 @@ class Button extends styled.StylableComponent< inButtonGroup={this.context.inButtonGroup}> {iconComponent} {children} - {this.props.pulse === true && ( -