dosubot[bot] commented on issue #29477: URL: https://github.com/apache/superset/issues/29477#issuecomment-2207485460
<!-- Greeting --> Привет, @goldjee! Я - [Dosu](https://dosu.dev), бот, который может помочь вам решить проблемы, ответить на вопросы и стать участником проекта. Я здесь, чтобы помочь вам, в ожидании ответа от человеческого обслуживающего лица. <!-- Answer --> To modify the "Save" button in SQL Lab to dynamically adjust its size based on the length of the localized label, you can remove the fixed width and allow the button to size itself based on its content. Here is the modified code: ```tsx import { FC } from 'react'; import { t, useTheme, styled } from '@superset-ui/core'; import Icons from 'src/components/Icons'; import { DropdownButton } from 'src/components/DropdownButton'; import Button from 'src/components/Button'; import { DropdownButtonProps } from 'antd/lib/dropdown'; interface SaveDatasetActionButtonProps { setShowSave: (arg0: boolean) => void; overlayMenu: JSX.Element | null; } const SaveDatasetActionButton = ({ setShowSave, overlayMenu, }: SaveDatasetActionButtonProps) => { const theme = useTheme(); const StyledDropdownButton = styled( DropdownButton as FC<DropdownButtonProps>, )` &.ant-dropdown-button button.ant-btn.ant-btn-default { font-weight: ${theme.gridUnit * 150}; background-color: ${theme.colors.primary.light4}; color: ${theme.colors.primary.dark1}; &:nth-of-type(2) { &:before, &:hover:before { border-left: 2px solid ${theme.colors.primary.dark2}; } } } span[name='caret-down'] { margin-left: ${theme.gridUnit * 1}px; color: ${theme.colors.primary.dark2}; } `; return !overlayMenu ? ( <Button onClick={() => setShowSave(true)} buttonStyle="primary" > {t('Save')} </Button> ) : ( <StyledDropdownButton onClick={() => setShowSave(true)} overlay={overlayMenu} icon={ <Icons.CaretDown iconColor={theme.colors.grayscale.light5} name="caret-down" /> } trigger={['click']} > {t('Save')} </StyledDropdownButton> ); }; export default SaveDatasetActionButton; ``` In this modification, the fixed width is removed from the `Button` component, allowing it to adjust its size based on the length of the localized label. This ensures that the button can accommodate longer labels, such as the Russian "СОХРАН" <sup>[[1]](https://github.com/apache/superset/blob/master/superset-frontend/src/SqlLab/components/SaveDatasetActionButton/index.tsx)</sup>. Additionally, there are other buttons in the SQL Lab interface that have a fixed size and might need similar adjustments for localization. For example, the "Create" button in the modal has a fixed size: ```tsx <Button buttonStyle="primary" disabled={ctas.length === 0} onClick={createViewAs} > {t('Create')} </Button> ``` This button might need adjustments to accommodate different text lengths in various languages <sup>[[2]](https://github.com/apache/superset/blob/master/superset-frontend/src/SqlLab/components/SqlEditor/index.tsx)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
