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

backend/assistants_web: Fix alignment of wikipedia toggle #870

Merged
merged 2 commits into from
Dec 5, 2024

Conversation

scottmx81
Copy link
Collaborator

@scottmx81 scottmx81 commented Dec 5, 2024

This PR fixes the alignment of the Wikipedia switch, in the feature to toggle tools on or off.

I have fixed the issue by setting a width in the top level div of the Switch component. The reason why this fixes the issue is because a flex-grow class is being used in the container div around the description and switch divs. The switch has a width of 30px defined in it already, but not at the top level div returned by the component, but rather on the HUSwitch component it uses. The width on the HUSwitch component made the switch itself look the right size, but the Switch component was growing also, not just the description, since it didn't have an explicit width.

The reason why this only affected the other tools (Python Interpreter & Hybrid Web Search), and not Wikipedia, is because of the shorter description for Wikipedia. With the longer descriptions, the flex-grow: 1 made the description div the one that grew all the way, because of the overflowing text. But with the short description that didn't reach the end of the line, the flex-grow: 1 made both the div around the switch, and the div around the description both grow. With the explicit width at the top level div of the Switch component, but not width on the div around the description, the div around the description is the one that always grows.

I tried a couple of other ways of dealing with this, such as right aligning the switch, but I didn't like that the container div around it was still a different size. I tried adding a basis-0 class, but the effect was that the buttons were all properly aligned, but not at the very end. I think just setting the width where I have is fine, and it should not affect anywhere else in the code where the switch is used, because an explicit w-[30px] class is already hard-coded into the Switch component.

Screenshot 2024-12-05 at 11 56 05 AM Screenshot 2024-12-05 at 11 57 01 AM

AI Description

This PR updates the Switch component in the src/interfaces/assistants_web/src/components/UI/Switch.tsx file.

Changes

  • The w-10 class is replaced with w-[30px] to adjust the width of the div element.

@scottmx81 scottmx81 merged commit 64e18d2 into cohere-ai:main Dec 5, 2024
8 checks passed
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.

2 participants