You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/05/14 16:55:47 UTC

[GitHub] [superset] michael-s-molina commented on a change in pull request #14631: fix: fix submenu header double line

michael-s-molina commented on a change in pull request #14631:
URL: https://github.com/apache/superset/pull/14631#discussion_r632660829



##########
File path: superset-frontend/src/components/Menu/SubMenu.tsx
##########
@@ -195,69 +192,57 @@ const SubMenuComponent: React.FunctionComponent<SubMenuProps> = props => {
     return () => window.removeEventListener('resize', resize);
   }, [props.buttons]);
 
-  const offset = props.name ? headerSize : 0;
-
   return (
     <StyledHeader>
       <Row className="menu" role="navigation">
-        {props.name && (
-          <Col md={offset} xs={24}>
-            <div className="header">{props.name}</div>
-          </Col>
-        )}
-        <Col md={16 - offset} sm={24} xs={24}>
-          <Menu mode={showMenu} style={{ backgroundColor: 'transparent' }}>
-            {props.tabs &&
-              props.tabs.map(tab => {
-                if ((props.usesRouter || hasHistory) && !!tab.usesRouter) {
-                  return (
-                    <Menu.Item key={tab.label}>
-                      <li
-                        role="tab"
-                        data-test={tab['data-test']}
-                        className={
-                          tab.name === props.activeChild ? 'active' : ''
-                        }
-                      >
-                        <div>
-                          <Link to={tab.url || ''}>{tab.label}</Link>
-                        </div>
-                      </li>
-                    </Menu.Item>
-                  );
-                }
-
+        {props.name && <div className="header">{props.name}</div>}
+        <Menu mode={showMenu} style={{ backgroundColor: 'transparent' }}>
+          {props.tabs &&
+            props.tabs.map(tab => {

Review comment:
       ```suggestion
             {props.tabs?.map(tab => {
   ```

##########
File path: superset-frontend/src/components/Menu/SubMenu.tsx
##########
@@ -195,69 +192,57 @@ const SubMenuComponent: React.FunctionComponent<SubMenuProps> = props => {
     return () => window.removeEventListener('resize', resize);
   }, [props.buttons]);
 
-  const offset = props.name ? headerSize : 0;
-
   return (
     <StyledHeader>
       <Row className="menu" role="navigation">
-        {props.name && (
-          <Col md={offset} xs={24}>
-            <div className="header">{props.name}</div>
-          </Col>
-        )}
-        <Col md={16 - offset} sm={24} xs={24}>
-          <Menu mode={showMenu} style={{ backgroundColor: 'transparent' }}>
-            {props.tabs &&
-              props.tabs.map(tab => {
-                if ((props.usesRouter || hasHistory) && !!tab.usesRouter) {
-                  return (
-                    <Menu.Item key={tab.label}>
-                      <li
-                        role="tab"
-                        data-test={tab['data-test']}
-                        className={
-                          tab.name === props.activeChild ? 'active' : ''
-                        }
-                      >
-                        <div>
-                          <Link to={tab.url || ''}>{tab.label}</Link>
-                        </div>
-                      </li>
-                    </Menu.Item>
-                  );
-                }
-
+        {props.name && <div className="header">{props.name}</div>}
+        <Menu mode={showMenu} style={{ backgroundColor: 'transparent' }}>
+          {props.tabs &&
+            props.tabs.map(tab => {
+              if ((props.usesRouter || hasHistory) && !!tab.usesRouter) {
                 return (
                   <Menu.Item key={tab.label}>
                     <li
-                      className={cx('no-router', {
-                        active: tab.name === props.activeChild,
-                      })}
                       role="tab"
+                      data-test={tab['data-test']}

Review comment:
       Is this required? You already have a `role` defined. If you need more distinction you can use `aria-label `also.

##########
File path: superset-frontend/src/components/Menu/SubMenu.tsx
##########
@@ -195,69 +192,57 @@ const SubMenuComponent: React.FunctionComponent<SubMenuProps> = props => {
     return () => window.removeEventListener('resize', resize);
   }, [props.buttons]);
 
-  const offset = props.name ? headerSize : 0;
-
   return (
     <StyledHeader>
       <Row className="menu" role="navigation">
-        {props.name && (
-          <Col md={offset} xs={24}>
-            <div className="header">{props.name}</div>
-          </Col>
-        )}
-        <Col md={16 - offset} sm={24} xs={24}>
-          <Menu mode={showMenu} style={{ backgroundColor: 'transparent' }}>
-            {props.tabs &&
-              props.tabs.map(tab => {
-                if ((props.usesRouter || hasHistory) && !!tab.usesRouter) {
-                  return (
-                    <Menu.Item key={tab.label}>
-                      <li
-                        role="tab"
-                        data-test={tab['data-test']}
-                        className={
-                          tab.name === props.activeChild ? 'active' : ''
-                        }
-                      >
-                        <div>
-                          <Link to={tab.url || ''}>{tab.label}</Link>
-                        </div>
-                      </li>
-                    </Menu.Item>
-                  );
-                }
-
+        {props.name && <div className="header">{props.name}</div>}
+        <Menu mode={showMenu} style={{ backgroundColor: 'transparent' }}>
+          {props.tabs &&
+            props.tabs.map(tab => {
+              if ((props.usesRouter || hasHistory) && !!tab.usesRouter) {
                 return (
                   <Menu.Item key={tab.label}>
                     <li
-                      className={cx('no-router', {
-                        active: tab.name === props.activeChild,
-                      })}
                       role="tab"
+                      data-test={tab['data-test']}
+                      className={tab.name === props.activeChild ? 'active' : ''}
                     >
-                      <a href={tab.url} onClick={tab.onClick}>
-                        {tab.label}
-                      </a>
+                      <div>
+                        <Link to={tab.url || ''}>{tab.label}</Link>
+                      </div>
                     </li>
                   </Menu.Item>
                 );
-              })}
-          </Menu>
-        </Col>
-        <Col lg={8} md={navRightCol} sm={24} xs={24}>
-          <div className={navRightStyle}>
-            {props.buttons?.map((btn, i) => (
-              <Button
-                key={i}
-                buttonStyle={btn.buttonStyle}
-                onClick={btn.onClick}
-                data-test={btn['data-test']}
-              >
-                {btn.name}
-              </Button>
-            ))}
-          </div>
-        </Col>
+              }
+
+              return (
+                <Menu.Item key={tab.label}>
+                  <li
+                    className={cx('no-router', {
+                      active: tab.name === props.activeChild,
+                    })}
+                    role="tab"
+                  >
+                    <a href={tab.url} onClick={tab.onClick}>
+                      {tab.label}
+                    </a>
+                  </li>
+                </Menu.Item>
+              );
+            })}
+        </Menu>
+        <div className={navRightStyle}>
+          {props.buttons?.map((btn, i) => (
+            <Button
+              key={i}
+              buttonStyle={btn.buttonStyle}
+              onClick={btn.onClick}
+              data-test={btn['data-test']}

Review comment:
       You can query by button `role` and `name` here. `data-test` is not required.

##########
File path: superset-frontend/src/components/Menu/SubMenu.tsx
##########
@@ -195,69 +192,57 @@ const SubMenuComponent: React.FunctionComponent<SubMenuProps> = props => {
     return () => window.removeEventListener('resize', resize);
   }, [props.buttons]);
 
-  const offset = props.name ? headerSize : 0;
-
   return (
     <StyledHeader>
       <Row className="menu" role="navigation">
-        {props.name && (
-          <Col md={offset} xs={24}>
-            <div className="header">{props.name}</div>
-          </Col>
-        )}
-        <Col md={16 - offset} sm={24} xs={24}>
-          <Menu mode={showMenu} style={{ backgroundColor: 'transparent' }}>
-            {props.tabs &&
-              props.tabs.map(tab => {
-                if ((props.usesRouter || hasHistory) && !!tab.usesRouter) {
-                  return (
-                    <Menu.Item key={tab.label}>
-                      <li
-                        role="tab"
-                        data-test={tab['data-test']}
-                        className={
-                          tab.name === props.activeChild ? 'active' : ''
-                        }
-                      >
-                        <div>
-                          <Link to={tab.url || ''}>{tab.label}</Link>
-                        </div>
-                      </li>
-                    </Menu.Item>
-                  );
-                }
-
+        {props.name && <div className="header">{props.name}</div>}
+        <Menu mode={showMenu} style={{ backgroundColor: 'transparent' }}>
+          {props.tabs &&
+            props.tabs.map(tab => {
+              if ((props.usesRouter || hasHistory) && !!tab.usesRouter) {
                 return (
                   <Menu.Item key={tab.label}>
                     <li
-                      className={cx('no-router', {
-                        active: tab.name === props.activeChild,
-                      })}
                       role="tab"
+                      data-test={tab['data-test']}
+                      className={tab.name === props.activeChild ? 'active' : ''}
                     >
-                      <a href={tab.url} onClick={tab.onClick}>
-                        {tab.label}
-                      </a>
+                      <div>

Review comment:
       Is this `div` required?

##########
File path: superset-frontend/src/components/Menu/SubMenu.tsx
##########
@@ -42,6 +42,8 @@ const StyledHeader = styled.div`
     padding: 14px 0;
     margin-right: ${({ theme }) => theme.gridUnit * 3}px;

Review comment:
       You can replace all instances of ${({ theme }) => by moving this piece of code to the top like this https://github.com/apache/superset/pull/14448/files#diff-0856ab0ce511fac9256389d5ed3635f15d77ec907de602ce32d28f072de76753




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org