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

75 lines
1.6 KiB
TypeScript
Raw Normal View History

import { getStaticDir } from "@utils/env";
import classNames from "classnames";
2021-02-22 02:39:04 +00:00
import { Component } from "inferno";
2023-06-22 00:54:35 +00:00
import { I18NextService } from "../../services";
2021-02-11 20:35:27 +00:00
interface IconProps {
icon: string;
classes?: string;
inline?: boolean;
small?: boolean;
2021-02-11 20:35:27 +00:00
}
export class Icon extends Component<IconProps, any> {
constructor(props: any, context: any) {
super(props, context);
}
render() {
return (
<svg
className={classNames("icon", this.props.classes, {
"icon-inline": this.props.inline,
small: this.props.small,
})}
>
<use
xlinkHref={`${getStaticDir()}/assets/symbols.svg#icon-${
this.props.icon
}`}
></use>
feat: Bootstrap 5 (#1378) * feat: Use Bootstrap 5; remove Bootstrap 4 * feat: Add link decoration override global var * fix: Change sr-only to visually-hidden * fix: Fix missing toggle button classes * fix: Use darker green to pass 3:1 contrast and allow foreground color generation * fix: Replace all mr- and ml- classes with me- (end) and ms- (start) classes * fix: Replace all pr- and pl- classes with pe- (end) and ps- (start) classes * fix: Replace custom-select with form-select d-inline-block * fix: Change max-width to Bootstrap 4's max-width * fix: Fix badge colors * fix: Replace deprecated btn-block class with d-block * fix: Temporary fix for missing btn-block styles * fix: Fix margin-left auto and margin-right auto * fix: Fix default border color * fix: Fix some button widths * fix: Fix form row margins * fix: Remove theme color maps; no longer necessary in Bootstrap 5 * fix: Remove unused gray * test commit * fix: Fix deprecated input-group-append usage * fix: Add missing col-form-label classes * fix: Fix some column widths * fix: Fix language dropdown style regression * fix: Fix toast background color * fix: Fix missing colors in red themes * fix: Fix default radio button appearance for toggles * fix: Fix missing margin in search form * fix: Fix search form widths * fix: Fix rate limit form columns * fix: Fix search filters layout * fix: Fix weird table background issue; re-compile from main updates * fix: Fix modlog filter layout * fix: Fix some horizontal margins * fix: Fix incorrect usage of input-group * chore: Empty commit to re-trigger Woodpecker job * fix: Fix incorrect Bootstrap 5 padding class * fix: Tighten up the home filter bars for the hell of it * fix: Fix home filter bar gap --------- Co-authored-by: SleeplessOne1917 <abias1122@gmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2023-06-20 12:01:29 +00:00
<div className="visually-hidden">
<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;
className?: string;
2021-07-17 20:21:31 +00:00
}
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={classNames("spin", this.props.className, {
"spinner-large": this.props.large,
})}
2021-07-17 20:21:31 +00:00
/>
);
2021-02-11 20:35:27 +00:00
}
}
export class PurgeWarning extends Component<any, any> {
constructor(props: any, context: any) {
super(props, context);
}
render() {
return (
2023-06-20 18:46:16 +00:00
<div className="purge-warning mt-2 alert alert-danger" role="alert">
feat: Bootstrap 5 (#1378) * feat: Use Bootstrap 5; remove Bootstrap 4 * feat: Add link decoration override global var * fix: Change sr-only to visually-hidden * fix: Fix missing toggle button classes * fix: Use darker green to pass 3:1 contrast and allow foreground color generation * fix: Replace all mr- and ml- classes with me- (end) and ms- (start) classes * fix: Replace all pr- and pl- classes with pe- (end) and ps- (start) classes * fix: Replace custom-select with form-select d-inline-block * fix: Change max-width to Bootstrap 4's max-width * fix: Fix badge colors * fix: Replace deprecated btn-block class with d-block * fix: Temporary fix for missing btn-block styles * fix: Fix margin-left auto and margin-right auto * fix: Fix default border color * fix: Fix some button widths * fix: Fix form row margins * fix: Remove theme color maps; no longer necessary in Bootstrap 5 * fix: Remove unused gray * test commit * fix: Fix deprecated input-group-append usage * fix: Add missing col-form-label classes * fix: Fix some column widths * fix: Fix language dropdown style regression * fix: Fix toast background color * fix: Fix missing colors in red themes * fix: Fix default radio button appearance for toggles * fix: Fix missing margin in search form * fix: Fix search form widths * fix: Fix rate limit form columns * fix: Fix search filters layout * fix: Fix weird table background issue; re-compile from main updates * fix: Fix modlog filter layout * fix: Fix some horizontal margins * fix: Fix incorrect usage of input-group * chore: Empty commit to re-trigger Woodpecker job * fix: Fix incorrect Bootstrap 5 padding class * fix: Tighten up the home filter bars for the hell of it * fix: Fix home filter bar gap --------- Co-authored-by: SleeplessOne1917 <abias1122@gmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2023-06-20 12:01:29 +00:00
<Icon icon="alert-triangle" classes="icon-inline me-2" />
2023-06-22 00:54:35 +00:00
{I18NextService.i18n.t("purge_warning")}
</div>
);
}
}