sadpandajoe commented on code in PR #36330: URL: https://github.com/apache/superset/pull/36330#discussion_r2677160123
########## superset-frontend/src/components/KebabMenuButton/index.tsx: ########## @@ -0,0 +1,146 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { ReactNode } from 'react'; +import { css, useTheme } from '@apache-superset/core/ui'; +import { Dropdown, Button } from '@superset-ui/core/components'; +import { Icons } from '@superset-ui/core/components/Icons'; +import { MenuItem } from '@superset-ui/core/components/Menu'; + +export interface KebabMenuButtonProps { + /** + * Menu items to display in the dropdown + */ + menuItems: MenuItem[]; + /** + * Optional: Custom icon to use instead of the default three-dot icon + */ + icon?: ReactNode; + /** + * Optional: Button size (default: 'xsmall') + */ + buttonSize?: 'small' | 'xsmall'; + /** + * Optional: aria-label for accessibility + */ + ariaLabel?: string; + /** + * Optional: data-test attribute for testing + */ + dataTest?: string; + /** + * Optional: Button id attribute + */ + buttonId?: string; + /** + * Optional: Button style (default: 'link') + */ + buttonStyle?: 'primary' | 'secondary' | 'tertiary' | 'danger' | 'link'; + /** + * Optional: Additional CSS for the button + */ + buttonCss?: ReturnType<typeof css>; + /** + * Optional: Additional styles for the dropdown overlay + */ + overlayStyle?: React.CSSProperties; + /** + * Optional: Dropdown placement + */ + placement?: + | 'bottomLeft' + | 'bottomCenter' + | 'bottomRight' + | 'topLeft' + | 'topCenter' + | 'topRight'; + /** + * Optional: IconOrientation - 'horizontal' for horizontal dots, 'vertical' for vertical dots + */ + iconOrientation?: 'horizontal' | 'vertical'; +} + +/** + * Standardized kebab menu button component with consistent styling and behavior + * across Welcome page cards and Dashboard/Chart cards. + * + * Features: + * - Uses colorTextLabel for consistent icon color + * - Opens on click (not hover) for better UX consistency + * - Wraps Ant Design Dropdown with Superset conventions + */ +export function KebabMenuButton({ + menuItems, + icon, + buttonSize = 'xsmall', + ariaLabel = 'More Options', + dataTest, + buttonId, + buttonStyle, + buttonCss, + overlayStyle, + placement = 'bottomRight', + iconOrientation = 'horizontal', +}: KebabMenuButtonProps) { + const theme = useTheme(); + + const defaultIcon = + iconOrientation === 'vertical' ? ( + <Icons.EllipsisOutlined + css={css` + transform: rotate(90deg); + &:hover { + cursor: pointer; + } + `} + iconSize="xl" + iconColor={theme.colorTextLabel} + /> + ) : ( + <Icons.MoreOutlined + iconSize="xl" + iconColor={theme.colorTextLabel} + css={css` + &:hover { + cursor: pointer; + } + `} + /> + ); Review Comment: By hardcoding `iconColor` to `theme.colorTextLabel`, won't this mean that icons no longer inherits button for different states like hover, active, disabled? -- 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]
