-
Notifications
You must be signed in to change notification settings - Fork 394
fix: add cx-read-more component (for product reviews) #20250
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
spartacus
|
Project |
spartacus
|
Branch Review |
feature/CXSPA-9967
|
Run status |
|
Run duration | 04m 59s |
Commit |
|
Committer | Uros Lates |
View all properties for this run ↗︎ |
Test results | |
---|---|
|
0
|
|
3
|
|
2
|
|
0
|
|
237
|
View all changes introduced in this branch ↗︎ |
@Input() readLessTranslation?: string = 'common.readLess'; | ||
@Input() maxLength = 360; | ||
|
||
@Input() text: string = ''; |
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.
To make this component more useful in other cases, should we include a translation key as an option for this?
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.
We alread have that - the labels are inputs (accepting translation keys) - here
@Input() readMoreTranslation?: string = 'common.readMore';
@Input() readLessTranslation?: string = 'common.readLess';
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.
Sorry, to be clear I mean @Input() text: I18nKey | string = '';
. I suppose the other inputs should also have the I18nKey
typing too right?
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.
Ah that. sorry the text is the actual text coming from the DB (so its should not be translatable - thats done in through the BE system).
As for the other 2 inputs NP I'll update it to have the name suffix I18nKey (to be more intuitive). As for they I18nKey type - i haven't found it and wouldn't like to introduce it now since its just a string. And introducing it now (and enforcing consistency) would require tons of changes on other places I guess. We could to that type of improvement globally as some other issue (if really required).
import { I18nModule } from '@spartacus/core'; | ||
|
||
/** | ||
* Renders cx-read-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.
This is a nice approach to the read more case. Simple enough to understand quickly and works well. Could we expand on jsdocs for the class and properties?
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.
Applied! 👍
@@ -43,12 +46,16 @@ export class ProductReviewsComponent { | |||
@ViewChild('writeReviewButton', { static: false }) | |||
writeReviewButton: ElementRef; | |||
|
|||
@Input() inputCharactersForReviewTitle = 255; |
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.
We should keep this behaviour feature toggled as I would consider it a breaking change. If it falls back to null
, then I think the maxLength
property wouldn't be applied.
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.
I think the property name could also be changed to something closer to the attribute it affects like maxLengthReviewTitle
. Just an example, but I think it could be more clear.
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.
Addressed! 👍
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.
Applied! 👍
@@ -127,12 +134,53 @@ export class ProductReviewsComponent { | |||
} | |||
} | |||
|
|||
get reviewTitleCharacterLeft(): number { |
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.
I'm not a huge fan of using getters this way as they retrigger on every component interaction (eg. clicking on the field triggers all, typing a character triggers all, etc). Its a big impact on performance at scale. It would be better if they could trigger only when the needed property changes.
Note: It could be an opportunity to look into the new angular signals.


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.
Applied 👍. Removed those and moved to template.
@@ -147,6 +166,16 @@ <h3>{{ 'productReview.overallRating' | cxTranslate }}</h3> | |||
*cxFeature="'!formErrorsDescriptiveMessages'" | |||
[control]="reviewForm.get('comment')" | |||
></cx-form-errors> | |||
|
|||
<p |
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.
Could you please consult with UI designers on the styling details of this component? You can tag them on the onboarding chat with links to the PR (and maybe ticket for context).
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.
If we're talking about the characters limiting feature & form errors - I don't think this is necessary since this kind of feature was already implemented on few other places, so the implementation here is fully matching the other usages & styles.
But if needed I could do that. (or if its related to the read-more cmp)
Merge Checks Failed
|
Merge Checks Failed
|
Merge Checks Failed
|
Closes https://jira.tools.sap/browse/CXSPA-9967