@selfcommunity/react-ui
Version:
React UI Components to integrate a Community created with SelfCommunity Platform.
55 lines (50 loc) • 2.36 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = tslib_1.__importStar(require("react"));
const styles_1 = require("@mui/material/styles");
const react_core_1 = require("@selfcommunity/react-core");
const material_1 = require("@mui/material");
const FollowUserButton_1 = tslib_1.__importDefault(require("../FollowUserButton"));
const FriendshipUserButton_1 = tslib_1.__importDefault(require("../FriendshipUserButton"));
const system_1 = require("@mui/system");
const PREFIX = 'SCConnectionUserButton';
const classes = {
root: `${PREFIX}-root`
};
const Root = (0, styles_1.styled)(material_1.Box, {
name: PREFIX,
slot: 'Root',
overridesResolver: (props, styles) => styles.root
})(({ theme }) => ({}));
/**
* > API documentation for the Community-JS Connection User Button component. Learn about the available props and the CSS API.
*
*
#### Import
```jsx
import {ConnectionUserButton} from '@selfcommunity/react-ui';
```
#### Component Name
The name `SCConnectionUserButton` can be used when providing style overrides in the theme.
#### CSS
|Rule Name|Global class|Description|
|---|---|---|
|root|.SCConnectionUserButton-root|Styles applied to the root element.|
* @param inProps
*/
function ConnectionUserButton(inProps) {
// PROPS
const props = (0, system_1.useThemeProps)({
props: inProps,
name: PREFIX
});
const { user = null, followConnectUserButtonProps = {} } = props, rest = tslib_1.__rest(props, ["user", "followConnectUserButtonProps"]);
// CONTEXT
const scPreferencesContext = (0, react_1.useContext)(react_core_1.SCPreferencesContext);
const followEnabled = react_core_1.SCPreferences.CONFIGURATIONS_FOLLOW_ENABLED in scPreferencesContext.preferences &&
scPreferencesContext.preferences[react_core_1.SCPreferences.CONFIGURATIONS_FOLLOW_ENABLED].value;
return ((0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: followEnabled ? ((0, jsx_runtime_1.jsx)(FollowUserButton_1.default, Object.assign({ user: user }, followConnectUserButtonProps, rest))) : ((0, jsx_runtime_1.jsx)(FriendshipUserButton_1.default, Object.assign({ user: user }, followConnectUserButtonProps, rest))) }));
}
exports.default = ConnectionUserButton;
;