korbit-ai[bot] commented on code in PR #34725: URL: https://github.com/apache/superset/pull/34725#discussion_r2280628071
########## superset-frontend/src/features/home/StyledDropdownSubMenu.tsx: ########## @@ -0,0 +1,45 @@ +/** + * 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 { styled, css } from '@superset-ui/core'; +import { MainNav } from '@superset-ui/core/components/Menu'; + +const { SubMenu } = MainNav; + +/** + * Shared styled submenu component with consistent caret positioning. + * Positions the caret icon on the right side of the label for dropdown menus. + */ +export const StyledDropdownSubMenu = styled(SubMenu)` + ${({ theme }) => css` + [data-icon="caret-down"] { + color: ${theme.colors.grayscale.base}; + font-size: ${theme.fontSizeXS}px; + margin-left: ${theme.sizeUnit}px; + } Review Comment: ### Inefficient Theme Property Access <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? Dynamic theme interpolation in styled-components causes unnecessary re-renders and style recalculations on every theme prop change. ###### Why this matters Each theme property access creates a new CSS-in-JS object, leading to performance overhead in style computation and potential memory churn. ###### Suggested change ∙ *Feature Preview* Destructure required theme properties at the start of the styled component to minimize theme object access and style recalculations: ```typescript ${({ theme: { colors, fontSizeXS, sizeUnit, colorPrimary } }) => css` [data-icon="caret-down"] { color: ${colors.grayscale.base}; font-size: ${fontSizeXS}px; margin-left: ${sizeUnit}px; } `} ``` ###### Provide feedback to improve future suggestions [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/ad60f03b-1f28-405a-870a-fddd2ab63691/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/ad60f03b-1f28-405a-870a-fddd2ab63691?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/ad60f03b-1f28-405a-870a-fddd2ab63691?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/ad60f03b-1f28-405a-870a-fddd2ab63691?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/ad60f03b-1f28-405a-870a-fddd2ab63691) </details> <sub> 💬 Looking for more details? Reply to this comment to chat with Korbit. </sub> <!--- korbi internal id:f9e2bc9a-9cc7-403c-8269-47863ff3cf56 --> [](f9e2bc9a-9cc7-403c-8269-47863ff3cf56) ########## superset-frontend/src/features/home/StyledDropdownSubMenu.tsx: ########## @@ -0,0 +1,45 @@ +/** + * 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 { styled, css } from '@superset-ui/core'; +import { MainNav } from '@superset-ui/core/components/Menu'; + +const { SubMenu } = MainNav; + +/** + * Shared styled submenu component with consistent caret positioning. + * Positions the caret icon on the right side of the label for dropdown menus. + */ +export const StyledDropdownSubMenu = styled(SubMenu)` + ${({ theme }) => css` + [data-icon="caret-down"] { + color: ${theme.colors.grayscale.base}; + font-size: ${theme.fontSizeXS}px; + margin-left: ${theme.sizeUnit}px; + } + &.ant-menu-submenu { + padding: ${theme.sizeUnit * 2}px ${theme.sizeUnit * 4}px; + display: flex; + align-items: center; + height: 100%; &.ant-menu-submenu-active { + .ant-menu-title-content { + color: ${theme.colorPrimary}; + } + } Review Comment: ### Inconsistent CSS Nesting Structure <sub></sub> <details> <summary>Tell me more</summary> ###### What is the issue? The CSS nesting structure is poorly formatted and inconsistent, making it difficult to understand the hierarchy and relationship between selectors. ###### Why this matters Poor CSS structure can lead to maintenance issues, specificity conflicts, and makes it harder for other developers to modify styles correctly. ###### Suggested change ∙ *Feature Preview* Restructure the CSS nesting to be consistent and clear: ```typescript &.ant-menu-submenu { padding: ${theme.sizeUnit * 2}px ${theme.sizeUnit * 4}px; display: flex; align-items: center; height: 100%; &.ant-menu-submenu-active { .ant-menu-title-content { color: ${theme.colorPrimary}; } } } ``` ###### Provide feedback to improve future suggestions [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4147f1de-c5c7-46c5-b2bc-c72a486c2433/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4147f1de-c5c7-46c5-b2bc-c72a486c2433?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4147f1de-c5c7-46c5-b2bc-c72a486c2433?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4147f1de-c5c7-46c5-b2bc-c72a486c2433?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/4147f1de-c5c7-46c5-b2bc-c72a486c2433) </details> <sub> 💬 Looking for more details? Reply to this comment to chat with Korbit. </sub> <!--- korbi internal id:1900c473-2477-4bea-9f2b-c8b2a3f8b23d --> [](1900c473-2477-4bea-9f2b-c8b2a3f8b23d) -- 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]
