Skip to content
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

feat: apply ellipsis into notification #2199

Merged
merged 3 commits into from
Feb 8, 2024
Merged

Conversation

ironAiken2
Copy link
Contributor

@ironAiken2 ironAiken2 commented Feb 1, 2024

This PR resolves #2196

feature :

  • Added allowEllipsis prop to control ellipsis property. (allowEllipsis (boolean))
  • Users can use the ellipsis feature by clicking on the text.

Checklist: (if applicable)

  • Mention to the original issue
  • Documentation
  • Minium required manager version
  • Specific setting for review (eg., KB link, endpoint or how to setup)
  • Minimum requirements to check during review
  • Test case(s) to demonstrate the difference of before/after

@ironAiken2 ironAiken2 self-assigned this Feb 1, 2024
@github-actions github-actions bot added the size:M 30~100 LoC label Feb 1, 2024
Copy link

github-actions bot commented Feb 1, 2024

Coverage report for ./react

St.
Category Percentage Covered / Total
🔴 Statements
3.14% (+0% 🔼)
101/3219
🔴 Branches
3.32% (+0% 🔼)
67/2018
🔴 Functions
1.55% (+0% 🔼)
17/1097
🔴 Lines
3.2% (+0% 🔼)
101/3160

Test suite run success

20 tests passing in 4 suites.

Report generated by 🧪jest coverage report action from e16331b

Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-2199.d3g9cs6u59b8lw.amplifyapp.com

const { t } = useTranslation();
const { token } = theme.useToken();
const [showExtraDescription, setShowExtraDescription] = useState(false);
const [ellipsis, setEllipsis] = useControllableValue({
defaultValue: allowEllipsis,
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useControllableValue helps manage the state to be either self-managed or controlled by its parent.
allowEllipsis is not applicable in this case. allowEllipsis determines whether ellipsis is allowed or not. Ellipsis refers to the current state of being ellipsised or not, which is not related to the allowance of ellipsis.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, you might not need to manage the ellipsis status and don't need to handle it using the click event. Typography has a feature to manage it, such as the expandable property. Please check this.

Copy link
Contributor Author

@ironAiken2 ironAiken2 Feb 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yomybaby

The allowEllipsi is simply a property that turns ellipsis on/off, so I didn't think it was right to use a useControllableValue, so I removed it.
The expendable property only provides the ability to expand the omitted text again, not to omit the expanded text again. So in the sider that holds all the notifications, I want to support both collapsing and expanding, so I'm controlling the ellipsis property with a click event.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's okay if it can't use ellipsis again. The main points are:

  • The clickable content area is good for the main action. For example, clicking the "success creating session" notification takes you to the session detail page. It's better not to use the clicking action for toggling. Let's reserve clicking for another feature later.
  • The UX for toggling ellipsis by clicking again is uncommon and not explicit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you let me know what the longest notification you have found is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yomybaby
I decided that scalability would be an afterthought, so I modified the code to focus on fixing the mentioned issues.

ref The error occurs when turn off storage and access the web. I didn't find the error in my test environment, so I tested it by hardcoding the notification text for the usage calculation part.

image

@github-actions github-actions bot added size:XS ~10 LoC and removed size:M 30~100 LoC labels Feb 7, 2024
Copy link
Member

@yomybaby yomybaby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yomybaby yomybaby merged commit 47a107f into main Feb 8, 2024
8 checks passed
@yomybaby yomybaby deleted the feat/notification-ellipsis branch February 8, 2024 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size:XS ~10 LoC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Added exception handling for long text in BAINotificationItem
2 participants