2020-07-09 16:22:18 +02:00
|
|
|
import React from "react";
|
2020-07-08 19:36:36 +02:00
|
|
|
import styled from "styled-components";
|
|
|
|
|
2021-03-21 18:05:24 +01:00
|
|
|
interface IIconProps {
|
|
|
|
name: string;
|
|
|
|
size?: string;
|
|
|
|
}
|
|
|
|
|
2021-06-14 11:29:03 +02:00
|
|
|
interface IIconButtonProps {
|
2021-06-21 16:52:16 +02:00
|
|
|
testid?: string;
|
2021-06-14 11:29:03 +02:00
|
|
|
icon: string;
|
|
|
|
onClick: (e: React.FormEvent) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
const StyledButton = styled.button`
|
|
|
|
float: right;
|
|
|
|
border: none;
|
|
|
|
padding: 0;
|
|
|
|
background: none;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const IconContainer = styled.i`
|
|
|
|
font-family: "Material Icons";
|
|
|
|
font-weight: normal;
|
|
|
|
font-style: normal;
|
|
|
|
display: inline-block;
|
|
|
|
line-height: 1;
|
|
|
|
text-transform: none;
|
|
|
|
letter-spacing: normal;
|
|
|
|
word-wrap: normal;
|
|
|
|
white-space: nowrap;
|
|
|
|
direction: ltr;
|
|
|
|
-webkit-font-smoothing: antialiased;
|
|
|
|
text-rendering: optimizeLegibility;
|
|
|
|
-moz-osx-font-smoothing: grayscale;
|
|
|
|
font-feature-settings: "liga";
|
2021-06-21 16:52:16 +02:00
|
|
|
font-size: ${(props) => props.about};
|
2021-07-10 23:57:08 +02:00
|
|
|
color: ${(props) => props.theme.mainColor};
|
2021-06-14 11:29:03 +02:00
|
|
|
`;
|
|
|
|
|
2021-03-21 19:59:18 +01:00
|
|
|
/**
|
|
|
|
* Renders an Icon
|
2021-06-14 11:29:03 +02:00
|
|
|
* @param {IIconProps} props props needed for the given icon
|
|
|
|
* @returns {React.ReactNode} the icon node
|
2021-03-21 19:59:18 +01:00
|
|
|
*/
|
2021-06-14 21:10:28 +02:00
|
|
|
export const Icon = ({ name, size }: IIconProps) => (
|
2021-07-11 15:58:42 +02:00
|
|
|
<IconContainer about={size}>{name}</IconContainer>
|
2021-06-14 21:10:28 +02:00
|
|
|
);
|
2020-07-09 16:22:18 +02:00
|
|
|
|
2021-06-14 11:29:03 +02:00
|
|
|
/**
|
|
|
|
* Renders a button with an icon
|
|
|
|
* @param {IIconProps} props - The props of the given IconButton
|
|
|
|
* @returns {React.ReactNode} the icon button node
|
|
|
|
*/
|
2021-06-21 16:52:16 +02:00
|
|
|
export const IconButton = ({ testid, icon, onClick }: IIconButtonProps) => (
|
|
|
|
<StyledButton data-testid={testid} onClick={onClick}>
|
2021-06-14 11:29:03 +02:00
|
|
|
<Icon name={icon} />
|
|
|
|
</StyledButton>
|
|
|
|
);
|
|
|
|
|
2021-03-21 18:05:24 +01:00
|
|
|
export default Icon;
|