## Description Updating the styles for JS settings popover Fixes #40657 ## Automation /ok-to-test tags="@tag.JS" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/15045634120> > Commit: 0346eec44945dee8b0a98ece911e23f36709c5b2 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=15045634120&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.JS` > Spec: > <hr>Thu, 15 May 2025 13:49:10 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added the ability to customize the width of the settings popover in toolbars. - **Style** - Improved text wrapping for function names in the function settings panel. - Adjusted spacing and set a minimum width for dropdown selectors to enhance layout consistency. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import React, { useCallback } from "react";
|
|
import {
|
|
Popover,
|
|
PopoverBody,
|
|
PopoverContent,
|
|
PopoverHeader,
|
|
PopoverTrigger,
|
|
ToggleButton,
|
|
} from "@appsmith/ads";
|
|
import styled from "styled-components";
|
|
|
|
interface Props {
|
|
isOpen: boolean;
|
|
handleOpenChange: (isOpen: boolean) => void;
|
|
title: string;
|
|
children: React.ReactNode;
|
|
dataTestId?: string;
|
|
disabled?: boolean;
|
|
popoverWidth?: string;
|
|
}
|
|
|
|
const StyledPopoverHeader = styled(PopoverHeader)`
|
|
margin-bottom: var(--ads-v2-spaces-5);
|
|
`;
|
|
|
|
const StyledPopoverContent = styled(PopoverContent)<{ popoverWidth?: string }>`
|
|
--popover-width: ${({ popoverWidth }) =>
|
|
popoverWidth ? popoverWidth : "280px"};
|
|
`;
|
|
|
|
export const ToolbarSettingsPopover = (props: Props) => {
|
|
const { handleOpenChange, isOpen, popoverWidth, title } = props;
|
|
const handleButtonClick = useCallback(() => {
|
|
handleOpenChange(true);
|
|
}, [handleOpenChange]);
|
|
|
|
const handleEscapeKeyDown = useCallback(() => {
|
|
handleOpenChange(false);
|
|
}, [handleOpenChange]);
|
|
|
|
return (
|
|
<Popover onOpenChange={handleOpenChange} open={isOpen}>
|
|
<PopoverTrigger>
|
|
<ToggleButton
|
|
data-testid={props.dataTestId}
|
|
disabled={props.disabled}
|
|
icon="settings-v3"
|
|
isSelected={isOpen}
|
|
onClick={handleButtonClick}
|
|
size="md"
|
|
/>
|
|
</PopoverTrigger>
|
|
<StyledPopoverContent
|
|
align="end"
|
|
onEscapeKeyDown={handleEscapeKeyDown}
|
|
popoverWidth={popoverWidth}
|
|
size="sm"
|
|
>
|
|
<StyledPopoverHeader isClosable>{title}</StyledPopoverHeader>
|
|
<PopoverBody>{props.children}</PopoverBody>
|
|
</StyledPopoverContent>
|
|
</Popover>
|
|
);
|
|
};
|