-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathComponentIcon.tsx
More file actions
35 lines (26 loc) · 1.11 KB
/
ComponentIcon.tsx
File metadata and controls
35 lines (26 loc) · 1.11 KB
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
import { validateProps } from 'botframework-webchat-react-valibot';
import { useStyles } from 'botframework-webchat-styles/react';
import cx from 'classnames';
import React, { memo } from 'react';
import { object, optional, pipe, readonly, string, type InferInput } from 'valibot';
import createIconComponent from '../Utils/createIconComponent';
import styles from './ComponentIcon.module.css';
const componentIconPropsSchema = pipe(
object({
appearance: optional(string()),
className: optional(string()),
icon: optional(string()),
size: optional(string())
}),
readonly()
);
type ComponentIconProps = InferInput<typeof componentIconPropsSchema>;
function BaseComponentIcon(props: ComponentIconProps) {
const { className } = validateProps(componentIconPropsSchema, props);
const classNames = useStyles(styles);
return <div className={cx(classNames['component-icon'], className)} />;
}
const ComponentIcon = createIconComponent(styles, BaseComponentIcon);
ComponentIcon.displayName = 'ComponentIcon';
export default memo(ComponentIcon);
export { componentIconPropsSchema, type ComponentIconProps };