lemmy-ui/src/shared/components/common/icon.tsx

43 lines
804 B
TypeScript
Raw Normal View History

2021-02-22 02:39:04 +00:00
import { Component } from "inferno";
2021-02-11 20:35:27 +00:00
interface IconProps {
icon: string;
classes?: string;
}
export class Icon extends Component<IconProps, any> {
constructor(props: any, context: any) {
super(props, context);
}
render() {
return (
<svg class={`icon ${this.props.classes}`}>
2021-07-16 16:51:54 +00:00
<use xlinkHref={`#icon-${this.props.icon}`}></use>
<div class="sr-only">
<title>{this.props.icon}</title>
</div>
2021-02-11 20:35:27 +00:00
</svg>
);
}
}
2021-07-17 20:21:31 +00:00
interface SpinnerProps {
large?: boolean;
}
export class Spinner extends Component<SpinnerProps, any> {
2021-02-11 20:35:27 +00:00
constructor(props: any, context: any) {
super(props, context);
}
render() {
2021-07-17 20:21:31 +00:00
return (
<Icon
icon="spinner"
classes={`spin ${this.props.large && "spinner-large"}`}
/>
);
2021-02-11 20:35:27 +00:00
}
}