-
Notifications
You must be signed in to change notification settings - Fork 895
[EuiAutoSizer] AutoSizer wrapper and testenv mock
#5278
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
dcc795c
add euiautosizer
thompsongl 7bfa2e3
use euiautosizer
thompsongl 1be90a8
use euiautosizer testenv mock
thompsongl 34449da
CL
thompsongl 0935be7
docs
thompsongl 946cf55
props table
thompsongl 01f3378
Merge branch 'master' into 4446-virtualized
thompsongl cc41c73
simplify wrapper
thompsongl 8b93c57
add data-eui attr to testenv mock
thompsongl b518ec8
Merge branch 'master' into 4446-virtualized
thompsongl e603110
Merge branch 'master' into 4446-virtualized
thompsongl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,30 @@ | ||
| import React from 'react'; | ||
| import { css } from '@emotion/react'; | ||
|
|
||
| import { EuiAutoSizer, EuiCode, EuiPanel } from '../../../../src/components'; | ||
|
|
||
| export default () => { | ||
| const containerStyles = css` | ||
| height: 200px; | ||
| width: 100%; | ||
| `; | ||
|
|
||
| const panelStyles = css` | ||
| position: absolute; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| `; | ||
|
|
||
| return ( | ||
| <div css={containerStyles}> | ||
| <EuiAutoSizer> | ||
| {({ height, width }) => ( | ||
| <EuiPanel css={[panelStyles, { height, width }]}> | ||
| <EuiCode>{`height: ${height}, width: ${width}`}</EuiCode> | ||
| </EuiPanel> | ||
| )} | ||
| </EuiAutoSizer> | ||
| </div> | ||
| ); | ||
| }; |
This file contains hidden or 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,42 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { GuideSectionTypes } from '../../components'; | ||
| import { EuiLink, EuiAutoSizer } from '../../../../src/components'; | ||
|
|
||
| import AutoSizer from './auto_sizer'; | ||
| const autoSizerSource = require('!!raw-loader!./auto_sizer'); | ||
|
|
||
| const autoSizerSnippet = `<EuiAutoSizer> | ||
| {({height, width}) => | ||
| (<!-- Component goes here -->) | ||
| } | ||
| </EuiAutoSizer>`; | ||
|
|
||
| export const AutoSizerExample = { | ||
| title: 'Auto sizer', | ||
| sections: [ | ||
| { | ||
| source: [ | ||
| { | ||
| type: GuideSectionTypes.JS, | ||
| code: autoSizerSource, | ||
| }, | ||
| ], | ||
| text: ( | ||
| <p> | ||
| <strong>EuiAutoSizer</strong> helps components that use virtualized | ||
| rendering and/or require explicit dimensions to fill all available | ||
| space in the parent container. See the{' '} | ||
| <EuiLink href="https://github.com/bvaughn/react-virtualized/blob/master/docs/AutoSizer.md"> | ||
| react-virtualized-auto-sizer | ||
| </EuiLink>{' '} | ||
| documentation as <strong>EuiAutoSizer</strong> is a passthrough | ||
| component for <strong>AutoSizer</strong>. | ||
| </p> | ||
| ), | ||
| props: { EuiAutoSizer }, | ||
| demo: <AutoSizer />, | ||
| snippet: autoSizerSnippet, | ||
| }, | ||
| ], | ||
| }; |
This file contains hidden or 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,21 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| export const EuiAutoSizer = ({ | ||
| children, | ||
| defaultHeight, | ||
| defaultWidth, | ||
| }: any) => { | ||
| const childrenParams = { | ||
| height: defaultHeight ?? 600, | ||
| width: defaultWidth ?? 600, | ||
| }; | ||
| return <div>{children(childrenParams)}</div>; | ||
| }; | ||
This file contains hidden or 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,19 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import React, { FunctionComponent } from 'react'; | ||
| import AutoSizer, { AutoSizerProps } from 'react-virtualized-auto-sizer'; | ||
|
|
||
| export interface EuiAutoSizerProps extends AutoSizerProps {} | ||
|
|
||
| export const EuiAutoSizer: FunctionComponent<EuiAutoSizerProps> = ({ | ||
|
thompsongl marked this conversation as resolved.
Outdated
|
||
| children, | ||
| ...rest | ||
| }) => { | ||
| return <AutoSizer {...rest}>{children}</AutoSizer>; | ||
| }; | ||
This file contains hidden or 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,9 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0 and the Server Side Public License, v 1; you may not use this file except | ||
| * in compliance with, at your election, the Elastic License 2.0 or the Server | ||
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| export { EuiAutoSizer, EuiAutoSizerProps } from './auto_sizer'; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.