-
Notifications
You must be signed in to change notification settings - Fork 230
[NEW] Message character limit feature #443
[NEW] Message character limit feature #443
Conversation
* adding new component ReminderCharacters on Footer * update function shouldComponentUpdate in Composer * adding config.settings.limitTextLength in screenProps
* added limitTextLength validation if null
Hey @oguhpereira thanks for contributing, It seems to be a very nice feature! I have two points to discuss here before we review/merge your code:
I'll be waiting for some news. Thanks. |
Hi @renatobecker this is the original video. I went to add the storybook but there seems to be a problem of compatibility of the preact with the version that is in the package.json |
I just watched your video, I noticed that even there is a message length limit, you're allowing the user to type new characters. why? |
@renatobecker I based it on twitter's UX. I don't prevent the user from entering the message, just block the sending. I'm trying not to create a bad experience when I exceed the character limit. Therefore, even if the user types a message larger than expected, he can adapt to fit the limit. |
So, I see two points here:
Sry, this doesn't make sense to me. |
|
I see. Thanks. |
* Removing visual effects when exceeding message limit * Adding write block when passing the character limit value
@renatobecker, I removed the changes commented above, added a lock to continue typing. Check on video |
Ohh that's awesome! |
* Creating class footer__remainder-alert * Changing to class footer__remainder-alert when textLength is equal character limit
@renatobecker When text reaches the limit it changes to $color-red. Check on video |
src/components/App/index.js
Outdated
@@ -182,6 +182,7 @@ export class App extends Component { | |||
expanded, | |||
alerts, | |||
modal, | |||
config, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this here, the StoreConsumer
is propagating the config
prop to the App components.
src/components/App/index.js
Outdated
@@ -204,6 +205,7 @@ export class App extends Component { | |||
onOpenWindow: this.handleOpenWindow, | |||
onDismissAlert: this.handleDismissAlert, | |||
dismissNotification: this.dismissNotification, | |||
limitTextLength: config.settings.limitTextLength, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need this here, the StoreConsumer
is propagating the config
prop to the App components.
You need to extract the prop value here:
https://github.com/RocketChat/Rocket.Chat.Livechat/blob/develop/src/routes/Chat/container.js#L338
And then pass it through the components.
src/components/Footer/styles.scss
Outdated
@@ -41,6 +41,16 @@ | |||
|
|||
@include pressable-button(2px); | |||
} | |||
|
|||
&__remainder, &__remainder-alert { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&__remainder, &__remainder-alert { | |
&__remainder { | |
margin-left: 10px; | |
min-width: 100px; | |
font-weight: bold; | |
&--highlight { | |
color: $color-red; | |
transition: color .2s; | |
} | |
} |
src/components/Footer/index.js
Outdated
@@ -43,3 +43,13 @@ export const FooterOptions = ({ children }) => ( | |||
{children} | |||
</PopoverMenu> | |||
); | |||
|
|||
|
|||
export const ReminderCharacters = ({ className, style = {}, textLenght, limitTextLength }) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const ReminderCharacters = ({ className, style = {}, textLenght, limitTextLength }) => ( | |
export const CharCounter = ({ className, style = {}, textLength, limitTextLength }) => ( | |
<span | |
className={createClassName(styles, 'footer__remainder', { highlight: textLength === limitTextLength }, [className])} | |
style={style} | |
> | |
{textLength} / {limitTextLength} | |
</span> | |
); | |
src/routes/Chat/component.js
Outdated
@@ -2,7 +2,7 @@ import { Component } from 'preact'; | |||
|
|||
import { Composer, ComposerAction, ComposerActions } from '../../components/Composer'; | |||
import { FilesDropTarget } from '../../components/FilesDropTarget'; | |||
import { FooterOptions } from '../../components/Footer'; | |||
import { FooterOptions, ReminderCharacters } from '../../components/Footer'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { FooterOptions, ReminderCharacters } from '../../components/Footer'; | |
import { FooterOptions, CharCounter } from '../../components/Footer'; |
src/routes/Chat/component.js
Outdated
@@ -162,14 +172,15 @@ export default class Chat extends Component { | |||
<ComposerAction onClick={this.handleUploadClick}> | |||
<PlusIcon width={20} /> | |||
</ComposerAction> | |||
)} | |||
)}1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oguhpereira what's the reason to add the 1
here?
I didn't get it, was it a mistake?
I noticed you left the 1
here after my review.
* Changing component name to CharCounter * Changing alert to hilight
src/routes/Chat/component.js
Outdated
@@ -162,14 +172,15 @@ export default class Chat extends Component { | |||
<ComposerAction onClick={this.handleUploadClick}> | |||
<PlusIcon width={20} /> | |||
</ComposerAction> | |||
)} | |||
)}1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oguhpereira what's the reason to add the 1
here?
I didn't get it, was it a mistake?
I noticed you left the 1
here after my review.
@oguhpereira the storybook is okay now, please pull the last changes from the |
* Remove number 1 * Create storybook in stories
@renatobecker I removed the number 1, it is not part of the logic, I also added the storybook |
Depends on RocketChat/Rocket.Chat#18261
The main goal of this PR is to add functionality to add character limit for messages.
#416