нужно выжать максимум. Что выпилить, что бы стало гарантированно быстрее? Испльзуем jss, material-ui
https://take.ms/NFOEl
const styles = theme => ({
button: {
textTransform: 'none',
minWidth: 0,
minHeight: 0,
paddingTop: 0,
paddingLeft: (theme.spacing.unit / 2) + (theme.spacing.unit / 4),
paddingRight: (theme.spacing.unit / 2) + (theme.spacing.unit / 4),
paddingBottom: 0,
fontWeight: 500,
color: gray[500],
height: 24,
fontSize: 12,
pointerEvents: 'auto !important'
},
icon: {
color: grey[500],
fontSize: '15px'
},
text: {
maxWidth: 100,
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
fontSize: '0.75rem',
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
fontWeight: 400,
lineHeight: 1.66,
letterSpacing: '0.03333em'
}
});
// eslint-disable-next-line
class Size extends Component {
static propTypes = {
isCompact: PropTypes.bool,
isDisabled: PropTypes.bool,
cardId: PropTypes.number.isRequired,
classes: PropTypes.object.isRequired,
text: PropTypes.string.isRequired,
isPopoverOpen: PropTypes.bool.isRequired,
onPopoverClose: PropTypes.func.isRequired,
onPopoverOpen: PropTypes.func.isRequired,
anchorEl: PropTypes.any,
className: PropTypes.string,
iconClassName: PropTypes.string
};
static defaultProps = {
anchorEl: null,
isDisabled: false,
isCompact: false,
className: '',
iconClassName: '',
classes: {}
};
handleSave = (sizeText) => {
const { cardId, onPopoverClose } = this.props;
onPopoverClose();
store.dispatch(saveCard(cardId, { size_text: sizeText }))
.catch((error) => {
showRequestError(error);
captureException(error);
});
}
render () {
const {
classes, className,
text, isCompact, isPopoverOpen, anchorEl,
onPopoverClose, onPopoverOpen, isDisabled,
iconClassName
} = this.props;
return (
<Fragment>
<Button
onClick={isDisabled ? _.noop : onPopoverOpen}
className={cn(classes.button, className)}
>
<FlashOnIcon
fontSize="small"
className={cn(classes.icon, iconClassName)}
/>
<If condition={!isCompact}>
<div className={classes.text}>{text}</div>
</If>
</Button>
<If condition={!isDisabled && isPopoverOpen}>
<CardEstimatePopover
anchorEl={anchorEl}
isPopoverOpen={isPopoverOpen}
value={text}
onPopoverClose={onPopoverClose}
onSave={this.handleSave}
/>
</If>
</Fragment>
);
}
}
export default compose(
React.memo,
withStyles(styles),
withPopoverToggler
)(Size);
18ms это наверное в dev?
не юзай матириал, не юзай рантайм стили
Обсуждают сегодня