@selfcommunity/react-templates
Version:
React Templates Components to integrate a Community created with SelfCommunity.
61 lines (54 loc) • 2.32 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Box, styled } from '@mui/material';
import { GroupHeader } from '@selfcommunity/react-ui';
import { useSCFetchGroup } from '@selfcommunity/react-core';
import GroupSkeletonTemplate from './Skeleton';
import { useThemeProps } from '@mui/system';
import classNames from 'classnames';
import { PREFIX } from './constants';
import GroupFeed from '../GroupFeed';
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 group's template.
* Take a look at our <strong>demo</strong> component [here](/docs/sdk/community-js/react-templates/Components/Group)
#### Import
```jsx
import {Group} from '@selfcommunity/react-templates';
```
#### Component Name
The name `SCGroupTemplate` can be used when providing style overrides in the theme.
#### CSS
|Rule Name|Global class|Description|
|---|---|---|
|root|.SCGroupTemplate-root|Styles applied to the root element.|
|feed|.SCGroupTemplate-feed|Styles applied to the feed element.|
*
* @param inProps
*/
export default function Group(inProps) {
// PROPS
const props = useThemeProps({
props: inProps,
name: PREFIX
});
const { id = 'group', className, group, groupId, widgets, FeedObjectProps, FeedSidebarProps, GroupFeedProps = {}, GroupHeaderProps = {} } = props;
// HOOKS
const { scGroup, setSCGroup } = useSCFetchGroup({ id: groupId, group });
const handleSubscribe = (group, status) => {
setSCGroup(Object.assign({}, scGroup, { subscription_status: status }));
};
if (!scGroup) {
return _jsx(GroupSkeletonTemplate, {});
}
return (_jsxs(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, { children: [_jsx(GroupHeader, Object.assign({ groupId: scGroup.id, GroupSubscribeButtonProps: { onSubscribe: handleSubscribe } }, GroupHeaderProps)), _jsx(GroupFeed, Object.assign({ className: classes.feed, group: scGroup, widgets: widgets, FeedObjectProps: FeedObjectProps, FeedSidebarProps: FeedSidebarProps }, GroupFeedProps))] })));
}