Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ibm
GitHub Repository: ibm/watson-machine-learning-samples
Path: blob/master/cloud/ai-service-apps/nextjs-carbon-react-ui/src/components/Avatar/Avatar.js
6408 views
1
// Modules -------------------------------------------------------------------->
2
3
import React from "react";
4
import PropTypes from "prop-types";
5
import cx from "classnames";
6
7
import {
8
Watsonx,
9
Bot,
10
Connect,
11
WatsonHealth3DCurveAutoColon,
12
Bee,
13
ChatBot,
14
DataCategorical,
15
FaceActivated,
16
Gamification,
17
User,
18
Branch,
19
Concept,
20
Bicycle,
21
Umbrella,
22
Chemistry,
23
DecisionTree,
24
Flash,
25
Gem,
26
} from "@carbon/react/icons";
27
28
// Globals -------------------------------------------------------------------->
29
30
const ICONS = {
31
Watsonx: {
32
ICON: () => <Watsonx />,
33
REF: Watsonx,
34
},
35
Bot: {
36
ICON: () => <Bot />,
37
REF: Bot,
38
},
39
Connect: {
40
ICON: () => <Connect />,
41
REF: Connect,
42
},
43
WatsonHealth3DCurveAutoColon: {
44
ICON: () => <WatsonHealth3DCurveAutoColon />,
45
REF: WatsonHealth3DCurveAutoColon,
46
},
47
Bee: {
48
ICON: () => <Bee />,
49
REF: Bee,
50
},
51
ChatBot: {
52
ICON: () => <ChatBot />,
53
REF: ChatBot,
54
},
55
DataCategorical: {
56
ICON: () => <DataCategorical />,
57
REF: DataCategorical,
58
},
59
FaceActivated: {
60
ICON: () => <FaceActivated />,
61
REF: FaceActivated,
62
},
63
Gamification: {
64
ICON: () => <Gamification />,
65
REF: Gamification,
66
},
67
User: {
68
ICON: () => <User />,
69
REF: User,
70
},
71
Branch: {
72
ICON: () => <Branch />,
73
REF: Branch,
74
},
75
Concept: {
76
ICON: () => <Concept />,
77
REF: Concept,
78
},
79
Bicycle: {
80
ICON: () => <Bicycle />,
81
REF: Bicycle,
82
},
83
Umbrella: {
84
ICON: () => <Umbrella />,
85
REF: Umbrella,
86
},
87
Chemistry: {
88
ICON: () => <Chemistry />,
89
REF: Chemistry,
90
},
91
DecisionTree: {
92
ICON: () => <DecisionTree />,
93
REF: DecisionTree,
94
},
95
Flash: {
96
ICON: () => <Flash />,
97
REF: Flash,
98
},
99
Gem: {
100
ICON: () => <Gem />,
101
REF: Gem,
102
},
103
};
104
105
const COLORS = {
106
background: "avatar__colorBackground",
107
supportWarning: "avatar__colorSupportWarning",
108
supportCautionMajor: "avatar__colorSupportCautionMajor",
109
supportError: "avatar__colorSupportError",
110
backgroundSelected: "avatar__colorBackgroundSelected",
111
layerAccentActive02: "avatar__colorLayerAccentActive02",
112
backgroundBrand: "avatar__colorBackgroundBrand",
113
supportSuccessInverse: "avatar__colorSupportSuccessInverse",
114
tagBackground: "avatar__colorTagBackground",
115
linkPrimary: "avatar__colorLinkPrimary",
116
supportInfo: "avatar__colorSupportInfo",
117
supportSuccess: "avatar__colorSupportSuccess",
118
};
119
120
// Classes -------------------------------------------------------------------->
121
122
const Avatar = ({ color = "background", icon = "Bot", chat = false, profile = false }) => {
123
const avatarStyle = cx("avatar__avatar", COLORS[color], {
124
["chat"]: chat,
125
["profile"]: profile,
126
});
127
128
return <div className={avatarStyle}>{icon && ICONS[icon].ICON()}</div>;
129
};
130
131
Avatar.propTypes = {
132
icon: PropTypes.string,
133
color: PropTypes.string,
134
chat: PropTypes.bool,
135
};
136
137
// Public Methods ------------------------------------------------------------->
138
139
export { Avatar, ICONS, COLORS };
140
141