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

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 80
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 63
mnd 1
bc 1
fnc 0
dl 0
loc 80
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import { BooleanProp, Demo, StringProp } from "@cianciarusocataldo/demo-ui";
2
3
import { Dropdown } from "modular-ui-preview";
4
import { ComponentPage } from "app/components/ComponentPage";
5
import { DEMO_COMMON_PROPS } from "app/constants/demo-props";
6
7
const DropdownPage = () => (
8
  <ComponentPage
9
    name="Dropdown"
10
    translations
11
    render={(t, componentLabel) => {
12
      const iconsLabel = t("props_icons");
13
      const elementLabel = t("props_element", {
14
        index: "<INDEX>",
15
      });
16
17
      return (
18
        <Demo
19
          label={componentLabel}
20
          props={{
21
            [iconsLabel]: BooleanProp(false),
22
            label: StringProp('label'),
23
            ...DEMO_COMMON_PROPS,
24
          }}
25
          startColor="#ebe5e2"
26
        >
27
          {(props: any) => {
28
            const icon = props[iconsLabel] ? (
29
              <div
30
                style={{
31
                  marginTop: "auto",
32
                  marginBottom: "auto",
33
                  marginLeft: "0.25rem",
34
                  marginRight: "0.25rem",
35
                }}
36
              >
37
                <i
38
                  style={{
39
                    border: "solid",
40
                    borderWidth: "0 3px 3px 0",
41
                    display: "block",
42
                    padding: "3px",
43
                  }}
44
                ></i>
45
              </div>
46
            ) : undefined;
47
48
            const elements = [
49
              {
50
                name: elementLabel.replace("<INDEX>", "1"),
51
                icon: icon,
52
              },
53
              {
54
                name: elementLabel.replace("<INDEX>", "2"),
55
                icon: icon,
56
              },
57
            ];
58
59
            return (
60
              <div className="flex flex-col items-center bg-transparent ">
61
                <Dropdown
62
                  className={props.className}
63
                  hide={props.hide}
64
                  dark={props.dark}
65
                  shadow={props.shadow}
66
                  unstyled={props.unstyled}
67
                  label={props.label}
68
                  content={elements}
69
                />
70
              </div>
71
            );
72
          }}
73
        </Demo>
74
      );
75
    }}
76
  />
77
);
78
79
export default DropdownPage;
80