Passed
Push — dev ( 8e57b5...c7670f )
by
unknown
03:51
created

resources/assets/js/components/ContextBlock/ContextBlockItem.tsx   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 64
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 41
mnd 1
bc 1
fnc 0
dl 0
loc 64
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import * as React from "react";
2
3
export interface ContextBlockItemProps {
4
  title?: string;
5
  subtext?: string | React.ReactNode;
6
  active?: boolean;
7
  className?: string;
8
  contextId?: string;
9
  backgroundColor?: string;
10
  backgroundOpacity?: string;
11
  padding?: string;
12
  radius?: string;
13
  fontSize?: string;
14
  fontWeight?: string;
15
  wrapperMargin?: string;
16
  titleMargin?: string;
17
  bodyText?: string | React.ReactNode;
18
}
19
20
const ContextBlockItem: React.FunctionComponent<ContextBlockItemProps> = ({
21
  subtext,
22
  title,
23
  className,
24
  contextId,
25
  backgroundColor,
26
  backgroundOpacity,
27
  padding,
28
  radius,
29
  fontSize,
30
  fontWeight,
31
  wrapperMargin,
32
  titleMargin,
33
  active,
34
  bodyText,
35
}): React.ReactElement => {
36
  return (
37
    <div
38
      className={`${className || ""}${active ? " active" : ""}`}
39
      data-tc-wenv-id={contextId}
40
      data-c-background={
41
        (backgroundColor && `${backgroundColor}(${backgroundOpacity})`) ||
42
        "grey(20)"
43
      }
44
      data-c-padding={padding || "all(normal)"}
45
      data-c-radius={radius || "rounded"}
46
      data-c-margin={wrapperMargin || ""}
47
    >
48
      {title && (
49
        <p
50
          data-c-font-size={fontSize || "small"}
51
          data-c-margin={titleMargin || "bottom(half)"}
52
          data-c-font-weight={fontWeight || "bold"}
53
        >
54
          {title}
55
        </p>
56
      )}
57
      {subtext && <p data-c-font-size={fontSize || "small"}>{subtext}</p>}
58
      {bodyText && <div>{bodyText}</div>}
59
    </div>
60
  );
61
};
62
63
export default ContextBlockItem;
64