UNPKG

@selfcommunity/react-ui

Version:

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

52 lines (45 loc) 3.27 kB
import { __rest } from "tslib"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import React from 'react'; import Widget from '../Widget'; import { styled } from '@mui/material/styles'; import Skeleton from '@mui/material/Skeleton'; import { SCFeedObjectTemplateType } from '../../types/feedObject'; import { CardContent, CardHeader, useTheme } from '@mui/material'; import classNames from 'classnames'; import { PREFIX } from './constants'; const classes = { root: `${PREFIX}-skeleton-root`, media: `${PREFIX}-media` }; const Root = styled(Widget, { name: PREFIX, slot: 'SkeletonRoot' })(() => ({})); /** * > API documentation for the Community-JS Feed Object Skeleton component. Learn about the available props and the CSS API. #### Import ```jsx import {FeedObjectSkeleton} from '@selfcommunity/react-ui'; ``` #### Component Name The name `SCFeedObject-skeleton-root` can be used when providing style overrides in the theme. #### CSS |Rule Name|Global class|Description| |---|---|---| |root|.SCFeedObject-skeleton-root|Styles applied to the root element.| |media|.SCFeedObject-media|Styles applied to the media element.| * */ export default function FeedObjectSkeleton(props) { const { template = SCFeedObjectTemplateType.SNIPPET } = props, rest = __rest(props, ["template"]); const theme = useTheme(); let obj; if (template === SCFeedObjectTemplateType.PREVIEW || template === SCFeedObjectTemplateType.DETAIL || template === SCFeedObjectTemplateType.SEARCH) { obj = (_jsxs(React.Fragment, { children: [_jsx(CardHeader, { avatar: _jsx(Skeleton, { animation: "wave", variant: "circular", width: theme.selfcommunity.user.avatar.sizeMedium, height: theme.selfcommunity.user.avatar.sizeMedium }), title: _jsx(Skeleton, { animation: "wave", height: 10, width: "80%", style: { marginBottom: 6 } }), subheader: _jsx(Skeleton, { animation: "wave", height: 10, width: "40%" }) }), _jsx(Skeleton, { animation: "wave", variant: "rectangular", className: classes.media }), _jsx(CardContent, { children: _jsxs(React.Fragment, { children: [_jsx(Skeleton, { animation: "wave", height: 10, style: { marginBottom: 6 } }), _jsx(Skeleton, { animation: "wave", height: 10, width: "80%", style: { marginBottom: 6 } }), _jsx(Skeleton, { animation: "wave", height: 10, width: "60%" })] }) })] })); } else { obj = (_jsxs(React.Fragment, { children: [_jsx(CardHeader, { avatar: _jsx(Skeleton, { animation: "wave", variant: "circular", width: theme.selfcommunity.user.avatar.sizeMedium, height: theme.selfcommunity.user.avatar.sizeMedium }), title: _jsx(Skeleton, { animation: "wave", height: 10, width: "80%", style: { marginBottom: 6 } }), subheader: _jsx(Skeleton, { animation: "wave", height: 10, width: "40%" }) }), _jsx(CardContent, { children: _jsxs(React.Fragment, { children: [_jsx(Skeleton, { animation: "wave", height: 10, style: { marginBottom: 6 } }), _jsx(Skeleton, { animation: "wave", height: 10, width: "80%", style: { marginBottom: 6 } }), _jsx(Skeleton, { animation: "wave", height: 10, width: "60%", style: { marginBottom: 6 } })] }) })] })); } return (_jsx(Root, Object.assign({ className: classNames(classes.root, `${PREFIX}-${template}`) }, rest, { children: obj }))); }