UNPKG

@selfcommunity/react-ui

Version:

React UI Components to integrate a Community created with SelfCommunity Platform.

24 lines (23 loc) 1.22 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import classNames from 'classnames'; import { Box, Link, Typography, Icon, styled } from '@mui/material'; import { MEDIA_TYPE_DOCUMENT } from '../../constants/Media'; const PREFIX = 'SCLessonFilePreview'; const classes = { root: `${PREFIX}-root`, item: `${PREFIX}-item`, title: `${PREFIX}-title` }; const Root = styled(Box, { name: PREFIX, slot: 'Root', overridesResolver: (props, styles) => styles.root })(() => ({})); export default function LessonFilePreview(props) { // PROPS const { className, media } = props; /** * Renders component */ return (_jsx(Root, Object.assign({ className: classNames(classes.root, className), sx: { backgroundImage: `url(${(media === null || media === void 0 ? void 0 : media.image_thumbnail) ? media.image_thumbnail.url : media.image})` } }, { children: media.title && (_jsx(Link, Object.assign({ href: media.url, target: "_blank", rel: "noopener noreferrer" }, { children: _jsxs(Typography, Object.assign({ className: classes.title }, { children: [media.type === MEDIA_TYPE_DOCUMENT && _jsx(Icon, { children: "picture_as_pdf" }), media.title] })) }))) }), media.id)); }