2022-04-09 15:47:04 +01:00
|
|
|
import { API } from "revolt.js";
|
2022-04-22 21:06:12 +01:00
|
|
|
import { Nullable } from "revolt.js/esm/util/null";
|
2022-01-14 18:50:58 +00:00
|
|
|
import styled, { css } from "styled-components/macro";
|
2021-06-19 12:34:53 +01:00
|
|
|
|
|
|
|
export interface IconBaseProps<T> {
|
2021-07-05 11:25:20 +01:00
|
|
|
target?: T;
|
2021-11-04 20:55:26 +00:00
|
|
|
url?: string;
|
2022-04-09 15:47:04 +01:00
|
|
|
attachment?: Nullable<API.File>;
|
2021-06-19 12:34:53 +01:00
|
|
|
|
2021-07-05 11:25:20 +01:00
|
|
|
size: number;
|
2021-08-03 15:37:19 +01:00
|
|
|
hover?: boolean;
|
2021-07-05 11:25:20 +01:00
|
|
|
animate?: boolean;
|
2021-06-19 12:34:53 +01:00
|
|
|
}
|
|
|
|
|
2021-06-19 15:29:04 +01:00
|
|
|
interface IconModifiers {
|
2021-08-30 23:39:02 +02:00
|
|
|
/**
|
|
|
|
* If this is undefined or null then the icon defaults to square, else uses the CSS variable given.
|
|
|
|
*/
|
|
|
|
borderRadius?: string;
|
2021-08-03 15:37:19 +01:00
|
|
|
hover?: boolean;
|
2021-06-19 15:29:04 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default styled.svg<IconModifiers>`
|
2021-07-05 11:25:20 +01:00
|
|
|
flex-shrink: 0;
|
2022-01-16 13:44:00 +01:00
|
|
|
cursor: pointer;
|
2021-07-05 11:25:20 +01:00
|
|
|
img {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
object-fit: cover;
|
|
|
|
|
|
|
|
${(props) =>
|
2021-08-30 23:39:02 +02:00
|
|
|
props.borderRadius &&
|
2021-07-05 11:25:20 +01:00
|
|
|
css`
|
2021-08-30 23:39:02 +02:00
|
|
|
border-radius: var(${props.borderRadius});
|
2021-07-05 11:25:20 +01:00
|
|
|
`}
|
|
|
|
}
|
2021-08-03 15:37:19 +01:00
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
props.hover &&
|
|
|
|
css`
|
|
|
|
&:hover .icon {
|
|
|
|
filter: brightness(0.8);
|
|
|
|
}
|
|
|
|
`}
|
2021-06-19 12:34:53 +01:00
|
|
|
`;
|
2021-06-19 15:29:04 +01:00
|
|
|
|
|
|
|
export const ImageIconBase = styled.img<IconModifiers>`
|
2021-07-05 11:25:20 +01:00
|
|
|
flex-shrink: 0;
|
|
|
|
object-fit: cover;
|
|
|
|
|
|
|
|
${(props) =>
|
2021-08-30 23:39:02 +02:00
|
|
|
props.borderRadius &&
|
2021-07-05 11:25:20 +01:00
|
|
|
css`
|
2021-08-30 23:39:02 +02:00
|
|
|
border-radius: var(${props.borderRadius});
|
2021-07-05 11:25:20 +01:00
|
|
|
`}
|
2021-08-03 15:37:19 +01:00
|
|
|
|
|
|
|
${(props) =>
|
|
|
|
props.hover &&
|
|
|
|
css`
|
|
|
|
&:hover img {
|
|
|
|
filter: brightness(0.8);
|
|
|
|
}
|
|
|
|
`}
|
2021-06-19 15:29:04 +01:00
|
|
|
`;
|