mirror of
https://github.com/elastic/kibana.git
synced 2025-06-29 03:24:45 -04:00
Extend embeddable examples with a state management example. PR also refactors embeddable examples to use side nav instead of tabs. <img width="800" alt="Screenshot 2024-09-11 at 8 38 28 AM" src="https://github.com/user-attachments/assets/ac46600f-2c45-4f9e-b4f8-a5c03f4eef2f"> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
39 lines
1.1 KiB
TypeScript
39 lines
1.1 KiB
TypeScript
/*
|
|
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
|
|
* License v3.0 only", or the "Server Side Public License, v 1".
|
|
*/
|
|
|
|
import React, { useMemo } from 'react';
|
|
import { css } from '@emotion/react';
|
|
import { useHistory } from 'react-router-dom';
|
|
import { EuiSideNav } from '@elastic/eui';
|
|
|
|
export function Sidebar({ pages }: { pages: Array<{ id: string; title: string }> }) {
|
|
const history = useHistory();
|
|
|
|
const items = useMemo(() => {
|
|
return pages.map((page) => {
|
|
return {
|
|
id: page.id,
|
|
name: page.title,
|
|
onClick: () => history.push(`/${page.id}`),
|
|
};
|
|
});
|
|
}, [pages, history]);
|
|
|
|
return (
|
|
<EuiSideNav
|
|
css={{
|
|
css: css`
|
|
maxwidth: '85%';
|
|
`,
|
|
}}
|
|
truncate={false}
|
|
items={items}
|
|
/>
|
|
);
|
|
}
|