Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dataset): resizable dataset layout left column #24829

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ interface LeftPanelProps {

const LeftPanelStyle = styled.div`
${({ theme }) => `
max-width: ${theme.gridUnit * 87.5}px;
padding: ${theme.gridUnit * 4}px;
height: 100%;
background-color: ${theme.colors.grayscale.light5};
Expand Down
20 changes: 17 additions & 3 deletions superset-frontend/src/features/datasets/DatasetLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
* under the License.
*/
import React, { ReactElement, JSXElementConstructor } from 'react';
import { useTheme } from '@superset-ui/core';
import ResizableSidebar from 'src/components/ResizableSidebar';

import {
StyledLayoutWrapper,
LeftColumn,
Expand Down Expand Up @@ -46,14 +49,25 @@ export default function DatasetLayout({
rightPanel,
footer,
}: DatasetLayoutProps) {
const theme = useTheme();

return (
<StyledLayoutWrapper data-test="dataset-layout-wrapper">
{header && <StyledLayoutHeader>{header}</StyledLayoutHeader>}
<OuterRow>
{leftPanel && (
<LeftColumn>
<StyledLayoutLeftPanel>{leftPanel}</StyledLayoutLeftPanel>
</LeftColumn>
<ResizableSidebar
id="dataset"
initialWidth={theme.gridUnit * 80}
minWidth={theme.gridUnit * 80}
enable
>
{adjustedWidth => (
<LeftColumn width={adjustedWidth}>
<StyledLayoutLeftPanel>{leftPanel}</StyledLayoutLeftPanel>
</LeftColumn>
)}
</ResizableSidebar>
)}
<RightColumn>
<PanelRow>
Expand Down
10 changes: 5 additions & 5 deletions superset-frontend/src/features/datasets/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ export const StyledLayoutWrapper = styled.div`
background-color: ${({ theme }) => theme.colors.grayscale.light5};
`;

const Column = styled.div`
const Column = styled.div<{ width?: number }>`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that LeftColumn and RightColumn are pretty much overriding the properties of Column, could you remove Column? I think it will be way more readable.

export const LeftColumn = styled.div<{ theme: SupersetTheme; width?: number }>`
  width: ${({ theme, width }) => width ?? theme.gridUnit * 80}px;
  height: auto;
  flex-direction: column;
`;

export const RightColumn = styled.div`
  width: auto;
  height: auto;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
`;

width: 100%;
height: 100%;
flex-direction: column;
`;

export const LeftColumn = styled(Column)`
width: ${({ theme }) => theme.gridUnit * 80}px;
width: ${({ theme, width }) => width ?? theme.gridUnit * 80}px;
height: auto;
`;

export const RightColumn = styled(Column)`
width: auto;
height: auto;
display: flex;
flex: 1 0 auto;
width: calc(100% - ${({ theme }) => theme.gridUnit * 80}px);
flex: 1 1 auto;
`;