Skip to content

Commit 4d62a07

Browse files
Merge pull request LucasBassetti#188 from pascalgagneur/Update-styled-components-v4
Update styled components to v4
2 parents 058cd38 + 855a5e5 commit 4d62a07

File tree

7 files changed

+107
-52
lines changed

7 files changed

+107
-52
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ language: node_js
22
node_js:
33
- 8
44
before_install:
5-
- "npm install [email protected] [email protected] styled-components@3.4.10"
5+
- "npm install [email protected] [email protected] styled-components@4.1.3"

lib/ChatBot.jsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ class ChatBot extends Component {
3131
constructor(props) {
3232
super(props);
3333

34+
this.content = null;
35+
this.input = null;
36+
37+
this.setContentRef = (element) => {
38+
this.content = element;
39+
};
40+
41+
this.setInputRef = (element) => {
42+
this.input = element;
43+
};
44+
45+
3446
this.state = {
3547
renderedSteps: [],
3648
previousSteps: [],
@@ -665,7 +677,7 @@ class ChatBot extends Component {
665677
{!hideHeader && header}
666678
<Content
667679
className="rsc-content"
668-
innerRef={contentRef => (this.content = contentRef)}
680+
ref={this.setContentRef}
669681
floating={floating}
670682
style={contentStyle}
671683
height={height}
@@ -679,7 +691,7 @@ class ChatBot extends Component {
679691
<Input
680692
type="textarea"
681693
style={inputStyle}
682-
innerRef={inputRef => (this.input = inputRef)}
694+
ref={this.setInputRef}
683695
className="rsc-input"
684696
placeholder={inputInvalid ? '' : inputPlaceholder}
685697
onKeyPress={this.handleKeyPress}

lib/components/Input.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import styled from 'styled-components';
21
import { invalidInput } from '../common/animations';
2+
import styled, { css } from 'styled-components';
33

44
const Input = styled.input`
5-
animation: ${props => props.invalid ? `${invalidInput} .2s ease` : ''};
5+
animation: ${props => props.invalid ? css`${invalidInput} .2s ease` : ''};
66
border: 0;
77
border-radius: 0;
88
border-bottom-left-radius: 10px;

lib/components/SubmitButton.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import styled from 'styled-components';
1+
import styled, { css } from 'styled-components';
22
import defaultTheme from '../theme';
33
import { pulse } from '../common/animations';
44

@@ -31,7 +31,7 @@ const SubmitButton = styled.button`
3131
height: 23px;
3232
border-radius: 50%;
3333
animation: ${({ theme, speaking }) =>
34-
speaking ? `${pulse(theme.headerBgColor)} 2s ease infinite` : ''};
34+
speaking ? css`${pulse(theme.headerBgColor)} 2s ease infinite` : ''};
3535
}
3636
&:not(:disabled):hover {
3737
opacity: 0.7;

package-lock.json

Lines changed: 77 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"react-addons-test-utils": "^15.6.2",
7575
"react-test-renderer": "^16.0.0",
7676
"sinon": "^7.1.0",
77-
"styled-components": "^3.4.10",
77+
"styled-components": "^4.1.3",
7878
"uglifyjs-webpack-plugin": "^0.4.6",
7979
"webpack": "^4.23.1",
8080
"webpack-bundle-analyzer": "^2.13.1",
@@ -89,8 +89,8 @@
8989
"react-dom": "^16.4.1"
9090
},
9191
"peerDependencies": {
92-
"styled-components": ">= 2.0.0 < 4",
93-
"react": "^16.x",
94-
"react-dom": "^16.x"
92+
"styled-components": "^4.0.0",
93+
"react": "^16.3.0",
94+
"react-dom": "^16.3.0"
9595
}
96-
}
96+
}

tests/lib/SubmitButton.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,10 @@ describe('SubmitButton', () => {
1414
const wrapper = mount(<SubmitButton invalid={true} />);
1515
expect(wrapper.props().invalid).to.be.equal(true);
1616
});
17+
18+
it('should render a speaking button', () => {
19+
const wrapper = mount(<SubmitButton speaking={true} />);
20+
expect(wrapper.props().speaking).to.be.equal(true);
21+
});
22+
1723
});

0 commit comments

Comments
 (0)