import * as React from "react"; import {ClientIconRenderer} from "tc-shared/ui/react-elements/Icons"; import {ClientIcon} from "svg-sprites/client-icons"; import {getIconManager, RemoteIcon, RemoteIconInfo} from "tc-shared/file/Icons"; import {useState} from "react"; const cssStyle = require("./Icon.scss"); export const IconEmpty = React.memo((props: { className?: string, title?: string }) => (
)); export const IconLoading = React.memo((props: { className?: string, title?: string }) => (
)); export const IconError = React.memo((props: { className?: string, title?: string }) => ( )); export const IconUrl = React.memo((props: { iconUrl: string, className?: string, title?: string }) => (
{props.title}
)); export const IconRenderer = React.memo((props: { icon: string; title?: string; className?: string; }) => { if(!props.icon) { return
; } else if(typeof props.icon === "string") { return
; } else { throw "JQuery icons are not longer supported"; } }); export const RemoteIconRenderer = React.memo((props: { icon: RemoteIcon | undefined, className?: string, title?: string }) => { const [ revision, setRevision ] = useState(0); props.icon.events.reactUse("notify_state_changed", () => setRevision(revision + 1)); switch (props.icon.getState()) { case "empty": case "destroyed": return ( ); case "loaded": if(props.icon.iconId >= 0 && props.icon.iconId <= 1000) { if(props.icon.iconId === 0) { return ( ); } return
; } return ( ); case "loading": return ( ); case "error": return ( ); default: throw "invalid icon state"; } }); export const RemoteIconInfoRenderer = React.memo((props: { icon: RemoteIconInfo | undefined, className?: string, title?: string }) => { if(!props.icon || props.icon.iconId === 0) { return ; } else { return ; } });