playground/src/pages/Table/index.tsx   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 0

Size

Lines of Code 51
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 40
mnd 3
bc 3
fnc 0
dl 0
loc 51
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import { DEMO_COMMON_PROPS } from "app/constants/demo-props";
2
3
import {
4
  BooleanProp,
5
  Demo,
6
  NumberProp,
7
  StringProp,
8
} from "@cianciarusocataldo/demo-ui";
9
10
import { Table } from "modular-ui-preview";
11
import { ComponentPage } from "app/components/ComponentPage";
12
13
const TablePage = () => (
14
  <ComponentPage
15
    name="Table"
16
    translations
17
    render={(t, componentLabel) => {
18
      const cell = t("props_element");
19
      const header = t("props_header");
20
21
      return (
22
        <Demo
23
          label={componentLabel}
24
          props={{
25
            label: StringProp("label"),
26
            Rows: NumberProp(2),
27
            headers: BooleanProp(true),
28
            ...DEMO_COMMON_PROPS,
29
          }}
30
        >
31
          {({ Rows: numberOfRows, ...props }: any) => {
32
            let rows = [];
33
            if (numberOfRows) {
34
              if (props.headers) {
35
                rows.push([header, header, header]);
36
              }
37
              for (let i = 0; i < numberOfRows; i++) {
38
                rows.push([cell, cell, cell]);
39
              }
40
            }
41
42
            return <Table {...props} headers={props.headers} rows={rows} />;
43
          }}
44
        </Demo>
45
      );
46
    }}
47
  />
48
);
49
50
export default TablePage;
51