@craftercms/studio-ui
Version:
Services, components, models & utils to build CrafterCMS authoring extensions.
86 lines (84 loc) • 3.07 kB
JavaScript
/*
* Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Copyright (C) 2007-2022 Crafter Software Corporation. All Rights Reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import React from 'react';
import { makeStyles } from 'tss-react/mui';
import palette from '../../styles/palette';
import { Grid } from '@mui/material';
import Typography from '@mui/material/Typography';
import { FormattedMessage } from 'react-intl';
import { useSelector } from 'react-redux';
const useStyles = makeStyles()(() => ({
countContainer: {
padding: '5px'
},
submissionCommentCount: {
fontSize: '14px',
color: palette.gray.medium4
}
}));
function CharCountStatus(props) {
const { classes } = useStyles();
const { commentLength, commentMaxLength } = props;
return React.createElement(
Grid,
{ container: true, direction: 'row', justifyContent: 'space-between', className: classes.countContainer },
React.createElement(
Grid,
{ item: true },
React.createElement(
Typography,
{ className: classes.submissionCommentCount },
React.createElement(FormattedMessage, {
id: 'deleteDialog.maxCharacters',
defaultMessage: 'Max {maxLength} characters',
values: { maxLength: commentMaxLength }
})
)
),
React.createElement(
Grid,
{ item: true },
React.createElement(
Typography,
{ className: classes.submissionCommentCount },
commentLength,
'/',
commentMaxLength
)
)
);
}
export function CharCountStatusContainer(props) {
const { commentLength } = props;
const commentMaxLength = useSelector((state) => state.uiConfig.publishing.submissionCommentMaxLength);
return React.createElement(CharCountStatus, { commentLength: commentLength, commentMaxLength: commentMaxLength });
}
export default CharCountStatus;