@selfcommunity/react-ui 0.7.42-alpha.0 → 0.7.42-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/components/Category/Category.js +4 -5
- package/lib/esm/components/Category/Category.js +5 -6
- package/lib/umd/react-ui.js +1 -1
- package/package.json +2 -2
- package/lib/cjs/constants/Category.d.ts +0 -1
- package/lib/cjs/constants/Category.js +0 -4
- package/lib/esm/constants/Category.d.ts +0 -1
- package/lib/esm/constants/Category.js +0 -1
|
@@ -5,6 +5,7 @@ const react_1 = tslib_1.__importStar(require("react"));
|
|
|
5
5
|
const styles_1 = require("@mui/material/styles");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_core_1 = require("@selfcommunity/react-core");
|
|
8
|
+
const types_1 = require("@selfcommunity/types");
|
|
8
9
|
const Skeleton_1 = tslib_1.__importDefault(require("./Skeleton"));
|
|
9
10
|
const CategoryFollowButton_1 = tslib_1.__importDefault(require("../CategoryFollowButton"));
|
|
10
11
|
const react_intl_1 = require("react-intl");
|
|
@@ -12,8 +13,6 @@ const classnames_1 = tslib_1.__importDefault(require("classnames"));
|
|
|
12
13
|
const system_1 = require("@mui/system");
|
|
13
14
|
const BaseItemButton_1 = tslib_1.__importDefault(require("../../shared/BaseItemButton"));
|
|
14
15
|
const constants_1 = require("./constants");
|
|
15
|
-
const string_1 = require("../../utils/string");
|
|
16
|
-
const Category_1 = require("../../constants/Category");
|
|
17
16
|
const messages = (0, react_intl_1.defineMessages)({
|
|
18
17
|
categoryFollowers: {
|
|
19
18
|
id: 'ui.category.categoryFollowers',
|
|
@@ -24,6 +23,8 @@ const classes = {
|
|
|
24
23
|
root: `${constants_1.PREFIX}-root`,
|
|
25
24
|
categoryImage: `${constants_1.PREFIX}-category-image`,
|
|
26
25
|
title: `${constants_1.PREFIX}-title`,
|
|
26
|
+
followed: `${constants_1.PREFIX}-followed`,
|
|
27
|
+
autoFollowed: `${constants_1.PREFIX}-auto-followed`,
|
|
27
28
|
actions: `${constants_1.PREFIX}-actions`
|
|
28
29
|
};
|
|
29
30
|
const Root = (0, styles_1.styled)(BaseItemButton_1.default, {
|
|
@@ -70,14 +71,12 @@ function Category(inProps) {
|
|
|
70
71
|
const _ButtonBaseProps = (0, react_1.useMemo)(() => (ButtonBaseProps ? ButtonBaseProps : { component: react_core_1.Link, to: scRoutingContext.url(react_core_1.SCRoutes.CATEGORY_ROUTE_NAME, scCategory) }), [ButtonBaseProps, scRoutingContext, scCategory]);
|
|
71
72
|
// HOOKS
|
|
72
73
|
const intl = (0, react_intl_1.useIntl)();
|
|
73
|
-
const theme = (0, material_1.useTheme)();
|
|
74
|
-
const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
|
|
75
74
|
if (!scCategory) {
|
|
76
75
|
return react_1.default.createElement(Skeleton_1.default, { elevation: elevation });
|
|
77
76
|
}
|
|
78
77
|
// RENDER
|
|
79
78
|
if (!autoHide) {
|
|
80
|
-
return (react_1.default.createElement(Root, Object.assign({ elevation: elevation, className: (0, classnames_1.default)(classes.root, className), ButtonBaseProps: _ButtonBaseProps, image: react_1.default.createElement(material_1.Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary:
|
|
79
|
+
return (react_1.default.createElement(Root, Object.assign({ elevation: elevation, className: (0, classnames_1.default)(classes.root, className, { [classes.followed]: scCategory.followed }, { [classes.autoFollowed]: scCategory.auto_follow === types_1.SCCategoryAutoFollowType.FORCED }), ButtonBaseProps: _ButtonBaseProps, image: react_1.default.createElement(material_1.Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary: scCategory.name, secondary: showFollowers ? `${intl.formatMessage(messages.categoryFollowers, { total: scCategory.followers_counter })}` : scCategory.slogan, actions: react_1.default.createElement(CategoryFollowButton_1.default, Object.assign({ category: scCategory }, categoryFollowButtonProps)) }, rest)));
|
|
81
80
|
}
|
|
82
81
|
return null;
|
|
83
82
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import React, { useMemo } from 'react';
|
|
3
3
|
import { styled } from '@mui/material/styles';
|
|
4
|
-
import { Avatar
|
|
4
|
+
import { Avatar } from '@mui/material';
|
|
5
5
|
import { Link, SCRoutes, useSCFetchCategory, useSCRouting } from '@selfcommunity/react-core';
|
|
6
|
+
import { SCCategoryAutoFollowType } from '@selfcommunity/types';
|
|
6
7
|
import CategorySkeleton from './Skeleton';
|
|
7
8
|
import CategoryFollowButton from '../CategoryFollowButton';
|
|
8
9
|
import { defineMessages, useIntl } from 'react-intl';
|
|
@@ -10,8 +11,6 @@ import classNames from 'classnames';
|
|
|
10
11
|
import { useThemeProps } from '@mui/system';
|
|
11
12
|
import BaseItemButton from '../../shared/BaseItemButton';
|
|
12
13
|
import { PREFIX } from './constants';
|
|
13
|
-
import { formatCroppedName } from '../../utils/string';
|
|
14
|
-
import { CATEGORY_NAME_MAX_LENGTH_DESKTOP } from '../../constants/Category';
|
|
15
14
|
const messages = defineMessages({
|
|
16
15
|
categoryFollowers: {
|
|
17
16
|
id: 'ui.category.categoryFollowers',
|
|
@@ -22,6 +21,8 @@ const classes = {
|
|
|
22
21
|
root: `${PREFIX}-root`,
|
|
23
22
|
categoryImage: `${PREFIX}-category-image`,
|
|
24
23
|
title: `${PREFIX}-title`,
|
|
24
|
+
followed: `${PREFIX}-followed`,
|
|
25
|
+
autoFollowed: `${PREFIX}-auto-followed`,
|
|
25
26
|
actions: `${PREFIX}-actions`
|
|
26
27
|
};
|
|
27
28
|
const Root = styled(BaseItemButton, {
|
|
@@ -68,14 +69,12 @@ export default function Category(inProps) {
|
|
|
68
69
|
const _ButtonBaseProps = useMemo(() => (ButtonBaseProps ? ButtonBaseProps : { component: Link, to: scRoutingContext.url(SCRoutes.CATEGORY_ROUTE_NAME, scCategory) }), [ButtonBaseProps, scRoutingContext, scCategory]);
|
|
69
70
|
// HOOKS
|
|
70
71
|
const intl = useIntl();
|
|
71
|
-
const theme = useTheme();
|
|
72
|
-
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
73
72
|
if (!scCategory) {
|
|
74
73
|
return React.createElement(CategorySkeleton, { elevation: elevation });
|
|
75
74
|
}
|
|
76
75
|
// RENDER
|
|
77
76
|
if (!autoHide) {
|
|
78
|
-
return (React.createElement(Root, Object.assign({ elevation: elevation, className: classNames(classes.root, className), ButtonBaseProps: _ButtonBaseProps, image: React.createElement(Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary:
|
|
77
|
+
return (React.createElement(Root, Object.assign({ elevation: elevation, className: classNames(classes.root, className, { [classes.followed]: scCategory.followed }, { [classes.autoFollowed]: scCategory.auto_follow === SCCategoryAutoFollowType.FORCED }), ButtonBaseProps: _ButtonBaseProps, image: React.createElement(Avatar, { alt: scCategory.name, src: scCategory.image_medium, variant: "square", className: classes.categoryImage }), primary: scCategory.name, secondary: showFollowers ? `${intl.formatMessage(messages.categoryFollowers, { total: scCategory.followers_counter })}` : scCategory.slogan, actions: React.createElement(CategoryFollowButton, Object.assign({ category: scCategory }, categoryFollowButtonProps)) }, rest)));
|
|
79
78
|
}
|
|
80
79
|
return null;
|
|
81
80
|
}
|