refactor(classnames): use faster classcat alternative

This commit is contained in:
moklick
2020-07-14 10:11:26 +02:00
parent dec1f973cb
commit 1b3f58486a
11 changed files with 43 additions and 25 deletions
@@ -1,5 +1,5 @@
import React, { memo, HTMLAttributes } from 'react';
import classnames from 'classnames';
import cc from 'classcat';
import { useStoreState } from '../../store/hooks';
import { BackgroundVariant } from '../../types';
@@ -25,7 +25,7 @@ const Background = memo(
const height = useStoreState((s) => s.height);
const [x, y, scale] = useStoreState((s) => s.transform);
const bgClasses = classnames('react-flow__background', className);
const bgClasses = cc(['react-flow__background', className]);
const bgColor = color ? color : defaultColors[variant];
const scaledGap = gap * scale;
const xOffset = x % scaledGap;
+2 -2
View File
@@ -1,5 +1,5 @@
import React from 'react';
import classnames from 'classnames';
import cc from 'classcat';
import { useStoreState, useStoreActions } from '../../store/hooks';
@@ -24,7 +24,7 @@ const Controls = ({ style, showZoom = true, showFitView = true, showInteractive
const zoomOut = useStoreActions((actions) => actions.zoomOut);
const isInteractive = useStoreState((s) => s.nodesDraggable && s.nodesConnectable && s.elementsSelectable);
const mapClasses = classnames('react-flow__controls', className);
const mapClasses = cc(['react-flow__controls', className]);
return (
<div className={mapClasses} style={style}>
+2 -2
View File
@@ -1,5 +1,5 @@
import React from 'react';
import classnames from 'classnames';
import cc from 'classcat';
import { useStoreState } from '../../store/hooks';
import { getRectOfNodes, getBoundsofRects } from '../../utils/graph';
@@ -31,7 +31,7 @@ const MiniMap = ({
const [tX, tY, tScale] = useStoreState((s) => s.transform);
const nodes = useStoreState((s) => s.nodes);
const mapClasses = classnames('react-flow__minimap', className);
const mapClasses = cc(['react-flow__minimap', className]);
const elementWidth = (style.width || defaultWidth)! as number;
const elementHeight = (style.height || defaultHeight)! as number;
const nodeColorFunc = (nodeColor instanceof Function ? nodeColor : () => nodeColor) as StringFunc;