-
Notifications
You must be signed in to change notification settings - Fork 154
Upgrade guppy to styled components v4 #269
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,14 @@ import { configure, addDecorator } from '@storybook/react'; | |
import { COLORS } from '../src/constants'; | ||
import Wrapper from './components/Wrapper'; | ||
|
||
import '../src/global-styles'; | ||
import GlobalStyles from '../src/global-styles'; | ||
|
||
const WrapperDecorator = storyFn => <Wrapper>{storyFn()}</Wrapper>; | ||
const WrapperDecorator = storyFn => ( | ||
<> | ||
<GlobalStyles /> | ||
<Wrapper>{storyFn()}</Wrapper> | ||
</> | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! |
||
|
||
addDecorator(WrapperDecorator); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,7 +132,7 @@ | |
"sass-loader": "7.0.0", | ||
"slug": "0.9.1", | ||
"style-loader": "0.19.1", | ||
"styled-components": "3.2.6", | ||
"styled-components": "^4.0.0-beta.9", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: We tend to prefer exact versions, without the You can specify this when installing by doing |
||
"svgr": "1.8.1", | ||
"sw-precache-webpack-plugin": "0.11.4", | ||
"thread-loader": "1.1.2", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
* with styled-components. Just gonna override the provided global styles. | ||
*/ | ||
import React, { Component } from 'react'; | ||
import styled, { injectGlobal } from 'styled-components'; | ||
import styled, { createGlobalStyle } from 'styled-components'; | ||
import { SearchBox } from 'react-instantsearch/dom'; | ||
|
||
import { COLORS } from '../../constants'; | ||
|
@@ -18,6 +18,7 @@ class AddDependencySearchBox extends Component<Props> { | |
render() { | ||
return ( | ||
<Wrapper> | ||
<SearchBoxGlobalStyle /> | ||
<SearchBox | ||
onChange={this.props.onChange} | ||
autoFocus={true} | ||
|
@@ -33,7 +34,7 @@ const Wrapper = styled.div` | |
width: 100%; | ||
`; | ||
|
||
injectGlobal` | ||
const SearchBoxGlobalStyle = createGlobalStyle` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is so much nicer :D |
||
.ais-SearchBox { | ||
/* width: 100%; */ | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,11 +37,13 @@ class ProjectName extends PureComponent<Props, State> { | |
showRandomizeTooltip: false, | ||
}; | ||
|
||
node: HTMLElement; | ||
node: ?HTMLElement; | ||
timeoutId: number; | ||
|
||
componentDidMount() { | ||
this.node.focus(); | ||
if (this.node) { | ||
this.node.focus(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hah, nice. Digging that switching to |
||
|
||
this.timeoutId = window.setTimeout(() => { | ||
this.setState({ showRandomizeTooltip: true }); | ||
|
@@ -175,7 +177,7 @@ class ProjectName extends PureComponent<Props, State> { | |
hasError={isProjectNameTaken} | ||
> | ||
<TextInput | ||
innerRef={node => (this.node = node)} | ||
ref={node => (this.node = node)} | ||
type="text" | ||
value={randomizedOverrideName || name} | ||
isFocused={isFocused} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ type State = { | |
class WhimsicalInstaller extends PureComponent<Props, State> { | ||
tickId: ?number; | ||
generationLoopId: ?number; | ||
wrapperNode: HTMLElement; | ||
wrapperNode: ?HTMLElement; | ||
wrapperBoundingBox: ClientRect; | ||
lastCoordinate: Point; | ||
|
||
|
@@ -68,10 +68,12 @@ class WhimsicalInstaller extends PureComponent<Props, State> { | |
|
||
toggleRunning = () => { | ||
if (this.props.isRunning) { | ||
this.wrapperBoundingBox = this.wrapperNode.getBoundingClientRect(); | ||
if (this.wrapperNode) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can roll this into the previous condition: if (this.props.isRunning && this.wrapperNode) { I like reducing nested conditionals, when possible. |
||
this.wrapperBoundingBox = this.wrapperNode.getBoundingClientRect(); | ||
|
||
this.fileGenerationLoop(); | ||
this.tick(); | ||
this.fileGenerationLoop(); | ||
this.tick(); | ||
} | ||
} else if (!this.props.isRunning) { | ||
window.clearTimeout(this.generationLoopId); | ||
window.cancelAnimationFrame(this.tickId); | ||
|
@@ -586,7 +588,7 @@ class WhimsicalInstaller extends PureComponent<Props, State> { | |
const filesArray = Object.keys(files).map(fileId => files[fileId]); | ||
|
||
return ( | ||
<Wrapper width={width} innerRef={node => (this.wrapperNode = node)}> | ||
<Wrapper width={width} ref={node => (this.wrapperNode = node)}> | ||
<PlanetContainer size={height}> | ||
<Earth size={height * 0.4} /> | ||
</PlanetContainer> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We've been using
Fragment
instead of<>
in this project:It does exactly the same thing, but it's a bit more google-able, so for folks who haven't seen it before, it's not as mysterious/magical.