src/components/molecules/Container/index.tsx
last analyzed

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 54
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 0
eloc 18
mnd 0
bc 0
fnc 0
dl 0
loc 54
ccs 10
cts 10
cp 1
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1 1
import "./styles.css";
2
3
import { ContainerComponent } from "./types";
4
5 1
import { buildComponent } from "../../../utils";
6 1
import classNames from "classnames";
7
8
/**
9
 * A simple but smart container, enhanced with modular-ui common props and animations (if enabled)
10
 *
11
 * @since 3.0.0
12
 *
13
 * @param wrapper component type. The Container component can wrap a content inside different components (by now, )
14
 * @param children content to render inside Container
15
 * @param animated if `true`, the Container will be showed with a fade-in effect
16
 * @param {string} className `common modular-ui prop` - custom className (to better customize it)
17
 * @param {boolean} unstyled `common modular-ui prop` - Style/unstyle component (to better customize it)
18
 * @param {string} id `common modular-ui prop` - `data-id` parameter (for testing purpose, to easily find the component into the DOM)
19
 * @param {boolean} dark `common modular-ui prop` - Enable/disable dark mode
20
 * @param {boolean} hide `common modular-ui prop` - Hide/show component
21
 * @param {boolean} shadow `common modular-ui prop` - Enable/disable shadow behind component (to better customize it)
22
 *
23
 * @example <caption>Example Container usage</caption>
24
 * import { render } from "react-dom";
25
 * import { Container } from '@cianciarusocataldo/modular-ui';
26
 *
27
 * render(<Container animated dark> Example content </Container>, document.getElementById("root"));
28
 *
29
 * @see https://cianciarusocataldo.github.io/modular-ui/components/molecules/Container
30
 *
31
 * @author Cataldo Cianciaruso <https://github.com/CianciarusoCataldo>
32
 *
33
 * @copyright 2022 Cataldo Cianciaruso
34
 */
35 1
const Container: ContainerComponent = ({
36 19
  children,
37 19
  wrapper,
38 19
  animated,
39 19
  ...commonProps
40
}) =>
41 19
  buildComponent({
42
    name: "modular-container",
43
    Component: children,
44
    commonProps: {
45
      ...commonProps,
46
      className: classNames(commonProps.className, {
47
        animated: animated && !commonProps.hide,
48
      }),
49
    },
50
    wrapper,
51
  });
52
53
export default Container;
54