-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathindex.tsx
91 lines (83 loc) · 2.66 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright 2021 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
import React from "react";
import classnames from "classnames/bind";
import styles from "./summaryCard.module.scss";
import booleanSettingStyles from "../settings/booleanSetting.module.scss";
import { CircleFilled } from "src/icon";
import { Tooltip } from "antd";
interface ISummaryCardProps {
children: React.ReactNode;
className?: string;
}
const cx = classnames.bind(styles);
const booleanSettingCx = classnames.bind(booleanSettingStyles);
// tslint:disable-next-line: variable-name
export const SummaryCard: React.FC<ISummaryCardProps> = ({
children,
className = "",
}) => <div className={`${cx("summary--card")} ${className}`}>{children}</div>;
interface ISummaryCardItemProps {
label: React.ReactNode;
value: React.ReactNode;
className?: string;
}
interface ISummaryCardItemBoolSettingProps extends ISummaryCardItemProps {
toolTipText: React.ReactNode;
}
export const SummaryCardItem: React.FC<ISummaryCardItemProps> = ({
label,
value,
className = "",
}) => (
<div className={cx("summary--card__item", className)}>
<h4 className={cx("summary--card__item--label")}>{label}</h4>
<p className={cx("summary--card__item--value")}>{value}</p>
</div>
);
export const SummaryCardItemBoolSetting: React.FC<ISummaryCardItemBoolSettingProps> = ({
label,
value,
toolTipText,
className,
}) =>
value ? (
<div className={cx("summary--card__item", className)}>
<h4 className={cx("summary--card__item--label")}>{label}</h4>
<p className={cx("summary--card__item--value")}>
<CircleFilled
className={booleanSettingCx("bool-setting-icon__enabled")}
/>
<Tooltip
placement="bottom"
title={toolTipText}
className={cx("crl-hover-text__dashed-underline")}
>
Enabled
</Tooltip>
</p>
</div>
) : (
<div className={cx("summary--card__item", className)}>
<h4 className={cx("summary--card__item--label")}>{label}</h4>
<p className={cx("summary--card__item--value")}>
<CircleFilled
className={booleanSettingCx("bool-setting-icon__disabled")}
/>
<Tooltip
placement="bottom"
title={toolTipText}
className={cx("crl-hover-text__dashed-underline")}
>
Disabled
</Tooltip>
</p>
</div>
);