1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Remove excessive scrollbars from the TabLayout view

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-12-01 15:29:04 +03:00
parent e5f8951553
commit 0b0988f14e
9 changed files with 24 additions and 13 deletions

View File

@ -102,7 +102,7 @@ class NonInjectedClusterOverview extends React.Component<Dependencies> {
const isMetricHidden = hostedCluster.isMetricHidden(ClusterMetricsResourceType.Cluster); const isMetricHidden = hostedCluster.isMetricHidden(ClusterMetricsResourceType.Cluster);
return ( return (
<TabLayout> <TabLayout scrollable>
<div className={styles.ClusterOverview} data-testid="cluster-overview-page"> <div className={styles.ClusterOverview} data-testid="cluster-overview-page">
{this.renderClusterOverview(isLoaded, isMetricHidden)} {this.renderClusterOverview(isLoaded, isMetricHidden)}
</div> </div>

View File

@ -103,7 +103,7 @@ class NonInjectedWorkloadsOverview extends React.Component<Dependencies> {
render() { render() {
return ( return (
<SiblingsInTabLayout> <SiblingsInTabLayout scrollable>
<div className="WorkloadsOverview flex column gaps" data-testid="page-for-workloads-overview"> <div className="WorkloadsOverview flex column gaps" data-testid="page-for-workloads-overview">
<div className="header flex gaps align-center"> <div className="header flex gaps align-center">
<h5 className="box grow">Overview</h5> <h5 className="box grow">Overview</h5>

View File

@ -31,7 +31,7 @@
> .items { > .items {
position: relative; position: relative;
min-height: 200px; min-height: 130px;
} }
} }

View File

@ -23,9 +23,7 @@
} }
.contents { .contents {
grid-area: contents; overflow: hidden;
overflow: auto;
height: calc(100vh - var(--status-bar-height) - var(--main-layout-header));
} }
.footer { .footer {

View File

@ -12,6 +12,7 @@ import type { HierarchicalSidebarItem } from "./sidebar-items.injectable";
interface SiblingTabLayoutProps { interface SiblingTabLayoutProps {
children: React.ReactNode; children: React.ReactNode;
scrollable?: boolean;
} }
interface Dependencies { interface Dependencies {
@ -19,13 +20,14 @@ interface Dependencies {
} }
const NonInjectedSiblingsInTabLayout = observer( const NonInjectedSiblingsInTabLayout = observer(
({ tabs, children }: Dependencies & SiblingTabLayoutProps) => { ({ tabs, children, ...other }: Dependencies & SiblingTabLayoutProps) => {
const dereferencedTabs = tabs.get(); const dereferencedTabs = tabs.get();
if (dereferencedTabs.length) { if (dereferencedTabs.length) {
return ( return (
<TabLayout <TabLayout
tabs={dereferencedTabs} tabs={dereferencedTabs}
{...other}
> >
{children} {children}
</TabLayout> </TabLayout>

View File

@ -15,11 +15,13 @@ import type { HierarchicalSidebarItem } from "./sidebar-items.injectable";
export interface TabLayoutProps { export interface TabLayoutProps {
tabs?: HierarchicalSidebarItem[]; tabs?: HierarchicalSidebarItem[];
children?: React.ReactNode; children?: React.ReactNode;
scrollable?: boolean;
} }
export const TabLayout = observer( export const TabLayout = observer(
({ ({
tabs = [], tabs = [],
scrollable,
children, children,
}: TabLayoutProps) => { }: TabLayoutProps) => {
const hasTabs = tabs.length > 0; const hasTabs = tabs.length > 0;
@ -50,7 +52,7 @@ export const TabLayout = observer(
</Tabs> </Tabs>
)} )}
<main> <main className={cssNames({ scrollable })}>
<ErrorBoundary> <ErrorBoundary>
{children} {children}
</ErrorBoundary> </ErrorBoundary>

View File

@ -11,16 +11,20 @@
> .Tabs { > .Tabs {
background: var(--layoutTabsBackground); background: var(--layoutTabsBackground);
min-height: 32px; min-height: 36px;
} }
main { main {
$spacing: $margin * 2; $spacing: $margin * 2;
flex-grow: 1; flex-grow: 1;
overflow-y: scroll; // always reserve space for scrollbar (17px) overflow-y: hidden;
overflow-x: auto; overflow-x: auto;
margin: $spacing; margin: $spacing;
margin-right: 0;
&.scrollable {
overflow-y: scroll;
margin-right: 0;
}
} }
} }

View File

@ -20,6 +20,7 @@ export interface TabLayoutProps {
contentClass?: IClassName; contentClass?: IClassName;
tabs?: TabLayoutRoute[]; tabs?: TabLayoutRoute[];
children?: ReactNode; children?: ReactNode;
scrollable?: boolean;
} }
export interface TabLayoutRoute { export interface TabLayoutRoute {
@ -31,7 +32,7 @@ export interface TabLayoutRoute {
default?: boolean; // initial tab to open with provided `url, by default tabs[0] is used default?: boolean; // initial tab to open with provided `url, by default tabs[0] is used
} }
export const TabLayout = observer(({ className, contentClass, tabs = [], children }: TabLayoutProps) => { export const TabLayout = observer(({ className, contentClass, tabs = [], scrollable, children }: TabLayoutProps) => {
const currentLocation = navigation.location.pathname; const currentLocation = navigation.location.pathname;
const hasTabs = tabs.length > 0; const hasTabs = tabs.length > 0;
const startTabUrl = hasTabs ? (tabs.find(tab => tab.default) || tabs[0])?.url : null; const startTabUrl = hasTabs ? (tabs.find(tab => tab.default) || tabs[0])?.url : null;
@ -50,7 +51,7 @@ export const TabLayout = observer(({ className, contentClass, tabs = [], childre
))} ))}
</Tabs> </Tabs>
)} )}
<main className={cssNames(contentClass)}> <main className={cssNames(contentClass, { scrollable })}>
<ErrorBoundary> <ErrorBoundary>
{hasTabs && ( {hasTabs && (
<Switch> <Switch>

View File

@ -14,6 +14,10 @@
overflow: auto; overflow: auto;
} }
&.scrollable.virtual {
overflow: unset;
}
&.selectable { &.selectable {
.TableHead, .TableRow { .TableHead, .TableRow {
padding: 0 $padding; padding: 0 $padding;