convert to emotion
Summary: My benchmarks have shown react-emotion to be faster than the current implementation of `styled`. For this reason, I am converting all styling to [emotion](https://emotion.sh). Benchmark results: {F136839093} The syntax is very similar between the two libraries. The main difference is that emotion only allows a single function for the whole style attribute, whereas the old implementation had functions for every style-attirbute. Before: ``` { color: props => props.color, fontSize: props => props.size, } ``` After: ``` props => ({ color: props.color, fontSize: props.size, }) ``` Reviewed By: jknoxville Differential Revision: D9479893 fbshipit-source-id: 2c39e4618f7e52ceacb67bbec8ae26114025723f
This commit is contained in:
committed by
Facebook Github Bot
parent
4151c73409
commit
726966fdc0
@@ -9,11 +9,11 @@ import React from 'react';
|
||||
import styled from '../styled/index.js';
|
||||
import {colors} from './colors.js';
|
||||
|
||||
export const StyledButton = styled.view({
|
||||
export const StyledButton = styled('div')(props => ({
|
||||
cursor: 'pointer',
|
||||
width: '30px',
|
||||
height: '16px',
|
||||
background: props => (props.toggled ? colors.green : colors.grey),
|
||||
background: props.toggled ? colors.green : colors.grey,
|
||||
display: 'block',
|
||||
borderRadius: '100px',
|
||||
position: 'relative',
|
||||
@@ -22,14 +22,14 @@ export const StyledButton = styled.view({
|
||||
content: `''`,
|
||||
position: 'absolute',
|
||||
top: '3px',
|
||||
left: props => (props.toggled ? '18px' : '3px'),
|
||||
left: props.toggled ? '18px' : '3px',
|
||||
width: '10px',
|
||||
height: '10px',
|
||||
background: 'white',
|
||||
borderRadius: '100px',
|
||||
transition: 'all cubic-bezier(0.3, 1.5, 0.7, 1) 0.3s',
|
||||
},
|
||||
});
|
||||
}));
|
||||
|
||||
type Props = {
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ type Props = {
|
||||
* <ToggleButton onClick={handler} toggled={boolean}/>
|
||||
* ```
|
||||
*/
|
||||
export default class ToggleButton extends styled.StylableComponent<Props> {
|
||||
export default class ToggleButton extends React.Component<Props> {
|
||||
render() {
|
||||
return (
|
||||
<StyledButton toggled={this.props.toggled} onClick={this.props.onClick} />
|
||||
|
||||
Reference in New Issue
Block a user