2020-03-23 15:35:58 +01:00
|
|
|
/*
|
2024-09-24 09:42:07 +02:00
|
|
|
* Copyright (c) 2020 - present Cloudogu GmbH
|
2020-03-23 15:35:58 +01:00
|
|
|
*
|
2024-09-24 09:42:07 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify it under
|
|
|
|
|
* the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
|
* Software Foundation, version 3.
|
2020-03-23 15:35:58 +01:00
|
|
|
*
|
2024-09-24 09:42:07 +02:00
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
|
* details.
|
2020-03-23 15:35:58 +01:00
|
|
|
*
|
2024-09-24 09:42:07 +02:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see https://www.gnu.org/licenses/.
|
2020-03-23 15:35:58 +01:00
|
|
|
*/
|
2024-09-24 09:42:07 +02:00
|
|
|
|
2021-11-01 16:54:58 +01:00
|
|
|
import React, { FC } from "react";
|
2019-10-20 16:59:02 +02:00
|
|
|
import classNames from "classnames";
|
2020-08-11 10:34:29 +02:00
|
|
|
import { createAttributesForTesting } from "./devBuild";
|
2019-10-19 16:38:07 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
title?: string;
|
2021-11-01 16:54:58 +01:00
|
|
|
iconStyle?: string;
|
2019-10-19 16:38:07 +02:00
|
|
|
name: string;
|
2021-11-01 16:54:58 +01:00
|
|
|
color?: string;
|
2019-10-19 16:38:07 +02:00
|
|
|
className?: string;
|
2021-03-03 09:52:18 +01:00
|
|
|
onClick?: (event: React.MouseEvent) => void;
|
2021-11-01 16:54:58 +01:00
|
|
|
onEnter?: (event: React.KeyboardEvent) => void;
|
2020-08-11 10:34:29 +02:00
|
|
|
testId?: string;
|
2021-11-01 16:54:58 +01:00
|
|
|
tabIndex?: number;
|
2021-11-03 10:11:40 +01:00
|
|
|
alt?: string;
|
2019-10-19 16:38:07 +02:00
|
|
|
};
|
|
|
|
|
|
2023-09-05 08:53:03 +02:00
|
|
|
/**
|
|
|
|
|
* @deprecated
|
|
|
|
|
*/
|
2021-11-01 16:54:58 +01:00
|
|
|
const Icon: FC<Props> = ({
|
|
|
|
|
iconStyle = "fas",
|
2021-12-16 17:54:39 +01:00
|
|
|
color = "secondary",
|
2021-11-01 16:54:58 +01:00
|
|
|
title,
|
|
|
|
|
name,
|
|
|
|
|
className,
|
|
|
|
|
onClick,
|
|
|
|
|
testId,
|
2021-11-29 13:57:05 +01:00
|
|
|
tabIndex,
|
2021-11-01 16:54:58 +01:00
|
|
|
onEnter,
|
2023-09-05 08:53:03 +02:00
|
|
|
alt = title,
|
2021-11-01 16:54:58 +01:00
|
|
|
}) => {
|
|
|
|
|
return (
|
|
|
|
|
<i
|
|
|
|
|
onClick={onClick}
|
2023-09-05 08:53:03 +02:00
|
|
|
onKeyPress={(event) => event.key === "Enter" && onEnter && onEnter(event)}
|
2021-11-01 16:54:58 +01:00
|
|
|
title={title}
|
|
|
|
|
className={classNames(iconStyle, "fa-fw", "fa-" + name, `has-text-${color}`, className)}
|
|
|
|
|
tabIndex={tabIndex}
|
2021-11-03 10:11:40 +01:00
|
|
|
aria-label={alt}
|
2021-11-01 16:54:58 +01:00
|
|
|
{...createAttributesForTesting(testId)}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
2019-10-19 16:38:07 +02:00
|
|
|
|
2021-11-01 16:54:58 +01:00
|
|
|
export default Icon;
|