@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
75 lines (66 loc) • 4.26 kB
JavaScript
import { __rest } from "tslib";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { styled } from '@mui/material/styles';
import { Box, Typography } from '@mui/material';
import classNames from 'classnames';
import Widget from '../../components/Widget';
import { useThemeProps } from '@mui/system';
import NewChip from '../NewChip/NewChip';
import { SCNotificationObjectTemplateType } from '../../types/notification';
const PREFIX = 'SCNotificationItem';
const classes = {
root: `${PREFIX}-root`,
header: `${PREFIX}-header`,
image: `${PREFIX}-image`,
snippetImage: `${PREFIX}-snippet-image`,
title: `${PREFIX}-title`,
primary: `${PREFIX}-primary`,
secondary: `${PREFIX}-secondary`,
actions: `${PREFIX}-actions`,
footer: `${PREFIX}-footer`,
snippet: `${PREFIX}-snippet`,
new: `${PREFIX}-new`,
newChip: `${PREFIX}-new-chip`
};
const Root = styled(Widget, {
name: PREFIX,
slot: 'Root',
overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({}));
/**
* > API documentation for the Community-JS BaseItem component. Learn about the available props and the CSS API.
#### Import
```jsx
import {NotificationItem} from '@selfcommunity/react-ui';
```
#### Component Name
The name `NotificationItem` can be used when providing style overrides in the theme.
#### CSS
|Rule Name|Global class|Description|
|---|---|---|
|root|.SCBaseItem-root|Styles applied to the root element.|
|new|.SCBaseItem-new-snippet|Styles applied to the root element when notification is marked as new.|
|content|.SCBaseItem-content|Styles applied to the content element.|
|header|.SCBaseItem-header|Styles applied to the header element.|
|image|.SCBaseItem-image|Styles applied to image section.|
|snippetImage|.SCBaseItem-snippet-image|Styles applied to image section when a snippet notification is rendered.|
|title|.SCBaseItem-text|Styles applied to title section.|
|primary|.SCBaseItem-primary|Styles applied to primary section.|
|secondary|.SCBaseItem-secondary|Styles applied to secondary section.|
|actions|.SCBaseItem-actions|Styles applied to actions section.|
|footer|.SCBaseItem-footer|Styles applied to footer section.|
|newChip|.SCBaseItem-new-chip|Styles applied to the new chip element when notification is marked as new.|
* @param inProps
*/
export default function NotificationItem(inProps) {
// PROPS
const props = useThemeProps({
props: inProps,
name: PREFIX
});
const { id = null, className = null, image = null, disableTypography = false, primary = null, primaryTypographyProps = { component: 'span', variant: 'body1' }, secondary = null, secondaryTypographyProps = { component: 'p', variant: 'body2' }, actions = null, footer = null, template = SCNotificationObjectTemplateType.DETAIL, isNew = false, elevation = 0 } = props, rest = __rest(props, ["id", "className", "image", "disableTypography", "primary", "primaryTypographyProps", "secondary", "secondaryTypographyProps", "actions", "footer", "template", "isNew", "elevation"]);
// RENDER
return (_jsxs(Root, Object.assign({ id: id }, rest, { className: classNames(classes.root, className, `${PREFIX}-${template}`, {
[classes.new]: isNew
}), elevation: elevation }, { children: [_jsxs(Box, Object.assign({ className: classes.header }, { children: [image && _jsx(Box, Object.assign({ className: classNames(classes.image) }, { children: image })), _jsxs(Box, Object.assign({ className: classes.title }, { children: [primary && (_jsxs(Box, Object.assign({ className: classes.primary }, { children: [template === SCNotificationObjectTemplateType.DETAIL && isNew && _jsx(NewChip, { className: classes.newChip }), disableTypography ? primary : _jsx(Typography, Object.assign({}, primaryTypographyProps, { children: primary }))] }))), secondary && (_jsx(Box, Object.assign({ className: classes.secondary }, { children: disableTypography ? secondary : _jsx(Typography, Object.assign({}, secondaryTypographyProps, { children: secondary })) })))] }))] })), actions && _jsx(Box, Object.assign({ className: classes.actions }, { children: actions })), footer && _jsx(Box, Object.assign({ className: classes.footer }, { children: footer }))] })));
}