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

Update EUI layout components in bfetch example plugin #163490

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 12 additions & 23 deletions examples/bfetch_explorer/public/components/page/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,23 @@
*/

import * as React from 'react';
import {
EuiPageBody,
EuiPageContent_Deprecated as EuiPageContent,
EuiPageContentBody_Deprecated as EuiPageContentBody,
EuiPageHeader,
EuiPageHeaderSection,
EuiTitle,
} from '@elastic/eui';
import { EuiPageTemplate, EuiPageSection, EuiPageHeader } from '@elastic/eui';

export interface PageProps {
title?: React.ReactNode;
sidebar?: React.ReactNode;
}

export const Page: React.FC<PageProps> = ({ title = 'Untitled', children }) => {
export const Page: React.FC<PageProps> = ({ title = 'Untitled', sidebar, children }) => {
return (
<EuiPageBody>
<EuiPageHeader>
<EuiPageHeaderSection>
<EuiTitle size="l">
<h1>{title}</h1>
</EuiTitle>
</EuiPageHeaderSection>
</EuiPageHeader>
<EuiPageContent>
<EuiPageContentBody style={{ maxWidth: 800, margin: '0 auto' }}>
{children}
</EuiPageContentBody>
</EuiPageContent>
</EuiPageBody>
<EuiPageTemplate panelled={true} offset={0} grow={true}>
<EuiPageTemplate.Sidebar>{sidebar}</EuiPageTemplate.Sidebar>
<EuiPageTemplate.Header>
<EuiPageHeader pageTitle={title} />
</EuiPageTemplate.Header>
<EuiPageTemplate.Section>
<EuiPageSection style={{ maxWidth: 800, margin: '0 auto' }}>{children}</EuiPageSection>
</EuiPageTemplate.Section>
</EuiPageTemplate>
);
};
2 changes: 0 additions & 2 deletions examples/bfetch_explorer/public/containers/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { Redirect } from 'react-router-dom';
import { BrowserRouter as Router, Route, Routes } from '@kbn/shared-ux-router';
import { EuiPage } from '@elastic/eui';
import { useDeps } from '../../hooks/use_deps';
import { Sidebar } from './sidebar';
import { routes } from '../../routes';

export const App: React.FC = () => {
Expand All @@ -27,7 +26,6 @@ export const App: React.FC = () => {
return (
<Router basename={appBasePath}>
<EuiPage>
<Sidebar />
<Routes>
{routeElements}
<Redirect to="/count-until" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { EuiPanel, EuiText } from '@elastic/eui';
import { CountUntil } from '../../../../components/count_until';
import { Page } from '../../../../components/page';
import { useDeps } from '../../../../hooks/use_deps';
import { Sidebar } from '../../sidebar';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Props {}
Expand All @@ -19,7 +20,7 @@ export const PageCountUntil: React.FC<Props> = () => {
const { plugins } = useDeps();

return (
<Page title={'Count Until'}>
<Page title={'Count Until'} sidebar={<Sidebar />}>
<EuiText>
This demo sends a single number N using <code>fetchStreaming</code> to the server. The
server will stream back N number of messages with 1 second delay each containing a number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { EuiPanel, EuiText } from '@elastic/eui';
import { DoubleIntegers } from '../../../../components/double_integers';
import { Page } from '../../../../components/page';
import { useDeps } from '../../../../hooks/use_deps';
import { Sidebar } from '../../sidebar';

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Props {}
Expand All @@ -19,7 +20,7 @@ export const PageDoubleIntegers: React.FC<Props> = () => {
const { explorer } = useDeps();

return (
<Page title={'Double Integers'}>
<Page title={'Double Integers'} sidebar={<Sidebar />}>
<EuiText>
Below is a list of numbers in milliseconds. They are sent as a batch to the server. For each
number server waits given number of milliseconds then doubles the number and streams it
Expand Down
40 changes: 19 additions & 21 deletions examples/bfetch_explorer/public/containers/app/sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import React from 'react';
import { EuiPageSideBar_Deprecated as EuiPageSideBar, EuiSideNav } from '@elastic/eui';
import { EuiSideNav } from '@elastic/eui';
import { useHistory } from 'react-router-dom';
import { routes } from '../../../routes';

Expand All @@ -18,26 +18,24 @@ export const Sidebar: React.FC<SidebarProps> = () => {
const history = useHistory();

return (
<EuiPageSideBar>
<EuiSideNav
items={[
{
name: 'bfetch explorer',
id: 'home',
items: routes.map(({ id, title, items }) => ({
id,
name: title,
isSelected: true,
items: items.map((route) => ({
id: route.id,
name: route.title,
onClick: () => history.push(`/${route.id}`),
'data-test-subj': route.id,
})),
<EuiSideNav
items={[
{
name: 'bfetch explorer',
id: 'home',
items: routes.map(({ id, title, items }) => ({
id,
name: title,
isSelected: true,
items: items.map((route) => ({
id: route.id,
name: route.title,
onClick: () => history.push(`/${route.id}`),
'data-test-subj': route.id,
})),
},
]}
/>
</EuiPageSideBar>
})),
},
]}
/>
);
};
Loading