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: Create a reusable component for expandable section #2903

Merged
merged 4 commits into from
May 29, 2024

Conversation

RulaKhaled
Copy link
Contributor

Description

This was requested by @Adal3n3 as we foresee this being used more in the future, this will be used in several areas in new onboarding for failed tests.

Code Example

<ExpandableSection title="Click here">
   <div>This is the collapsed section</div>
<ExpandableSection />

Notable Changes

Create new ui component and stories.

Screenshots

Screen.Recording.2024-05-28.at.3.32.17.PM.mov

Link to Sample Entry

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Copy link

sentry-io bot commented May 28, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: src/services/navigation/useNavLinks/useNavLinks.js

Function Unhandled Issue
useNavLinks TypeError: undefined is not an object (evaluating 'j(S).match') /:provider/:owner/:repo...
Event Count: 1 Affected Users: 23

Did you find this useful? React with a 👍 or 👎

@RulaKhaled RulaKhaled force-pushed the expandable-section branch from 2ad31bc to 9d0228b Compare May 28, 2024 14:35
@RulaKhaled RulaKhaled force-pushed the expandable-section branch from 9d0228b to 189b7ea Compare May 28, 2024 14:40
@codecov-qa
Copy link

codecov-qa bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.48%. Comparing base (883886d) to head (45c95b0).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2903      +/-   ##
==========================================
+ Coverage   98.46%   98.48%   +0.02%     
==========================================
  Files         879      882       +3     
  Lines       13028    13077      +49     
  Branches     3494     3511      +17     
==========================================
+ Hits        12828    12879      +51     
+ Misses        196      194       -2     
  Partials        4        4              
Files Coverage Δ
src/ui/ExpandableSection/ExpandableSection.tsx 100.00% <100.00%> (ø)

... and 9 files with indirect coverage changes

