fleet/frontend/components/Icon/Icon.tsx
Gabriel Hernandez e71307e11a
add passed policies column to inherited policies table. Add new colors and add to icons. (#8524)
* Merge branch 'main' of https://github.com/fleetdm/fleet into chore/testing-docs-on-contribution
add passing columns to inherited policies table

* add updated colors and applied them to icons

* change policy tables to use buildQueryString
2022-11-07 17:13:11 +00:00

44 lines
1.1 KiB
TypeScript

import React, { useMemo } from "react";
import classnames from "classnames";
import { IconNames, ICON_MAP } from "components/icons";
import { Colors } from "styles/var/colors";
interface IIconProps {
name: IconNames;
color?: Colors;
direction?: "up" | "down" | "left" | "right";
className?: string;
size?: "small" | "medium";
}
const baseClass = "icon";
const Icon = ({ name, color, direction, className, size }: IIconProps) => {
const classNames = classnames(baseClass, className);
// createPassedProps creates a props object that we pass to the specific icon
// for values that are not null or undefined
const props = useMemo(() => {
const createPassedProps = () => {
return Object.assign(
{},
color === undefined ? undefined : { color },
direction === undefined ? undefined : { direction },
size === undefined ? undefined : { size }
);
};
return createPassedProps();
}, [color, direction, size]);
const IconComponent = ICON_MAP[name];
return (
<div className={classNames}>
<IconComponent {...props} />
</div>
);
};
export default Icon;