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

docs: ensure ToastManager is layered above PortalManager to enable adding toast notifications within a portal #936

Merged
merged 1 commit into from
Oct 8, 2024

Conversation

cheton
Copy link
Member

@cheton cheton commented Oct 7, 2024

PR Type

enhancement, documentation


Description

  • Reordered ToastManager to be above PortalManager in the main application component and usage examples to ensure proper layering for toast notifications.
  • Updated documentation for PortalManager and ToastManager to provide clearer setup instructions and simplified code examples.

Changes walkthrough 📝

Relevant files
Enhancement
_app.page.js
Reorder ToastManager above PortalManager in App component

packages/react-docs/pages/_app.page.js

  • Reordered ToastManager to be above PortalManager.
  • Adjusted transition properties for toast placement.
  • +20/-20 
    index.page.mdx
    Reorder ToastManager above PortalManager in usage example

    packages/react-docs/pages/getting-started/usage/index.page.mdx

  • Reordered ToastManager to be above PortalManager in example.
  • Adjusted transition properties for toast placement.
  • +21/-21 
    Documentation
    index.page.mdx
    Update PortalManager setup documentation                                 

    packages/react-docs/pages/components/portal-manager/index.page.mdx

  • Updated setup instructions for PortalManager.
  • Simplified code example for wrapping application.
  • +12/-12 
    index.page.mdx
    Update ToastManager setup documentation                                   

    packages/react-docs/pages/components/toast-manager/index.page.mdx

  • Updated setup instructions for ToastManager.
  • Simplified code example for wrapping application.
  • +28/-30 

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    …e adding toast notifications within a portal
    Copy link

    codesandbox bot commented Oct 7, 2024

    Review or Edit in CodeSandbox

    Open the branch in Web EditorVS CodeInsiders

    Open Preview

    Copy link

    changeset-bot bot commented Oct 7, 2024

    ⚠️ No Changeset found

    Latest commit: 55c37bc

    Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

    This PR includes no changesets

    When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

    Click here to learn what changesets are, and how to add one.

    Click here if you're a maintainer who wants to add a changeset to this PR

    Copy link
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Component Order
    The order of ToastManager and PortalManager has been changed. Ensure this doesn't affect the functionality of toasts within portals.

    Documentation Update
    The setup instructions for PortalManager have been simplified. Verify that the new instructions are clear and complete.

    Documentation Update
    The setup instructions for ToastManager have been simplified. Ensure that the new instructions provide all necessary information.

    Component Import Order
    The import order of TonicProvider has changed. Verify that this doesn't affect the usage example or cause any issues.

    Copy link
    Contributor

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Enhancement
    Add explanation about nesting PortalManager inside ToastManager

    Consider adding a brief explanation of why PortalManager should be wrapped inside
    ToastManager. This will provide context for developers and align with the changes
    made in other files.

    packages/react-docs/pages/components/portal-manager/index.page.mdx [15-21]

    -Next, wrap your application with `PortalManager`:
    +Next, wrap your application with `PortalManager`. Note that `PortalManager` should be nested inside `ToastManager` to enable adding toast notifications within a portal:
     
     ```jsx disabled
    -<PortalManager>
    -  <App />
    -</PortalManager>
    +<ToastManager>
    +  <PortalManager>
    +    <App />
    +  </PortalManager>
    +</ToastManager>
    
    - [ ] **Apply this suggestion** <!-- /improve --apply_suggestion=0 -->
    
    <details><summary>Suggestion importance[1-10]: 8</summary>
    
    Why: The suggestion enhances the documentation by explaining the nesting order, which is crucial for proper functionality. This aligns with the changes in the PR and provides valuable context for developers.
    
    
    </details></details></td><td align=center>8
    
    </td></tr><tr><td>
    
    
    
    <details><summary>Add information about wrapping PortalManager with ToastManager in the setup instructions</summary>
    
    ___
    
    
    **Consider mentioning that <code>ToastManager</code> should wrap <code>PortalManager</code> to ensure proper <br>functionality when using toasts within portals. This will provide a more complete <br>setup instruction and align with the changes made in other files.**
    
    [packages/react-docs/pages/components/toast-manager/index.page.mdx [13-37]](https://github.com/trendmicro-frontend/tonic-ui/pull/936/files#diff-3aea5a94f2dfd32a155e165c3342bc413b27975a2ad7d3d04cd9cb1b682d560aR13-R37)
    
    ```diff
    -Next, wrap your application with `ToastManager`:
    +Next, wrap your application with `ToastManager`. Make sure `ToastManager` wraps `PortalManager` to enable adding toast notifications within a portal:
     
     ```jsx disabled
     <ToastManager
       TransitionProps={{
         sx: {
           '[data-toast-placement^="top"] > &:first-of-type': {
             mt: '4x', // the space to the top edge of the screen
           },
           '[data-toast-placement^="bottom"] > &:last-of-type': {
             mb: '4x', // the space to the bottom edge of the screen
           },
           '[data-toast-placement$="left"] > &': {
             ml: '4x', // the space to the left edge of the screen
           },
           '[data-toast-placement$="right"] > &': {
             mr: '4x', // the space to the right edge of the screen
           },
         },
       }}
       placement="bottom-right"
     >
    -  <App />
    +  <PortalManager>
    +    <App />
    +  </PortalManager>
     </ToastManager>
    
    
    - [ ] **Apply this suggestion** <!-- /improve --apply_suggestion=1 -->
    
    <details><summary>Suggestion importance[1-10]: 8</summary>
    
    Why: This suggestion improves the setup instructions by clarifying the component hierarchy, which is essential for correct usage. It aligns with the PR changes and aids in preventing potential integration issues. 
    
    
    </details></details></td><td align=center>8
    
    </td></tr><tr><td rowspan=1><strong>Maintainability</strong></td>
    <td>
    
    
    
    <details><summary>Add a comment explaining the order of ToastManager and PortalManager components</summary>
    
    ___
    
    
    **Consider adding a comment explaining why <code>ToastManager</code> needs to be above <br><code>PortalManager</code>. This will help future developers understand the importance of this <br>order and prevent accidental changes that could break the functionality.**
    
    [packages/react-docs/pages/_app.page.js [136-154]](https://github.com/trendmicro-frontend/tonic-ui/pull/936/files#diff-49f34385f9684300c85addd1b7dc358db1cfc469e159754c0ea81c147fa99672R136-R154)
    
    ```diff
    +{/* ToastManager needs to be above PortalManager to enable adding toast notifications within a portal */}
     <ToastManager
       TransitionProps={{
         sx: {
           '[data-toast-placement^="top"] > &:first-of-type': {
             mt: '4x', // the space to the top edge of the screen
           },
           '[data-toast-placement^="bottom"] > &:last-of-type': {
             mb: '4x', // the space to the bottom edge of the screen
           },
           '[data-toast-placement$="left"] > &': {
             ml: '4x', // the space to the left edge of the screen
           },
           '[data-toast-placement$="right"] > &': {
             mr: '4x', // the space to the right edge of the screen
           },
         },
       }}
     >
       <PortalManager>
    
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: Adding a comment to explain the order of components improves code maintainability by providing context for future developers. This suggestion is relevant and aligns with the changes made in the PR.

    7

    💡 Need additional feedback ? start a PR chat

    Copy link

    codesandbox-ci bot commented Oct 7, 2024

    This pull request is automatically built and testable in CodeSandbox.

    To see build info of the built libraries, click here or the icon next to each commit SHA.

    Copy link

    codecov bot commented Oct 7, 2024

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 77.80%. Comparing base (2421c20) to head (55c37bc).
    Report is 1 commits behind head on v2.

    Additional details and impacted files
    @@           Coverage Diff           @@
    ##               v2     #936   +/-   ##
    =======================================
      Coverage   77.80%   77.80%           
    =======================================
      Files         403      403           
      Lines        6632     6632           
    =======================================
      Hits         5160     5160           
      Misses       1472     1472           

    ☔ View full report in Codecov by Sentry.
    📢 Have feedback on the report? Share it here.

    @trendmicro-frontend-bot
    Copy link
    Contributor

    Tonic UI Demo

    On 2024-10-07 03:28:52 +0000, PR #936 (55c37bc) was successfully deployed. You can view it at the following link:
    https://trendmicro-frontend.github.io/tonic-ui-demo/react/pr-936/

    @cheton cheton merged commit 5116834 into v2 Oct 8, 2024
    7 checks passed
    @cheton cheton deleted the tonic-ui-932 branch October 8, 2024 03:54
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    Ensure ToastManager is layered above PortalManager to enable adding toast messages within a portal
    2 participants