Components Coverage Δ
Assets 54.28% <ø> (-0.26%) ⬇️
Layouts 97.22% <ø> (ø)
Pages 99.27% <ø> (+<0.01%) ⬆️
Services 99.48% <ø> (+<0.01%) ⬆️
Shared 99.68% <ø> (ø)
UI 94.73% <100.00%> (+0.36%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 883886d...45c95b0. Read the comment docs.

Copy link

codecov-public-qa bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.48%. Comparing base (883886d) to head (45c95b0).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found ☺️

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2903      +/-   ##
==========================================
+ Coverage   98.46%   98.48%   +0.02%     
==========================================
  Files         879      882       +3     
  Lines       13028    13077      +49     
  Branches     3499     3506       +7     
==========================================
+ Hits        12828    12879      +51     
+ Misses        196      194       -2     
  Partials        4        4              
Files Coverage Δ
src/ui/ExpandableSection/ExpandableSection.tsx 100.00% <100.00%> (ø)

... and 9 files with indirect coverage changes

Components Coverage Δ
Assets 54.28% <ø> (-0.26%) ⬇️
Layouts 97.22% <ø> (ø)
Pages 99.27% <ø> (+<0.01%) ⬆️
Services 99.48% <ø> (+<0.01%) ⬆️
Shared 99.68% <ø> (ø)
UI 94.73% <100.00%> (+0.36%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 883886d...45c95b0. Read the comment docs.

Copy link

codecov bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.48%. Comparing base (883886d) to head (45c95b0).
Report is 2 commits behind head on main.

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@               Coverage Diff                @@
##               main      #2903        +/-   ##
================================================
+ Coverage   98.46000   98.48000   +0.02000     
================================================
  Files           879        882         +3     
  Lines         13028      13077        +49     
  Branches       3429       3441        +12     
================================================
+ Hits          12828      12879        +51     
+ Misses          196        194         -2     
  Partials          4          4                
Files Coverage Δ
src/ui/ExpandableSection/ExpandableSection.tsx 100.00% <100.00%> (ø)

... and 9 files with indirect coverage changes

Components Coverage Δ
Assets 54.28% <ø> (-0.26%) ⬇️
Layouts 97.22% <ø> (ø)
Pages 99.27% <ø> (+<0.01%) ⬆️
Services 99.48% <ø> (+<0.01%) ⬆️
Shared 99.68% <ø> (ø)
UI 94.73% <100.00%> (+0.36%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 883886d...45c95b0. Read the comment docs.

@codecov-notifications
Copy link

codecov-notifications bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2903   +/-   ##
=======================================
  Coverage        ?   98.48%           
=======================================
  Files           ?      882           
  Lines           ?    13077           
  Branches        ?     3506           
=======================================
  Hits            ?    12879           
  Misses          ?      194           
  Partials        ?        4           
Files Coverage Δ
src/ui/ExpandableSection/ExpandableSection.tsx 100.00% <100.00%> (ø)
Components Coverage Δ
Assets 54.28% <ø> (?)
Layouts 97.22% <ø> (?)
Pages 99.27% <ø> (?)
Services 99.48% <ø> (?)
Shared 99.68% <ø> (?)
UI 94.73% <100.00%> (?)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 883886d...45c95b0. Read the comment docs.

Copy link

codecov bot commented May 28, 2024

Bundle Report

Changes will increase total bundle size by 25.34kB ⬆️

Bundle name Size Change
gazebo-production-array-push 6.65MB 25.34kB ⬆️

@codecov-releaser
Copy link
Contributor

codecov-releaser commented May 28, 2024

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
189b7ea Tue, 28 May 2024 14:52:34 GMT Expired Expired
a7fdd9f Tue, 28 May 2024 16:39:39 GMT Expired Expired
d706154 Wed, 29 May 2024 11:14:19 GMT Expired Expired
45c95b0 Wed, 29 May 2024 17:15:06 GMT Cloud Enterprise

Copy link
Contributor

@nicholas-codecov nicholas-codecov left a comment

Choose a reason for hiding this comment

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

Looking to get the component updated to the GV2 style so that we're ahead of the curve once it comes time to implementing GV2

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems very similar to the SummaryDropdown. Are you alright refactoring this to follow that style, as well as using the primitives from Radix? Refactoring to this style will also increase the composability of the component so it's super nice to work with and style, bringing it up to the GV2 style of writing composable components, as well as making it fully accessible.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's also a couple of components that Spencer has also done up already in the newer style that you can also reference.

Copy link
Contributor

@spalmurray-codecov spalmurray-codecov May 28, 2024

Choose a reason for hiding this comment

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

Card, RadioTileGroup, CopyClipboard, and CodeSnippet are the ones I've done/redone, for reference! :)

Copy link
Contributor

Choose a reason for hiding this comment

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

The SummaryDropdown is using the Accordion which may not be best for what we're trying to accomplish unless you're looking to stack a couple of this drop downs together, an alternative if they're going to all be separate or only one would be the Collapsible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we swap this from a default export to a named export similar to this, as this is the kinda style we're switching to make things a little nicer on the import.

@@ -0,0 +1,32 @@
import * as Collapsible from '@radix-ui/react-collapsible'
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll probably need to install this as a dependency as with Radix you install the different primitives individually, as they're packaged individually.

Comment on lines 18 to 30
<div className="my-2 border border-gray-200">
<Collapsible.Root open={isExpanded} onOpenChange={setIsExpanded}>
<Collapsible.Trigger asChild>
<button className="flex w-full items-center justify-between p-4 text-left font-semibold hover:bg-gray-100">
<span>{title}</span>
<Icon name={isExpanded ? 'chevronUp' : 'chevronDown'} size="sm" />
</button>
</Collapsible.Trigger>
<Collapsible.Content className="border-t border-gray-200 p-4">
{children}
</Collapsible.Content>
</Collapsible.Root>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you break this up into different components similar to the SummaryDropdown that way it will enable us to compose them together and make any stylistic changes inline.

@@ -0,0 +1,67 @@
import * as Collapsible from '@radix-ui/react-collapsible'
import cs from 'classnames'
Copy link
Contributor

Choose a reason for hiding this comment

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

Should use new cn wrapper instead of cs

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a drop in replacement

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated. Why did we replace cs though?

Copy link
Contributor

Choose a reason for hiding this comment

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

cn is a mix of classnames, and another utility called tailwind-merge, tailwind-merge will remove duplicate and potentially conflicting classnames for us, which has caused some issues beforehand.

Expandable Section with HTML
</ExpandableSection.Trigger>
<ExpandableSection.Content>
<div>
Copy link
Contributor

Choose a reason for hiding this comment

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

I think ExpandableSection.Content should functionally be a div, so could probably remove this div here. Doesn't really matter though

Copy link
Contributor

@spalmurray-codecov spalmurray-codecov left a comment

Choose a reason for hiding this comment

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

Couple nits, looks awesome otherwise!

@RulaKhaled RulaKhaled added this pull request to the merge queue May 29, 2024
Merged via the queue into main with commit bfb52ec May 29, 2024
60 checks passed
@RulaKhaled RulaKhaled deleted the expandable-section branch May 29, 2024 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants