playground/src/app/components/ComponentPage/index.tsx   A
last analyzed

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 54
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 43
mnd 1
bc 1
fnc 0
dl 0
loc 54
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import { TFunction, useTranslation } from "react-i18next";
2
3
import { useCommonTranslation } from "hooks/localization";
4
5
import { AllowedComponent, Table } from "modular-ui-preview";
6
import AppLabel from "../AppLabel";
7
import AppPage from "../AppPage";
8
9
export const ComponentPage = ({
10
  children,
11
  name: componentName,
12
  render,
13
  props,
14
  translations,
15
}: {
16
  children?: AllowedComponent | AllowedComponent[];
17
  render?: (
18
    t: TFunction,
19
    label?: string
20
  ) => AllowedComponent | AllowedComponent[];
21
  name: string;
22
  props?: string[][];
23
  translations?: boolean;
24
}) => {
25
  const t = useCommonTranslation();
26
  const { t: tComponent } = useTranslation(
27
    translations ? componentName.toLowerCase() : "common"
28
  );
29
  const headerLabel = t("component", { componentName });
30
31
  return (
32
    <AppPage>
33
      <AppLabel className="text-4xl mt-12 mb-5 ml-3" value={headerLabel} />
34
      <div className="flex flex-col p-3 items-center">
35
        {children}
36
        {render && render(tComponent, headerLabel)}
37
        <a
38
          target="_blank"
39
          href="https://cianciarusocataldo.github.io/demo-ui"
40
          rel="noreferrer"
41
        >
42
          <img
43
            alt=""
44
            className="mt-0"
45
            src="https://img.shields.io/badge/powered%20by-demo--ui-orange"
46
            height="25"
47
          />
48
        </a>
49
        {props && <Table headers rows={props} />}
50
      </div>
51
    </AppPage>
52
  );
53
};
54