@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
67 lines (58 loc) • 3.5 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const styles_1 = require("@mui/material/styles");
const material_1 = require("@mui/material");
const classnames_1 = tslib_1.__importDefault(require("classnames"));
const Widget_1 = tslib_1.__importDefault(require("../../components/Widget"));
const system_1 = require("@mui/system");
const PREFIX = 'SCBaseItem';
const classes = {
root: `${PREFIX}-root`,
withActions: `${PREFIX}-with-actions`,
content: `${PREFIX}-content`,
image: `${PREFIX}-image`,
text: `${PREFIX}-text`,
primary: `${PREFIX}-primary`,
secondary: `${PREFIX}-secondary`,
actions: `${PREFIX}-actions`
};
const Root = (0, styles_1.styled)(Widget_1.default, {
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 {BaseItem} from '@selfcommunity/react-ui';
```
#### Component Name
The name `BaseItem` 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.|
|content|.SCBaseItem-content|Styles applied to the content element.|
|image|.SCBaseItem-image|Styles applied to image section.|
|text|.SCBaseItem-text|Styles applied to text 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.|
* @param inProps
*/
function BaseItem(inProps) {
// PROPS
const props = (0, system_1.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 } = props, rest = tslib_1.__rest(props, ["id", "className", "image", "disableTypography", "primary", "primaryTypographyProps", "secondary", "secondaryTypographyProps", "actions"]);
// RENDER
return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ id: id }, rest, { className: (0, classnames_1.default)(classes.root, className, { [classes.withActions]: Boolean(actions) }) }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.content }, { children: [image && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.image }, { children: image })), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.text }, { children: [primary &&
(disableTypography ? (primary) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.primary }, primaryTypographyProps, { children: primary })))), secondary &&
(disableTypography ? (secondary) : ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ className: classes.secondary }, secondaryTypographyProps, { children: secondary }))))] }))] })), actions && (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.actions }, { children: actions }))] })));
}
exports.default = BaseItem;
;