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);
return (
<TabLayout>
<TabLayout scrollable>
<div className={styles.ClusterOverview} data-testid="cluster-overview-page">
{this.renderClusterOverview(isLoaded, isMetricHidden)}
</div>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,6 +20,7 @@ export interface TabLayoutProps {
contentClass?: IClassName;
tabs?: TabLayoutRoute[];
children?: ReactNode;
scrollable?: boolean;
}
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
}
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 hasTabs = tabs.length > 0;
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>
)}
<main className={cssNames(contentClass)}>
<main className={cssNames(contentClass, { scrollable })}>
<ErrorBoundary>
{hasTabs && (
<Switch>

View File

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