@selfcommunity/react-templates
Version:
React Templates Components to integrate a Community created with SelfCommunity.
62 lines (55 loc) • 2.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const material_1 = require("@mui/material");
const react_ui_1 = require("@selfcommunity/react-ui");
const CategoryFeed_1 = tslib_1.__importDefault(require("../CategoryFeed"));
const react_core_1 = require("@selfcommunity/react-core");
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
const system_1 = require("@mui/system");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const constants_1 = require("./constants");
const classes = {
root: `${constants_1.PREFIX}-root`,
feed: `${constants_1.PREFIX}-feed`
};
const Root = (0, material_1.styled)(material_1.Box, {
name: constants_1.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
*/
function Category(inProps) {
// PROPS
const props = (0, system_1.useThemeProps)({
props: inProps,
name: constants_1.PREFIX
});
const { id = 'category', className, category, categoryId, widgets, FeedObjectProps, FeedSidebarProps, CategoryFeedProps = {} } = props;
// Hooks
const { scCategory } = (0, react_core_1.useSCFetchCategory)({ id: categoryId, category });
if (!scCategory) {
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, {});
}
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, { children: [(0, jsx_runtime_1.jsx)(react_ui_1.CategoryHeader, { category: scCategory }), (0, jsx_runtime_1.jsx)(CategoryFeed_1.default, Object.assign({ className: classes.feed, category: scCategory, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, CategoryFeedProps))] })));
}
exports.default = Category;