UNPKG

@selfcommunity/react-templates

Version:

React Templates Components to integrate a Community created with SelfCommunity.

58 lines (51 loc) 2.12 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { Box, styled } from '@mui/material'; import { CategoryHeader } from '@selfcommunity/react-ui'; import CategoryFeed from '../CategoryFeed'; import { useSCFetchCategory } from '@selfcommunity/react-core'; import CategorySkeleton from './Skeleton'; import { useThemeProps } from '@mui/system'; import classNames from 'classnames'; import { PREFIX } from './constants'; const classes = { root: `${PREFIX}-root`, feed: `${PREFIX}-feed` }; const Root = styled(Box, { name: PREFIX, slot: 'Root' })(() => ({})); /** * > API documentation for the Community-JS Category Template. Learn about the available props and the CSS API. * * * This component renders a specific category's template. * Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-templates/Components/Category) #### Import ```jsx import {Category} from '@selfcommunity/react-templates'; ``` #### Component Name The name `SCCategoryTemplate` can be used when providing style overrides in the theme. #### CSS |Rule Name|Global class|Description| |---|---|---| |root|.SCCategoryTemplate-root|Styles applied to the root element.| |feed|.SCCategoryTemplate-feed|Styles applied to the feed element.| * * @param inProps */ export default function Category(inProps) { // PROPS const props = useThemeProps({ props: inProps, name: PREFIX }); const { id = 'category', className, category, categoryId, widgets, FeedObjectProps, FeedSidebarProps, CategoryFeedProps = {} } = props; // Hooks const { scCategory } = useSCFetchCategory({ id: categoryId, category }); if (!scCategory) { return _jsx(CategorySkeleton, {}); } return (_jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: [_jsx(CategoryHeader, { category: scCategory }), _jsx(CategoryFeed, Object.assign({ className: classes.feed, category: scCategory, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, CategoryFeedProps))] }))); }