/*
* SPDX-FileCopyrightText: 2019-2022 CERN.
* SPDX-License-Identifier: MIT
*/
import { Component } from "react";
import { Button, Container, Divider, Header, Menu, Segment } from "semantic-ui-react";
import { CERNVideosReactSearchKit } from "./cern-videos";
import NamespacedExample from "./cern-videos-namespaced/app";
import { OSReactSearchKit } from "./opensearch";
import { ZenodoReactSearchKit } from "./zenodo";
const demos = {
"os2": {
label: "OpenSearch 2",
text: "You Know, for Search",
cmp: ,
},
"zenodo": {
label: "zenodo.org",
text: "(All) Research. Shared.",
cmp: ,
},
"cern-videos": {
label: "videos.cern.ch",
text: "The CERN official platform for videos.",
cmp: ,
},
"namespaced_example": {
label: "video.cern.ch namespaced",
text: "Example of multiple React-SearchKit instances rendered at same time, namespaced by their appName, with different overridden components.",
cmp: ,
},
};
export default class App extends Component {
constructor(props) {
super(props);
this.state = { activeDemo: null };
}
resetUrlParams = () => {
window.history.pushState({}, document.title, "/");
};
renderHeader = () => {
const { activeDemo } = this.state;
const demoMenus = Object.keys(demos).map((key) => (
{
this.setState({ activeDemo: key });
}}
>
{demos[key].label}
));
return (
);
};
renderContent = () => {
const { activeDemo } = this.state;
const links = Object.keys(demos).map((key) => (
{demos[key].text}
));
const defaultCmp = (
This is a collection of demos to show how to use React-SearchKit and
components.
Choose between one of the available demos:
{links}
);
const cmp = activeDemo && activeDemo in demos ? demos[activeDemo].cmp : defaultCmp;
return {cmp};
};
render = () => {
const { activeDemo } = this.state;
if (!activeDemo) {
this.resetUrlParams();
}
return (
<>
{this.renderHeader()}
{this.renderContent()}
>
);
};
}