@ozen-ui/kit
Version:
React component library
38 lines (37 loc) • 2.03 kB
JavaScript
import { __assign, __rest } from "tslib";
import './FileIcon.css';
import React from 'react';
import { QuestionCircleOutlineIcon, WarningTriangleOutlineIcon, } from '@ozen-ui/icons';
import { useThemeProps } from '../../hooks/useThemeProps';
import { cn } from '../../utils/classname';
import { polymorphicComponentWithRef } from '../../utils/polymorphicComponentWithRef';
import { renderContent } from '../../utils/renderContent';
import { Loader } from '../Loader';
import { FILE_ICON_DEFAULT_COLOR, FILE_ICON_DEFAULT_SIZE, FILE_ICON_DEFAULT_STATUS, FILE_ICON_DEFAULT_TAG, } from './constants';
export var cnFileIcon = cn('FileIcon');
export var FileIcon = polymorphicComponentWithRef(function (inProps, ref) {
var props = useThemeProps({
props: inProps,
name: 'FileIcon',
});
var _a = props.as, Tag = _a === void 0 ? FILE_ICON_DEFAULT_TAG : _a, className = props.className, _b = props.status, status = _b === void 0 ? FILE_ICON_DEFAULT_STATUS : _b, children = props.children, _c = props.color, color = _c === void 0 ? FILE_ICON_DEFAULT_COLOR : _c, _d = props.size, size = _d === void 0 ? FILE_ICON_DEFAULT_SIZE : _d, other = __rest(props, ["as", "className", "status", "children", "color", "size"]);
var iconSize = 's';
var content = (function () {
if (status === 'loading') {
return React.createElement(Loader, { color: "currentcolor", size: iconSize });
}
if (status === 'error') {
return React.createElement(WarningTriangleOutlineIcon, { size: iconSize });
}
if (status === 'unknown') {
return React.createElement(QuestionCircleOutlineIcon, { size: iconSize });
}
return renderContent({ content: children, props: { size: iconSize } });
})();
return (React.createElement(Tag, __assign({}, other, { ref: ref, className: cnFileIcon({
status: status,
color: color,
size: size,
}, [className]) }), content));
});
FileIcon.displayName = 'FileIcon';