@awsui/components-react
Version:
AWS UI is a collection of [React](https://reactjs.org/) components that help create intuitive, responsive, and accessible user experiences for web applications. It is developed by Amazon Web Services (AWS). This work is available under the terms of the [A
26 lines (25 loc) • 1.85 kB
JavaScript
import { __assign, __rest } from "tslib";
import clsx from 'clsx';
import React, { useContext } from 'react';
import { getBaseProps } from '../internal/base-component';
import styles from './styles.css.js';
import TutorialList from './components/tutorial-list';
import TutorialDetailView from './components/tutorial-detail-view';
import { hotspotContext } from '../annotation-context/context';
import { useTelemetry } from '../internal/hooks/use-telemetry';
var defaultFilteringFunction = function (tutorial, searchTerm) {
var _a;
if (searchTerm === '') {
return true;
}
return ((_a = tutorial.title) === null || _a === void 0 ? void 0 : _a.toLowerCase().indexOf(searchTerm.toLowerCase())) !== -1;
};
export default function TutorialPanel(_a) {
var i18nStrings = _a.i18nStrings, loading = _a.loading, tutorials = _a.tutorials, onFeedbackClick = _a.onFeedbackClick, downloadUrl = _a.downloadUrl, restProps = __rest(_a, ["i18nStrings", "loading", "tutorials", "onFeedbackClick", "downloadUrl"]);
useTelemetry('TutorialPanel');
var baseProps = getBaseProps(restProps);
var context = useContext(hotspotContext);
var filteringFunction = defaultFilteringFunction;
return (React.createElement(React.Fragment, null,
React.createElement("div", __assign({}, baseProps, { className: clsx(baseProps.className, styles['tutorial-panel']) }), context.currentTutorial ? (React.createElement(TutorialDetailView, { i18nStrings: i18nStrings, tutorial: context.currentTutorial, onExitTutorial: context.onExitTutorial, currentStepIndex: context.currentStepIndex, onFeedbackClick: onFeedbackClick })) : (React.createElement(TutorialList, { i18nStrings: i18nStrings, tutorials: tutorials, loading: loading, onStartTutorial: context.onStartTutorial, filteringFunction: filteringFunction, downloadUrl: downloadUrl })))));
}