-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Web console: Improve workbench view with resizable side panels (#17387)
- Loading branch information
1 parent
d5bb7de
commit 4b7902e
Showing
29 changed files
with
1,158 additions
and
629 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
web-console/src/components/splitter-layout/__snapshots__/splitter-layout.spec.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SplitterLayout matches snapshot one child 1`] = ` | ||
<div | ||
class="splitter-layout splitter-layout-horizontal" | ||
> | ||
<div | ||
class="layout-pane layout-pane-primary" | ||
> | ||
<div | ||
class="child1" | ||
/> | ||
</div> | ||
</div> | ||
`; | ||
|
||
exports[`SplitterLayout matches snapshot two children 1`] = ` | ||
<div | ||
class="splitter-layout splitter-layout-vertical" | ||
> | ||
<div | ||
class="layout-pane layout-pane-primary" | ||
> | ||
<div | ||
class="child1" | ||
/> | ||
</div> | ||
<div | ||
class="layout-splitter" | ||
role="separator" | ||
/> | ||
<div | ||
class="layout-pane" | ||
style="height: 50%;" | ||
> | ||
<div | ||
class="child2" | ||
/> | ||
</div> | ||
</div> | ||
`; |
48 changes: 48 additions & 0 deletions
48
web-console/src/components/splitter-layout/layout-pane.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import classNames from 'classnames'; | ||
import type { ReactNode } from 'react'; | ||
|
||
export interface LayoutPaneProps { | ||
vertical?: boolean; | ||
size: number | undefined; | ||
percentage?: boolean; | ||
children: ReactNode; | ||
} | ||
|
||
export function LayoutPane(props: LayoutPaneProps) { | ||
return ( | ||
<div | ||
className={classNames('layout-pane', { | ||
'layout-pane-primary': typeof props.size === 'undefined', | ||
})} | ||
style={ | ||
typeof props.size === 'number' | ||
? { | ||
[props.vertical ? 'height' : 'width']: `${props.size}${ | ||
props.percentage ? '%' : 'px' | ||
}`, | ||
} | ||
: undefined | ||
} | ||
> | ||
{props.children} | ||
</div> | ||
); | ||
} |
68 changes: 68 additions & 0 deletions
68
web-console/src/components/splitter-layout/splitter-layout.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// Originally copied from https://github.com/zesik/react-splitter-layout/blob/master/src/stylesheets/index.css and heavily refactored | ||
|
||
$default-splitter-size: 8px; | ||
|
||
.splitter-layout { | ||
display: flex; | ||
overflow: hidden; | ||
|
||
&.splitter-layout-horizontal { | ||
flex-direction: row; | ||
|
||
&.layout-changing { | ||
cursor: col-resize; | ||
} | ||
|
||
& > .layout-splitter { | ||
width: $default-splitter-size; | ||
height: 100%; | ||
cursor: col-resize; | ||
} | ||
} | ||
|
||
&.splitter-layout-vertical { | ||
flex-direction: column; | ||
|
||
&.layout-changing { | ||
cursor: row-resize; | ||
} | ||
|
||
& > .layout-splitter { | ||
width: 100%; | ||
height: $default-splitter-size; | ||
cursor: row-resize; | ||
} | ||
} | ||
|
||
& > .layout-pane { | ||
position: relative; | ||
flex: 0 0 auto; | ||
overflow: auto; | ||
|
||
&.layout-pane-primary { | ||
flex: 1 1 auto; | ||
} | ||
} | ||
|
||
& > .layout-splitter { | ||
flex: 0 0 auto; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
web-console/src/components/splitter-layout/splitter-layout.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { render } from '@testing-library/react'; | ||
|
||
import { SplitterLayout } from './splitter-layout'; | ||
|
||
describe('SplitterLayout', () => { | ||
it('matches snapshot one child', () => { | ||
const splitterLayout = ( | ||
<SplitterLayout primaryMinSize={100} secondaryInitialSize={50} secondaryMinSize={10}> | ||
<div className="child1" /> | ||
</SplitterLayout> | ||
); | ||
|
||
const { container } = render(splitterLayout); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('matches snapshot two children', () => { | ||
const splitterLayout = ( | ||
<SplitterLayout | ||
vertical | ||
percentage | ||
primaryMinSize={100} | ||
secondaryInitialSize={50} | ||
secondaryMinSize={10} | ||
> | ||
<div className="child1" /> | ||
<div className="child2" /> | ||
</SplitterLayout> | ||
); | ||
|
||
const { container } = render(splitterLayout); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.