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

EuiResizableContainer #2701

Merged
merged 50 commits into from
Apr 30, 2020
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
9e90132
Create a resizable_container
sulemanof Nov 28, 2019
65abee5
Merge remote-tracking branch 'upstream/master' into resizable_container
sulemanof Dec 19, 2019
9fe9b05
Tune styles, add props
sulemanof Dec 19, 2019
967fe80
Add vertical container, scrollable panel
sulemanof Dec 21, 2019
79d427f
Merge remote-tracking branch 'upstream/master' into resizable_container
sulemanof Jan 29, 2020
3cb7f13
Merge remote-tracking branch 'upstream/master' into resizable_container
sulemanof Feb 13, 2020
5a7792f
Use several panels, update docs
sulemanof Feb 20, 2020
8449976
Merge remote-tracking branch 'upstream/master' into resizable_container
sulemanof Feb 20, 2020
b464a45
added styles + resizeble resizer example
Mar 21, 2020
5ec1069
added styles + resizeble resizer example
Mar 21, 2020
8abe6e2
remove leftover code mistake
Mar 21, 2020
578ae81
Merge branch 'master' into resizable_container
thompsongl Mar 25, 2020
3f9dc69
Merge branch 'master' into resizable_container
thompsongl Apr 20, 2020
5295163
license headers
thompsongl Apr 20, 2020
8fb3c27
rename all the things
thompsongl Apr 20, 2020
e460520
Merge branch 'master' into resizable_container
thompsongl Apr 21, 2020
57f6041
new badge
thompsongl Apr 21, 2020
e1b00af
flex-shrink resizer button
thompsongl Apr 21, 2020
43fa038
docs
thompsongl Apr 21, 2020
bf6dbfe
Merge branch 'master' into resizable_container
thompsongl Apr 21, 2020
89d597f
Merge branch 'master' into resizable_container
thompsongl Apr 21, 2020
0f8e8ad
Merge branch 'master' into resizable_container
thompsongl Apr 22, 2020
9455e19
type adjustments
thompsongl Apr 22, 2020
f869b91
tests
thompsongl Apr 22, 2020
e5e6c9d
touch support
thompsongl Apr 22, 2020
d8a5865
Merge branch 'master' into resizable_container
thompsongl Apr 22, 2020
ccaa1d2
Merge branch 'master' into resizable_container
thompsongl Apr 23, 2020
4331f4a
type update
thompsongl Apr 23, 2020
d163fb2
Merge branch 'master' into resizable_container
thompsongl Apr 23, 2020
0fc8a69
docs copyedit
thompsongl Apr 23, 2020
bd5606c
handle mouse leave
thompsongl Apr 23, 2020
a745b61
cancel dragging when keyboard in use
thompsongl Apr 23, 2020
f1d92e7
prevent resizer position overlap and resulting jank
thompsongl Apr 23, 2020
4c81e39
keyboard scrollable panels
thompsongl Apr 23, 2020
d211dc4
focus state cleanup
snide Apr 23, 2020
ef67098
sass cleanup
snide Apr 23, 2020
d61f143
some aria wording
snide Apr 23, 2020
58fbf37
remove scrollbar mixin maagic
snide Apr 24, 2020
2f0de93
scrollable default
thompsongl Apr 24, 2020
bb15941
resizer focus on click
thompsongl Apr 24, 2020
5802387
safari animation fix
thompsongl Apr 24, 2020
d6ee629
Merge branch 'master' into resizable_container
thompsongl Apr 24, 2020
d362d6c
Merge branch 'master' into resizable_container
thompsongl Apr 27, 2020
f86edcd
Merge branch 'master' into resizable_container
thompsongl Apr 28, 2020
07c268e
respect minSize
thompsongl Apr 28, 2020
3028f1e
Merge branch 'master' into resizable_container
thompsongl Apr 29, 2020
438197f
CL
thompsongl Apr 29, 2020
57e0caa
stricter context access; static getPanelMinSize; clean up
thompsongl Apr 29, 2020
64707d5
deregister panel on clean up
thompsongl Apr 29, 2020
a6dfa2d
Merge branch 'master' into resizable_container
thompsongl Apr 30, 2020
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Added `closeButtonProps` to `EuiCollapsibleNav` ([#3398](https://github.com/elastic/eui/pull/3398))
- Added `buffer` prop to `EuiPopover` for altering minimum distance to container edges ([#3398](https://github.com/elastic/eui/pull/3398))
- Allowed `search` prop changes to update `EuiInMemoryTable` internal query state ([#3371](https://github.com/elastic/eui/pull/3371))
- Added `EuiResizableContainer` component ([#2701](https://github.com/elastic/eui/pull/2701))

**Bug Fixes**

Expand Down
3 changes: 3 additions & 0 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ import { TreeViewExample } from './views/tree_view/tree_view_example';

import { ResizeObserverExample } from './views/resize_observer/resize_observer_example';

import { ResizableContainerExample } from './views/resizable_container/resizable_container_example';

import { ResponsiveExample } from './views/responsive/responsive_example';

import { SearchBarExample } from './views/search_bar/search_bar_example';
Expand Down Expand Up @@ -328,6 +330,7 @@ const navigation = [
PageExample,
PanelExample,
PopoverExample,
ResizableContainerExample,
SpacerExample,
].map(example => createExample(example)),
},
Expand Down
29 changes: 29 additions & 0 deletions src-docs/src/views/resizable_container/lorem.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Lorem ipsum dolor sit amet, omnis omittam patrioque eam ad, eum
discere efficiantur ut. Ei duo sale melius discere, per animal
equidem rationibus at. Maiestatis mnesarchum per ea, te eum option
petentium repudiandae. Ne summo dicam timeam vis, duo etiam primis
maiestatis ex. Per detraxit mediocrem ad. Ei vix postulant
aliquando, has ei epicurei quaerendum necessitatibus. No vis idque
nihil ancillae, ea nostrud incorrupte interesset mel. Ex vim paulo
docendi, docendi omittam complectitur ne quo, ea nam mundi
salutatus. An detraxit splendide sed, ridens rationibus cu has. In
nam tota meliore torquatos, stet detracto insolens cu his. Quidam
pericula cum ei, modus essent vis an, mea ut veri placerat. Ne cum
fugit dolor aeterno. No augue audiam consequuntur quo. Case
detraxit reprehendunt ad qui, vis autem possim eu, vel ut duis
erroribus. At accusata delicatissimi vis, ad eam eruditi ceteros
pertinacia, at mandamus quaerendum vis. Ut simul omittam menandri
his, quodsi vituperata et his, ut eum melius tractatos petentium.
Nec illud molestie an. Te sed dolor ridens atomorum, quem eirmod
sed id. Sea iusto dicant populo an. Ius aeque fuisset et, duo id
amet invenire. Ad duo appareat rationibus sadipscing, nullam
verterem vix no. Ut melius cetero pertinax usu, ei sententiae
reprimique eam. Eu usu ferri graeco. Ei qui paulo latine
rationibus, dico dicat tempor usu ad. Ut eligendi interesset mel,
ius ut modus animal propriae, justo epicurei no his. Ea sit enim
sale omittantur, quot malorum intellegat pro ad, ocurreret
salutatus vel cu. Brute quaeque facilisis in nec. His velit
percipitur eu, libris possim convenire nec no. Ad mel exerci
explicari, vidit brute percipitur an vim, phaedrum volutpat
consequuntur mea ad. Ei sed adhuc mentitum consetetur, ea justo
perpetua pro, cetero lucilius sententiae eos eu.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import React from 'react';

import { EuiText, EuiResizableContainer } from '../../../../src';

const text = require('!!raw-loader!./lorem.txt');

export default () => (
<EuiResizableContainer style={{ height: '400px' }}>
{(EuiResizablePanel, EuiResizableButton) => (
<>
<EuiResizablePanel initialSize={50} minSize="30%">
<EuiText>
<p>{text}</p>
<a href="">Hello world</a>
</EuiText>
</EuiResizablePanel>

<EuiResizableButton />

<EuiResizablePanel initialSize={50} minSize="200px">
<EuiText>
<p>{text}</p>
</EuiText>
</EuiResizablePanel>
</>
)}
</EuiResizableContainer>
);
242 changes: 242 additions & 0 deletions src-docs/src/views/resizable_container/resizable_container_example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
import React, { Fragment } from 'react';

import { renderToHtml } from '../../services';

import { GuideSectionTypes } from '../../components';

import {
EuiCallOut,
EuiCode,
EuiLink,
EuiResizableContainer,
EuiSpacer,
EuiText,
} from '../../../../src/components';
import { EuiResizablePanel } from '../../../../src/components/resizable_container/resizable_panel';
import { EuiResizableButton } from '../../../../src/components/resizable_container/resizable_button';

import ResizableContainerBasic from './resizable_container_basic';
import ResizableContainerVertical from './resizable_container_vertical';
import ResizableContainerThreePanels from './resizable_container_three_panels';
import ResizableContainerResetValues from './resizable_container_reset_values';
import ResizableResizerSize from './resizable_resizer_size';

const ResizableContainerSource = require('!!raw-loader!./resizable_container_basic');
const ResizableContainerVericalSource = require('!!raw-loader!./resizable_container_vertical');
const ResizableContainerThreePanelsSource = require('!!raw-loader!./resizable_container_three_panels');
const ResizableContainerResetValuesSource = require('!!raw-loader!./resizable_container_reset_values');
const ResizableResizerSizeSource = require('!!raw-loader!./resizable_resizer_size');

const ResizableContainerHtml = renderToHtml(ResizableContainerBasic);
const ResizableContainerVericalHtml = renderToHtml(ResizableContainerVertical);
const ResizableContainerThreePanelsHtml = renderToHtml(
ResizableContainerThreePanels
);
const ResizableContainerResetValuesHtml = renderToHtml(
ResizableContainerResetValues
);
const ResizableResizerSizeHtml = renderToHtml(ResizableResizerSize);

const snippet = `<EuiResizableContainer style={{ height: '400px' }}>
{(EuiResizablePanel, EuiResizableButton) => (
<>
<EuiResizablePanel initialSize={50} minSize="200px">
<EuiText>
<p>{text}</p>
</EuiText>
</EuiResizablePanel>

<EuiResizableButton />

<EuiResizablePanel initialSize={50} minSize="200px">
<EuiText>
<p>{text}</p>
</EuiText>
</EuiResizablePanel>
</>
)}
</EuiResizableContainer>`;

export const ResizableContainerExample = {
title: 'Resizable container',
isNew: true,
intro: (
<Fragment>
<EuiCallOut title="Consuming" color="warning">
<EuiText size="s">
<p>
This component is handy for various resizable containers.{' '}
<strong>EuiResizableContainer</strong> uses the{' '}
<EuiLink
href="https://reactjs.org/docs/render-props.html#using-props-other-than-render"
external>
React Render Props
</EuiLink>{' '}
technique to provide <strong>EuiResizablePanel</strong> and{' '}
<strong>EuiResizableButton</strong> components for you layout. Wrap
parts of your content with the <strong>EuiResizablePanel</strong>{' '}
component and put the <strong>EuiResizableButton</strong> component
between.
</p>
</EuiText>
</EuiCallOut>

<EuiSpacer size="l" />
</Fragment>
),
sections: [
{
source: [
{
type: GuideSectionTypes.JS,
code: ResizableContainerSource,
},
{
type: GuideSectionTypes.HTML,
code: ResizableContainerHtml,
},
],
title: 'Horizontal resizing',
text: (
<div>
<p>
Simple resizable container with two panels and a resizer between.
This is the most common case you&#39;ll need in your app. Just drag{' '}
<strong>the resizer</strong> button between two panels to
increase/decrease panel size. You could also use arrow keys{' '}
<strong>&#x2190;</strong>|<strong>&#x2192;</strong> on{' '}
<strong>the focused resizer</strong> button to change panel size.
</p>
<ul>
<li>
add <EuiCode>initialSize</EuiCode> in percents to each panel to
specify the initial size of it. Other calculations will be
incapsulated, you don&#39;t worry about it.
</li>
<li>
add <EuiCode>scrollable=false</EuiCode> prop to a panel to
eliminate overflow scrolling
</li>
</ul>
</div>
),
props: { EuiResizableContainer, EuiResizablePanel, EuiResizableButton },
snippet,
demo: <ResizableContainerBasic />,
},
{
source: [
{
type: GuideSectionTypes.JS,
code: ResizableContainerResetValuesSource,
},
{
type: GuideSectionTypes.HTML,
code: ResizableContainerResetValuesHtml,
},
],
title: 'Horizontal resizing with controlled widths',
text: (
<div>
<p>
Sometimes it&#39;s necessary to control panel sizes from the
outside. For example to store sizes in{' '}
<EuiCode>localStorage</EuiCode> or change the layout with predefined
sizes. Here is the <EuiCode>onPanelWidthChange</EuiCode> and{' '}
<EuiCode>size</EuiCode> props for help. If you use such an approach,
you have to specify an <EuiCode>id</EuiCode> prop for each panel to
track their sizes.
</p>

<EuiCallOut title="Required properties" color="warning">
<EuiText size="s">
<p>
Either <EuiCode>initialSize</EuiCode> or <EuiCode>size</EuiCode>{' '}
must be specified. The <EuiCode>size</EuiCode> prop is for cases
where a parent component will control sizing updates.
</p>
</EuiText>
</EuiCallOut>
</div>
),
props: { EuiResizableContainer, EuiResizablePanel, EuiResizableButton },
demo: <ResizableContainerResetValues />,
},
{
source: [
{
type: GuideSectionTypes.JS,
code: ResizableContainerThreePanelsSource,
},
{
type: GuideSectionTypes.HTML,
code: ResizableContainerThreePanelsHtml,
},
],
title: 'Horizontal resizing with three panels',
text: (
<p>
The <strong>EuiResizablePanel</strong> and{' '}
<strong>EuiResizableButton</strong> components can each be used
multiple times to create a more complex layout.
</p>
),
props: { EuiResizableContainer, EuiResizablePanel, EuiResizableButton },
demo: <ResizableContainerThreePanels />,
},
{
source: [
{
type: GuideSectionTypes.JS,
code: ResizableContainerVericalSource,
},
{
type: GuideSectionTypes.HTML,
code: ResizableContainerVericalHtml,
},
],
title: 'Vertical resizing',
text: (
<p>
Set <EuiCode>direction=vertical</EuiCode> on{' '}
<strong>EuiResizableContainer</strong> to set a vertical orientation
of the resizable panels.
</p>
),
props: { EuiResizableContainer, EuiResizablePanel, EuiResizableButton },
demo: (
<div className="guideDemo__highlightSpacer">
<ResizableContainerVertical />
</div>
),
},
{
source: [
{
type: GuideSectionTypes.JS,
code: ResizableResizerSizeSource,
},
{
type: GuideSectionTypes.HTML,
code: ResizableResizerSizeHtml,
},
],
title: 'Resizable button spacing',
text: (
<div>
<p>
You can control the space between panels by modifying the{' '}
<EuiCode>size</EuiCode> prop of the{' '}
<strong>EuiResizableButton</strong> component. The available sizes
are <EuiCode>xl</EuiCode>, <EuiCode>l</EuiCode>,{' '}
<EuiCode>m</EuiCode>, and <EuiCode>s</EuiCode>. You should avoid
using different sizes within the same{' '}
<strong>EuiResizableContainer</strong>, as shown in the demo below.
</p>
</div>
),
props: { EuiResizableContainer, EuiResizablePanel, EuiResizableButton },
demo: <ResizableResizerSize />,
},
],
};
Loading