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

Animate settings sidebar #320

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

Conversation

shoumaw
Copy link
Contributor

@shoumaw shoumaw commented Feb 6, 2025

Add a width transition to the SettingsSidebar items

Screen.Recording.2025-02-06.at.11.43.50.PM.mov

@@ -22,7 +22,12 @@ export interface SettingsSidebarProps {
overrides: Partial<NormalizeIssueConfig & { fields: string[] }>
) => void;
}

const SETTINGS_WIDTH: Record<string, string> = {
SOURCES: "w-96",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Explicit widths have to be provided for the width transition to work.
It does not work with w-full or a custom value w-[600px]

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's revisit this with Justin

Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? Can't we calculate the width at the time of the animation and temporarily hard-code it?

We shouldn't have to remember to update these values if the HTML/CSS structure changes in one of the panels.

Copy link
Contributor Author

@shoumaw shoumaw Feb 10, 2025

Choose a reason for hiding this comment

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

I agree that is not ideal, but if we want to dynamically calculate its width (especially that each setting panel have a different width). The setting panel needs to be rendered first in order to calculate its width, we can not calculate it in advance.

If we do that, this means that first render will be without any transition animation and then subsequent renders will have access to its width and can apply the width transition.

Or did you mean something else?

Once I have some downtime on Annuity Association, I can and try and see if there are other better alternatives.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Another non-ideal solution is to render an absolutely positioned hidden version of the selected setting panel that we can use to calculate the width in advance

<div
className={`overflow-hidden h-full transition-[width] duration-500 ease-in-out ${settingsWidth}`}
onTransitionEnd={() => {
setSettingVisible(!!showSettings);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to handle the setting content not looking weird as the transition is happening. A new flag is used to determine when the transition ends before displaying the content

Copy link
Member

@justinbmeyer justinbmeyer left a comment

Choose a reason for hiding this comment

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

We need to make this work so it doesn't have hard-coded panel widths. At the time of animation, we should be able to read the DOM and temporarily set a fixed width if that is helpful. (though using tailwind classes is probably not going to work ... we'd need to set the style.width.

@@ -22,7 +22,12 @@ export interface SettingsSidebarProps {
overrides: Partial<NormalizeIssueConfig & { fields: string[] }>
) => void;
}

const SETTINGS_WIDTH: Record<string, string> = {
SOURCES: "w-96",
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? Can't we calculate the width at the time of the animation and temporarily hard-code it?

We shouldn't have to remember to update these values if the HTML/CSS structure changes in one of the panels.

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.

3 participants