Skip to content

#271: Implement Expand All and Collapse All Buttons #286

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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

SaqAsh
Copy link

@SaqAsh SaqAsh commented Jun 4, 2025

Summary

Issues

Description of Changes

  • Add ExpandAllButton and CollapseAllButton components for toggling all items open/closed.
  • Add underlying Button component, slightly refactored from the Button component from the stage repository
  • Add necessary icons to match Figma requirements in addition to the Loading icon to successfully port over the Button component from stage
  • Add corresponding Storybook stories

Readiness Checklist

  • Self Review
    • I have performed a self review of code
    • I have run the application locally and manually tested the feature
    • I have checked all updates to correct typos and misspellings
  • Formatting
    • Code follows the project style guide
    • Autmated code formatters (ie. Prettier) have been run
  • Local Testing
    • Successfully built all packages locally
    • Successfully ran all test suites, all unit and integration tests pass
  • Updated Tests
    • Unit and integration tests have been added that describe the bug that was fixed or the features that were added
  • Documentation
    • All new environment variables added to .env.schema file and documented in the README
    • All changes to server HTTP endpoints have open-api documentation
    • All new functions exported from their module have TSDoc comment documentation

Comment on lines 38 to 46
width={width}
height={height}
css={css`
height: 20px;
animation: ${spin} 1.4s linear infinite;
`}
>
<path
fill={fill}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only icon that doesn't specify defaults for width/height/fill. Should we?

Copy link
Author

Choose a reason for hiding this comment

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

Didn't realize this when copying over from stage, probably should follow the pattern.

import { useThemeContext } from '../../theme/ThemeContext';

interface CollapseAllButtonProps {
setIsCollapsed: (isCollapsed: boolean) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this needs a function argument since this will only ever send true. I think this can simply be named onClick and be () => void.

Copy link
Author

Choose a reason for hiding this comment

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

I had it send a boolean state value for the initial load, hence the argument, if we remove that behaviour that was requested in the ticket, including the default state on initial page load, then yes it doesn't need the argument.

Comment on lines 14 to 16
useEffect(() => {
setIsCollapsed(collapsedOnLoad);
}, [collapsedOnLoad, setIsCollapsed]);
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 explain why this is needed? Usually a button wouldn't be responsible for the state of other components on load. I think this on load behaviour belongs outside this component.

Copy link
Author

@SaqAsh SaqAsh Jun 10, 2025

Choose a reason for hiding this comment

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

"A property should be included to set the default state on initial page load (closedOnLoad or openOnLoad)" is included in the ticket for this component, which is what I was thinking when writing this code. However I think I do agree with you since now that I am implementing the accordion component, this is a state that is handled externally. Your thoughts are appreciated.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll recommend maintaining a healthy dose of scepticism when seeing potentially overreaching implementation details on the tickets, they are written by a less technically inclined individual.

Comment on lines 14 to 16
useEffect(() => {
setIsCollapsed(expandOnLoad);
}, [expandOnLoad, setIsCollapsed]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Repeat comment about the button not controlling the state of other components on load.

@SaqAsh SaqAsh linked an issue Jun 10, 2025 that may be closed by this pull request
1 task
@SaqAsh SaqAsh requested a review from joneubank June 10, 2025 18:47
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.

2B. Expand All / Collapse All
3 participants