All files / app/ui/icon withIconContainer.tsx

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40107x 107x   107x 107x 107x 107x 107x                 107x     3638x 1208x 1208x 1208x 1208x 1208x                              
import classNames from 'classnames';
import React, { memo, ComponentType } from 'react';
 
export enum IconSize {
    Regular = 'regular',
    Small = 'small',
    Medium = 'medium',
    Large = 'large',
}
 
export interface IconProps {
    additionalClassName?: string;
    size?: IconSize;
    testId?: string;
}
 
export default function withIconContainer<TProps>(
    OriginalComponent: ComponentType<TProps>
): ComponentType<TProps & IconProps> {
    return memo(({
        additionalClassName,
        size,
        testId,
        ...rest
    }) => (
        <div
            className={ classNames(
                'icon',
                additionalClassName,
                size === IconSize.Small ? 'icon--small' : null,
                size === IconSize.Large ? 'icon--large' : null,
                size === IconSize.Medium ? 'icon--medium' : null
            ) }
            data-test={ testId }
        >
            <OriginalComponent { ...rest as TProps } />
        </div>
    ));
}