|
1 | 1 | import React from "react"; |
2 | | -import { Tab, Tabs, TabList, TabPanel } from "react-tabs"; |
| 2 | +import { Tab, TabList, TabPanel, Tabs } from "react-tabs"; |
3 | 3 | import "react-tabs/style/react-tabs.css"; |
| 4 | +import Collapsible from "./Collapsible"; |
4 | 5 |
|
5 | | -import groupBy from "lodash/groupBy"; |
6 | | -import mapValues from "lodash/mapValues"; |
7 | | - |
8 | | -export default function ScannerExamples({ examples: allExamples }) { |
9 | | - const exampleGroups = mapValues( |
10 | | - groupBy(allExamples, ({ scanTarget }) => scanTarget), |
11 | | - (examples) => { |
12 | | - /* We are reversing to ensure that the right text ist displayed for the right file */ |
13 | | - return examples.reverse(); |
14 | | - } |
15 | | - ); |
16 | | - |
| 6 | +export default function ScannerExamples({ examples }) { |
17 | 7 | return ( |
18 | 8 | <div className="container-fluid"> |
19 | 9 | <h2 className="title">Examples</h2> |
20 | 10 |
|
21 | | - {Object.entries(exampleGroups).map(([targetName, examples]) => { |
| 11 | + {examples.map(({ name, description, scan, findings }) => { |
22 | 12 | return ( |
23 | | - <Tabs key={targetName}> |
24 | | - <h3>{targetName}</h3> |
25 | | - <TabList> |
26 | | - {examples.map(({ fileName }) => ( |
27 | | - <Tab key={fileName}>{fileName.split(".")[0]}</Tab> |
28 | | - ))} |
29 | | - </TabList> |
30 | | - |
31 | | - {examples.map(({ fileName, content }) => ( |
32 | | - <TabPanel key={fileName}> |
33 | | - <deckgo-highlight-code theme="cobalt"> |
34 | | - <code slot="code">{content}</code> |
35 | | - </deckgo-highlight-code> |
36 | | - </TabPanel> |
37 | | - ))} |
| 13 | + <Tabs key={name}> |
| 14 | + <Collapsible |
| 15 | + overflowWhenOpen="visible" |
| 16 | + lazyRender={true} |
| 17 | + transitionTime={150} |
| 18 | + transitionCloseTime={50} |
| 19 | + trigger={name} |
| 20 | + triggerTagName="h3" |
| 21 | + > |
| 22 | + {description && ( |
| 23 | + <div |
| 24 | + dangerouslySetInnerHTML={{ |
| 25 | + __html: description, |
| 26 | + }} |
| 27 | + ></div> |
| 28 | + )} |
| 29 | + <TabList> |
| 30 | + {scan && <Tab key={"scan"}>Scan</Tab>} |
| 31 | + {findings && <Tab key={"findings"}>Findings</Tab>} |
| 32 | + </TabList> |
| 33 | + {scan && ( |
| 34 | + <TabPanel key={"scan"}> |
| 35 | + <deckgo-highlight-code theme="cobalt"> |
| 36 | + <code slot="code">{scan}</code> |
| 37 | + </deckgo-highlight-code> |
| 38 | + </TabPanel> |
| 39 | + )} |
| 40 | + {findings && ( |
| 41 | + <TabPanel key={"findings"}> |
| 42 | + <deckgo-highlight-code theme="cobalt"> |
| 43 | + <code slot="code">{findings}</code> |
| 44 | + </deckgo-highlight-code> |
| 45 | + </TabPanel> |
| 46 | + )} |
| 47 | + </Collapsible> |
38 | 48 | </Tabs> |
39 | 49 | ); |
40 | 50 | })} |
|
0 commit comments