MCPcopy
hub / github.com/clientIO/joint / MessageComponent

Function MessageComponent

examples/joint-react/src/App.tsx:137–201  ·  view source on GitHub ↗
({
    elementType,
    title,
    description,
    inputText,
    width,
    height,
    isSelected,
}: ElementWithSelected<MessageElement>)

Source from the content-addressed store, hash-verified

135
136// Define the message component
137function MessageComponent({
138 elementType,
139 title,
140 description,
141 inputText,
142 width,
143 height,
144 isSelected,
145}: ElementWithSelected<MessageElement>) {
146 let iconContent;
147 let titleText;
148 switch (elementType) {
149 case 'alert': {
150 iconContent = (
151 <i className="fa-solid fa-triangle-exclamation text-rose-500 text-3xl mt-2"></i>
152 );
153 titleText = <span className="text-rose-500 font-bold">{title}</span>;
154 break;
155 }
156 default: {
157 iconContent = <i className="fa-solid fa-circle-info text-3xl mt-2"></i>;
158 titleText = <span className="font-bold">{title}</span>;
159 break;
160 }
161 }
162 const id = useCellId();
163 const setMessage = useUpdateElement<MessageElement>(id, 'inputText');
164 return (
165 <Highlighter.Stroke
166 padding={10}
167 rx={5}
168 ry={5}
169 strokeWidth={3}
170 stroke={LIGHT}
171 isHidden={!isSelected}
172 >
173 <foreignObject width={width} height={height} overflow="visible">
174 <MeasuredNode>
175 <div className="flex flex-row border-1 border-solid border-white/20 text-white rounded-lg p-4 min-w-[250px] min-h-[100px] bg-gray-900 shadow-sm">
176 <div className="flex flex-col gap-2">
177 <div className="flex flex-row gap-2 items-start">
178 <div className="text-2xl">{iconContent}</div>
179 <div className="text-lg ml-2">
180 {titleText}
181 <div className="text-sm mt-1">{description}</div>
182 </div>
183 </div>
184 {/* Divider */}
185 <div className="border-1 border-dashed border-rose-white mt-2 opacity-10" />
186 <input
187 type="text"
188 value={inputText}
189 className="w-full border-1 border-solid border-rose-white rounded-lg p-2 mt-3"
190 placeholder="Type here..."
191 onChange={({ target: { value }}) => {
192 setMessage(value);
193 }}
194 />

Callers

nothing calls this directly

Calls 2

useCellIdFunction · 0.90
useUpdateElementFunction · 0.90

Tested by

no test coverage detected