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

Add navigation layout in <PageLayout/>

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-02-24 15:18:42 +03:00
parent 0d3505cfac
commit 000244a484
3 changed files with 49 additions and 25 deletions

View File

@ -111,7 +111,12 @@ export class Preferences extends React.Component {
const header = <h2>Preferences</h2>; const header = <h2>Preferences</h2>;
return ( return (
<PageLayout showOnTop className="Preferences" header={header}> <PageLayout
showOnTop
showNavigation
className="Preferences"
header={header}
>
<h2>Color Theme</h2> <h2>Color Theme</h2>
<Select <Select
options={this.themeOptions} options={this.themeOptions}

View File

@ -1,8 +1,9 @@
.PageLayout { .PageLayout {
$spacing: $padding * 2;
--width: 60%; --width: 60%;
--max-width: 1000px; --max-width: 1000px;
--min-width: 570px; --min-width: 570px;
--nav-width: 160px;
--spacing: calc(var(--unit) * 2);
position: relative; position: relative;
width: 100%; width: 100%;
@ -10,45 +11,56 @@
display: grid !important; display: grid !important;
grid-template-rows: min-content 1fr; grid-template-rows: min-content 1fr;
&.showNavigation {
--width: 70%;
> .content-scrollable-area {
> .content-wrapper {
grid-template-columns: var(--nav-width) 1fr;
}
}
}
// covers whole app view area // covers whole app view area
&.top { &.showOnTop {
position: fixed !important; // allow to cover ClustersMenu position: fixed !important; // allow to cover ClustersMenu
z-index: 1; z-index: 1;
left: 0; left: 0;
top: 0; top: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background-color: $mainBackground; background-color: var(--mainBackground);
// adds extra space for traffic-light top buttons (mac only) // adds extra space for traffic-light top buttons (mac only)
.is-mac & > .header { .is-mac & > .header {
padding-top: $spacing * 2; padding-top: calc(var(--spacing) * 2);
} }
} }
> .header { > .header {
position: sticky; position: sticky;
padding: $spacing; padding: var(--spacing);
background-color: $layoutTabsBackground; background-color: $layoutTabsBackground;
} }
> .content-wrapper { > .content-scrollable-area {
overflow: auto; overflow: auto;
padding: $spacing * 2; display: grid;
display: flex; place-items: center;
flex-direction: column;
> .content { > .content-wrapper {
flex: 1; display: grid;
margin: 0 auto; grid-template-columns: none;
column-gap: 16px;
width: var(--width); width: var(--width);
min-width: var(--min-width); min-width: var(--min-width);
max-width: var(--max-width); max-width: var(--max-width);
padding: calc(var(--spacing) * 2);
} }
} }
h2:not(:first-of-type) { h2:not(:first-of-type) {
margin-top: $spacing; margin-top: var(--spacing);
} }
p { p {
@ -56,21 +68,17 @@
} }
a { a {
color: $colorInfo; color: var(--colorInfo);
} }
.SubTitle { .SubTitle {
text-transform: none; text-transform: none;
margin-bottom: 0 !important; margin-bottom: 0 !important;
+ * + .hint {
margin-top: -$padding / 2;
}
} }
.Select { .Select {
&__control { &__control {
box-shadow: 0 0 0 1px $borderFaintColor; box-shadow: 0 0 0 1px var(--borderFaintColor);
} }
} }
} }

View File

@ -14,6 +14,7 @@ export interface PageLayoutProps extends React.DOMAttributes<any> {
provideBackButtonNavigation?: boolean; provideBackButtonNavigation?: boolean;
contentGaps?: boolean; contentGaps?: boolean;
showOnTop?: boolean; // covers whole app view showOnTop?: boolean; // covers whole app view
showNavigation?: boolean;
back?: (evt: React.MouseEvent | KeyboardEvent) => void; back?: (evt: React.MouseEvent | KeyboardEvent) => void;
} }
@ -57,9 +58,9 @@ export class PageLayout extends React.Component<PageLayoutProps> {
render() { render() {
const { const {
contentClass, header, headerClass, provideBackButtonNavigation, contentClass, header, headerClass, provideBackButtonNavigation,
contentGaps, showOnTop, children, ...elemProps contentGaps, showOnTop, showNavigation, children, ...elemProps
} = this.props; } = this.props;
const className = cssNames("PageLayout", { top: showOnTop }, this.props.className); const className = cssNames("PageLayout", { showOnTop, showNavigation }, this.props.className);
return ( return (
<div {...elemProps} className={className}> <div {...elemProps} className={className}>
@ -73,9 +74,19 @@ export class PageLayout extends React.Component<PageLayoutProps> {
/> />
)} )}
</div> </div>
<div className="content-wrapper"> <div className="content-scrollable-area">
<div className={cssNames("content", contentGaps && "flex column gaps", contentClass)}> <div className="content-wrapper">
{children} { showNavigation && (
<div className="content-navigation">
<ul>
<li>Section 1</li>
<li>Section 2</li>
</ul>
</div>
)}
<div className={cssNames("content", contentGaps && "flex column gaps", contentClass)}>
{children}
</div>
</div> </div>
</div> </div>
</div> </div>