/* * 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, { useState } from 'react'; import ReactDOM from 'react-dom'; import { EuiText, EuiPageContent, EuiCard, EuiPageContentHeader, EuiFlexGroup, EuiFlexItem, EuiFieldSearch, EuiListGroup, EuiHighlight, EuiLink, EuiButtonIcon, } from '@elastic/eui'; import { AppMountParameters } from '../../../src/core/public'; import { ExampleDefinition } from './types'; interface Props { examples: ExampleDefinition[]; navigateToApp: (appId: string) => void; getUrlForApp: (appId: string) => string; } function DeveloperExamples({ examples, navigateToApp, getUrlForApp }: Props) { const [search, setSearch] = useState(''); const lcSearch = search.toLowerCase(); const filteredExamples = !lcSearch ? examples : examples.filter((def) => { if (def.description.toLowerCase().indexOf(lcSearch) >= 0) return true; if (def.title.toLowerCase().indexOf(lcSearch) >= 0) return true; return false; }); return (

Developer examples

The following examples showcase services and APIs that are available to developers. setSearch(e.target.value)} isClearable={true} aria-label="Search developer examples" />

{filteredExamples.map((def) => ( {def.description} } title={ { navigateToApp(def.appId); }} > {def.title} window.open(getUrlForApp(def.appId), '_blank', 'noopener, noreferrer') } > Open in new tab } image={def.image} footer={def.links ? : undefined} /> ))}
); } export const renderApp = (props: Props, element: AppMountParameters['element']) => { ReactDOM.render(, element); return () => ReactDOM.unmountComponentAtNode(element); };