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

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 63
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 51
mnd 1
bc 1
fnc 0
dl 0
loc 63
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import React from "react";
2
3
import { DEMO_COMMON_PROPS } from "app/constants/demo-props";
4
5
import { Demo, SelectProp } from "@cianciarusocataldo/demo-ui";
6
7
import { Button, Drawer } from "modular-ui-preview";
8
import { ComponentPage } from "app/components/ComponentPage";
9
10
const DrawerPage = () => {
11
  const [isVisible, setVisible] = React.useState(false);
12
13
  let demoProps = { ...DEMO_COMMON_PROPS };
14
  delete demoProps.hide;
15
16
  return (
17
    <ComponentPage
18
      name="Drawer"
19
      translations
20
      render={(t, componentLabel) => {
21
        const buttonText = t(isVisible ? "common_close" : "common_open");
22
23
        return (
24
          <Demo
25
            label={componentLabel}
26
            startColor="#C3BBBB"
27
            props={{
28
              position: SelectProp({
29
                top: "top",
30
                "top-left": "top-left",
31
                "top-right": "top-right",
32
                bottom: "bottom",
33
                "bottom-left": "bottom-left",
34
                "bottom-right": "bottom-right",
35
                left: "left",
36
                right: "right",
37
              }),
38
              ...demoProps,
39
            }}
40
          >
41
            {(props: any) => {
42
              return (
43
                <div className="flex flex-col items-center">
44
                  <Button onClick={() => setVisible(!isVisible)}>
45
                    {buttonText}
46
                  </Button>
47
                  <Drawer
48
                    hide={!isVisible}
49
                    onClose={() => setVisible(false)}
50
                    {...props}
51
                  />
52
                </div>
53
              );
54
            }}
55
          </Demo>
56
        );
57
      }}
58
    />
59
  );
60
};
61
62
export default DrawerPage;
63